@@ -358,6 +358,10 @@ impl<'ll> CodegenCx<'ll, '_> {
358
358
359
359
let instance = Instance :: mono ( self . tcx , def_id) ;
360
360
let ty = instance. ty ( self . tcx , ty:: ParamEnv :: reveal_all ( ) ) ;
361
+ if !is_mutable {
362
+ debug_assert_eq ! ( alloc. mutability. is_not( ) , self . type_is_freeze( ty) ) ;
363
+ }
364
+ debug_assert_eq ! ( alloc. align, self . align_of( ty) ) ;
361
365
let llty = self . layout_of ( ty) . llvm_type ( self ) ;
362
366
363
367
let g = self . get_static_inner ( def_id, llty) ;
@@ -396,7 +400,7 @@ impl<'ll> CodegenCx<'ll, '_> {
396
400
self . statics_to_rauw . borrow_mut ( ) . push ( ( g, new_g) ) ;
397
401
new_g
398
402
} ;
399
- set_global_alignment ( self , g, self . align_of ( ty ) ) ;
403
+ set_global_alignment ( self , g, alloc . align ) ;
400
404
llvm:: LLVMSetInitializer ( g, v) ;
401
405
402
406
if self . should_assume_dso_local ( g, true ) {
@@ -405,7 +409,7 @@ impl<'ll> CodegenCx<'ll, '_> {
405
409
406
410
// As an optimization, all shared statics which do not have interior
407
411
// mutability are placed into read-only memory.
408
- if !is_mutable && self . type_is_freeze ( ty ) {
412
+ if !is_mutable && alloc . mutability . is_not ( ) {
409
413
llvm:: LLVMSetGlobalConstant ( g, llvm:: True ) ;
410
414
}
411
415
0 commit comments