diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-23 20:17:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-23 20:17:52 +0200 |
| commit | a760954ca9823797660b07ed830dcf1eb8887e30 (patch) | |
| tree | 1d57e0e251238ce647e5cc0fcdec21ae4a3e65ce /compiler/rustc_codegen_cranelift/src/constant.rs | |
| parent | afb6c4681ab1701e03e03669ec41e8e7c8a495c2 (diff) | |
| parent | 96152c7df3296c00498a0a8d886b058a09325290 (diff) | |
Rollup merge of #124286 - bjorn3:sync_cg_clif-2024-04-23, r=bjorn3
Subtree sync for rustc_codegen_cranelift This fixes a crash when compiling the standard library. In addition the Cranelift update fixes all the 128bit int abi incompatibility between cg_clif and cg_llvm. r? ``@ghost`` ``@rustbot`` label +A-codegen +A-cranelift +T-compiler
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/constant.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/constant.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index cb05c17ec2a..cdf499a22f8 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -137,18 +137,23 @@ pub(crate) fn codegen_const_value<'tcx>( let alloc_id = prov.alloc_id(); let base_addr = match fx.tcx.global_alloc(alloc_id) { GlobalAlloc::Memory(alloc) => { - let data_id = data_id_for_alloc_id( - &mut fx.constants_cx, - fx.module, - alloc_id, - alloc.inner().mutability, - ); - let local_data_id = - fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - if fx.clif_comments.enabled() { - fx.add_comment(local_data_id, format!("{:?}", alloc_id)); + if alloc.inner().len() == 0 { + assert_eq!(offset, Size::ZERO); + fx.bcx.ins().iconst(fx.pointer_type, alloc.inner().align.bytes() as i64) + } else { + let data_id = data_id_for_alloc_id( + &mut fx.constants_cx, + fx.module, + alloc_id, + alloc.inner().mutability, + ); + let local_data_id = + fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + if fx.clif_comments.enabled() { + fx.add_comment(local_data_id, format!("{:?}", alloc_id)); + } + fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } - fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } GlobalAlloc::Function(instance) => { let func_id = crate::abi::import_function(fx.tcx, fx.module, instance); |
