Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rustc_codegen_ssa #56198

Merged
merged 17 commits into from
Dec 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove static_replace_all_uses and statics_to_rauw from cg_ssa
  • Loading branch information
bjorn3 committed Nov 29, 2018
commit 2d46ee26fbfc594fe819c49bcfa0ac434cb442d0
4 changes: 3 additions & 1 deletion src/librustc_codegen_llvm/base.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

5 changes: 0 additions & 5 deletions src/librustc_codegen_llvm/consts.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/context.rs
Original file line number Diff line number Diff line change
@@ -314,6 +314,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
local_gen_sym_counter: Cell::new(0),
}
}

crate fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
&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<Vec<(&'ll Value, &'ll Value)>> {
&self.statics_to_rauw
}

fn used_statics(&self) -> &RefCell<Vec<&'ll Value>> {
&self.used_statics
}
1 change: 0 additions & 1 deletion src/librustc_codegen_ssa/traits/misc.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ pub trait MiscMethods<'tcx>: Backend<'tcx> {
fn stats(&self) -> &RefCell<Stats>;
fn consume_stats(self) -> RefCell<Stats>;
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
fn statics_to_rauw(&self) -> &RefCell<Vec<(Self::Value, Self::Value)>>;
fn closure_env_needs_indirect_debuginfo(&self) -> bool;
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
1 change: 0 additions & 1 deletion src/librustc_codegen_ssa/traits/statics.rs
Original file line number Diff line number Diff line change
@@ -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);
}