@@ -343,30 +343,8 @@ impl<'ll> CodegenCx<'ll, '_> {
343343 self . statics . borrow_mut ( ) . insert ( def_id, g) ;
344344 g
345345 }
346- }
347-
348- impl < ' ll > StaticMethods for CodegenCx < ' ll , ' _ > {
349- fn static_addr_of ( & self , cv : & ' ll Value , align : Align , kind : Option < & str > ) -> & ' ll Value {
350- if let Some ( & gv) = self . const_globals . borrow ( ) . get ( & cv) {
351- unsafe {
352- // Upgrade the alignment in cases where the same constant is used with different
353- // alignment requirements
354- let llalign = align. bytes ( ) as u32 ;
355- if llalign > llvm:: LLVMGetAlignment ( gv) {
356- llvm:: LLVMSetAlignment ( gv, llalign) ;
357- }
358- }
359- return gv;
360- }
361- let gv = self . static_addr_of_mut ( cv, align, kind) ;
362- unsafe {
363- llvm:: LLVMSetGlobalConstant ( gv, True ) ;
364- }
365- self . const_globals . borrow_mut ( ) . insert ( cv, gv) ;
366- gv
367- }
368346
369- fn codegen_static ( & self , def_id : DefId , is_mutable : bool ) {
347+ fn codegen_static_item ( & self , def_id : DefId , is_mutable : bool ) {
370348 unsafe {
371349 let attrs = self . tcx . codegen_fn_attrs ( def_id) ;
372350
@@ -550,6 +528,32 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
550528 }
551529 }
552530 }
531+ }
532+
533+ impl < ' ll > StaticMethods for CodegenCx < ' ll , ' _ > {
534+ fn static_addr_of ( & self , cv : & ' ll Value , align : Align , kind : Option < & str > ) -> & ' ll Value {
535+ if let Some ( & gv) = self . const_globals . borrow ( ) . get ( & cv) {
536+ unsafe {
537+ // Upgrade the alignment in cases where the same constant is used with different
538+ // alignment requirements
539+ let llalign = align. bytes ( ) as u32 ;
540+ if llalign > llvm:: LLVMGetAlignment ( gv) {
541+ llvm:: LLVMSetAlignment ( gv, llalign) ;
542+ }
543+ }
544+ return gv;
545+ }
546+ let gv = self . static_addr_of_mut ( cv, align, kind) ;
547+ unsafe {
548+ llvm:: LLVMSetGlobalConstant ( gv, True ) ;
549+ }
550+ self . const_globals . borrow_mut ( ) . insert ( cv, gv) ;
551+ gv
552+ }
553+
554+ fn codegen_static ( & self , def_id : DefId , is_mutable : bool ) {
555+ self . codegen_static_item ( def_id, is_mutable)
556+ }
553557
554558 /// Add a global value to a list to be stored in the `llvm.used` variable, an array of ptr.
555559 fn add_used_global ( & self , global : & ' ll Value ) {
0 commit comments