diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-06 14:39:23 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-03-12 05:50:11 +0000 |
| commit | fcb890ea0c2d47d2fe6ea45fbb41fd3cb78645c8 (patch) | |
| tree | a55d55142394979bdb91e4d275d84a51570080b2 | |
| parent | 6719a8ef953ba9d90f2a589d80f41fae4531614f (diff) | |
| download | rust-fcb890ea0c2d47d2fe6ea45fbb41fd3cb78645c8.tar.gz rust-fcb890ea0c2d47d2fe6ea45fbb41fd3cb78645c8.zip | |
Use information from allocation instead of from the static's type
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 9c1b64fdb00..fbbc1ecbbca 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -358,6 +358,10 @@ impl<'ll> CodegenCx<'ll, '_> { let instance = Instance::mono(self.tcx, def_id); let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all()); + if !is_mutable { + debug_assert_eq!(alloc.mutability.is_not(), self.type_is_freeze(ty)); + } + debug_assert_eq!(alloc.align, self.align_of(ty)); let llty = self.layout_of(ty).llvm_type(self); let g = self.get_static_inner(def_id, llty); @@ -396,7 +400,7 @@ impl<'ll> CodegenCx<'ll, '_> { self.statics_to_rauw.borrow_mut().push((g, new_g)); new_g }; - set_global_alignment(self, g, self.align_of(ty)); + set_global_alignment(self, g, alloc.align); llvm::LLVMSetInitializer(g, v); if self.should_assume_dso_local(g, true) { @@ -405,7 +409,7 @@ impl<'ll> CodegenCx<'ll, '_> { // As an optimization, all shared statics which do not have interior // mutability are placed into read-only memory. - if !is_mutable && self.type_is_freeze(ty) { + if !is_mutable && alloc.mutability.is_not() { llvm::LLVMSetGlobalConstant(g, llvm::True); } |
