Skip to content

Commit 2d46ee2

Browse files

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed
 

‎src/librustc_codegen_llvm/base.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ pub fn compile_codegen_unit<'ll, 'tcx>(tcx: TyCtxt<'ll, 'tcx, 'tcx>,
195195
// Run replace-all-uses-with for statics that need it
196196
for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() {
197197
unsafe {
198-
cx.static_replace_all_uses(old_g, new_g)
198+
let bitcast = llvm::LLVMConstPointerCast(new_g, cx.val_ty(old_g));
199+
llvm::LLVMReplaceAllUsesWith(old_g, bitcast);
200+
llvm::LLVMDeleteGlobal(old_g);
199201
}
200202
}
201203

‎src/librustc_codegen_llvm/consts.rs

-5
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,4 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
498498
}
499499
}
500500
}
501-
unsafe fn static_replace_all_uses(&self, old_g: &'ll Value, new_g: &'ll Value) {
502-
let bitcast = llvm::LLVMConstPointerCast(new_g, self.val_ty(old_g));
503-
llvm::LLVMReplaceAllUsesWith(old_g, bitcast);
504-
llvm::LLVMDeleteGlobal(old_g);
505-
}
506501
}

‎src/librustc_codegen_llvm/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
314314
local_gen_sym_counter: Cell::new(0),
315315
}
316316
}
317+
318+
crate fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
319+
&self.statics_to_rauw
320+
}
317321
}
318322

319323
impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
@@ -431,10 +435,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
431435
&self.codegen_unit
432436
}
433437

434-
fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
435-
&self.statics_to_rauw
436-
}
437-
438438
fn used_statics(&self) -> &RefCell<Vec<&'ll Value>> {
439439
&self.used_statics
440440
}

‎src/librustc_codegen_ssa/traits/misc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub trait MiscMethods<'tcx>: Backend<'tcx> {
3232
fn stats(&self) -> &RefCell<Stats>;
3333
fn consume_stats(self) -> RefCell<Stats>;
3434
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
35-
fn statics_to_rauw(&self) -> &RefCell<Vec<(Self::Value, Self::Value)>>;
3635
fn closure_env_needs_indirect_debuginfo(&self) -> bool;
3736
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
3837
fn set_frame_pointer_elimination(&self, llfn: Self::Value);

‎src/librustc_codegen_ssa/traits/statics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ pub trait StaticMethods: BackendTypes {
1919
fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value;
2020
fn get_static(&self, def_id: DefId) -> Self::Value;
2121
fn codegen_static(&self, def_id: DefId, is_mutable: bool);
22-
unsafe fn static_replace_all_uses(&self, old_g: Self::Value, new_g: Self::Value);
2322
}

0 commit comments

Comments
 (0)
Please sign in to comment.