diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 78693a395b3..904e5d74f8e 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -195,7 +195,9 @@ pub fn compile_codegen_unit<'ll, 'tcx>(tcx: TyCtxt<'ll, 'tcx, 'tcx>, // Run replace-all-uses-with for statics that need it for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() { unsafe { - cx.static_replace_all_uses(old_g, new_g) + let bitcast = llvm::LLVMConstPointerCast(new_g, cx.val_ty(old_g)); + llvm::LLVMReplaceAllUsesWith(old_g, bitcast); + llvm::LLVMDeleteGlobal(old_g); } } diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index aac3ee903b1..47899d426f7 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -498,9 +498,4 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> { } } } - unsafe fn static_replace_all_uses(&self, old_g: &'ll Value, new_g: &'ll Value) { - let bitcast = llvm::LLVMConstPointerCast(new_g, self.val_ty(old_g)); - llvm::LLVMReplaceAllUsesWith(old_g, bitcast); - llvm::LLVMDeleteGlobal(old_g); - } } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 5b088ad2908..673122095da 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -314,6 +314,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { local_gen_sym_counter: Cell::new(0), } } + + crate fn statics_to_rauw(&self) -> &RefCell> { + &self.statics_to_rauw + } } impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { @@ -431,10 +435,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { &self.codegen_unit } - fn statics_to_rauw(&self) -> &RefCell> { - &self.statics_to_rauw - } - fn used_statics(&self) -> &RefCell> { &self.used_statics } diff --git a/src/librustc_codegen_ssa/traits/misc.rs b/src/librustc_codegen_ssa/traits/misc.rs index 0425b8e8e23..ab4f2f724cd 100644 --- a/src/librustc_codegen_ssa/traits/misc.rs +++ b/src/librustc_codegen_ssa/traits/misc.rs @@ -32,7 +32,6 @@ pub trait MiscMethods<'tcx>: Backend<'tcx> { fn stats(&self) -> &RefCell; fn consume_stats(self) -> RefCell; fn codegen_unit(&self) -> &Arc>; - fn statics_to_rauw(&self) -> &RefCell>; fn closure_env_needs_indirect_debuginfo(&self) -> bool; fn used_statics(&self) -> &RefCell>; fn set_frame_pointer_elimination(&self, llfn: Self::Value); diff --git a/src/librustc_codegen_ssa/traits/statics.rs b/src/librustc_codegen_ssa/traits/statics.rs index 5026d34dcad..aa4d69f078f 100644 --- a/src/librustc_codegen_ssa/traits/statics.rs +++ b/src/librustc_codegen_ssa/traits/statics.rs @@ -19,5 +19,4 @@ pub trait StaticMethods: BackendTypes { fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; fn get_static(&self, def_id: DefId) -> Self::Value; fn codegen_static(&self, def_id: DefId, is_mutable: bool); - unsafe fn static_replace_all_uses(&self, old_g: Self::Value, new_g: Self::Value); }