trans: Make partitioning available in LocalCrateContext.
This commit is contained in:
parent
bebcb285ad
commit
a8e34dfc29
1 changed files with 21 additions and 14 deletions
|
@ -96,6 +96,7 @@ pub struct LocalCrateContext<'tcx> {
|
||||||
llmod: ModuleRef,
|
llmod: ModuleRef,
|
||||||
llcx: ContextRef,
|
llcx: ContextRef,
|
||||||
tn: TypeNames, // FIXME: This seems to be largely unused.
|
tn: TypeNames, // FIXME: This seems to be largely unused.
|
||||||
|
codegen_unit: CodegenUnit<'tcx>,
|
||||||
needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty<'tcx>, bool>>,
|
needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty<'tcx>, bool>>,
|
||||||
fn_pointer_shims: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
|
fn_pointer_shims: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
|
||||||
drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, ValueRef>>,
|
drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, ValueRef>>,
|
||||||
|
@ -201,18 +202,8 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> {
|
||||||
-> CrateContextList<'a, 'tcx> {
|
-> CrateContextList<'a, 'tcx> {
|
||||||
CrateContextList {
|
CrateContextList {
|
||||||
shared: shared_ccx,
|
shared: shared_ccx,
|
||||||
// FIXME: We don't actually use the codegen unit partitioning yet.
|
local_ccxs: codegen_units.into_iter().map(|codegen_unit| {
|
||||||
local_ccxs: codegen_units.iter().map(|cgu| {
|
LocalCrateContext::new(shared_ccx, codegen_unit)
|
||||||
// Append ".rs" to crate name as LLVM module identifier.
|
|
||||||
//
|
|
||||||
// LLVM code generator emits a ".file filename" directive
|
|
||||||
// for ELF backends. Value of the "filename" is set as the
|
|
||||||
// LLVM module identifier. Due to a LLVM MC bug[1], LLVM
|
|
||||||
// crashes if the module identifier is same as other symbols
|
|
||||||
// such as a function name in the module.
|
|
||||||
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
|
||||||
let llmod_id = format!("{}.rs", cgu.name);
|
|
||||||
LocalCrateContext::new(shared_ccx, &llmod_id[..])
|
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,10 +488,21 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
|
||||||
|
|
||||||
impl<'tcx> LocalCrateContext<'tcx> {
|
impl<'tcx> LocalCrateContext<'tcx> {
|
||||||
fn new<'a>(shared: &SharedCrateContext<'a, 'tcx>,
|
fn new<'a>(shared: &SharedCrateContext<'a, 'tcx>,
|
||||||
name: &str)
|
codegen_unit: CodegenUnit<'tcx>)
|
||||||
-> LocalCrateContext<'tcx> {
|
-> LocalCrateContext<'tcx> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let (llcx, llmod) = create_context_and_module(&shared.tcx.sess, name);
|
// Append ".rs" to LLVM module identifier.
|
||||||
|
//
|
||||||
|
// LLVM code generator emits a ".file filename" directive
|
||||||
|
// for ELF backends. Value of the "filename" is set as the
|
||||||
|
// LLVM module identifier. Due to a LLVM MC bug[1], LLVM
|
||||||
|
// crashes if the module identifier is same as other symbols
|
||||||
|
// such as a function name in the module.
|
||||||
|
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
||||||
|
let llmod_id = format!("{}.rs", codegen_unit.name);
|
||||||
|
|
||||||
|
let (llcx, llmod) = create_context_and_module(&shared.tcx.sess,
|
||||||
|
&llmod_id[..]);
|
||||||
|
|
||||||
let dbg_cx = if shared.tcx.sess.opts.debuginfo != NoDebugInfo {
|
let dbg_cx = if shared.tcx.sess.opts.debuginfo != NoDebugInfo {
|
||||||
Some(debuginfo::CrateDebugContext::new(llmod))
|
Some(debuginfo::CrateDebugContext::new(llmod))
|
||||||
|
@ -511,6 +513,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
|
||||||
let local_ccx = LocalCrateContext {
|
let local_ccx = LocalCrateContext {
|
||||||
llmod: llmod,
|
llmod: llmod,
|
||||||
llcx: llcx,
|
llcx: llcx,
|
||||||
|
codegen_unit: codegen_unit,
|
||||||
tn: TypeNames::new(),
|
tn: TypeNames::new(),
|
||||||
needs_unwind_cleanup_cache: RefCell::new(FnvHashMap()),
|
needs_unwind_cleanup_cache: RefCell::new(FnvHashMap()),
|
||||||
fn_pointer_shims: RefCell::new(FnvHashMap()),
|
fn_pointer_shims: RefCell::new(FnvHashMap()),
|
||||||
|
@ -668,6 +671,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
|
||||||
self.local().llcx
|
self.local().llcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn codegen_unit(&self) -> &CodegenUnit<'tcx> {
|
||||||
|
&self.local().codegen_unit
|
||||||
|
}
|
||||||
|
|
||||||
pub fn td(&self) -> llvm::TargetDataRef {
|
pub fn td(&self) -> llvm::TargetDataRef {
|
||||||
unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
|
unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue