diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2016-05-06 15:21:17 -0400 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2016-05-09 16:17:00 -0400 |
| commit | a8e34dfc29df9ca817e9d1e91f3e49f6d405fe28 (patch) | |
| tree | 052a33beb4f86bf8c34ac04903655429e0d7405c | |
| parent | bebcb285ad187153a71296c42a02e4bb9c2297f5 (diff) | |
| download | rust-a8e34dfc29df9ca817e9d1e91f3e49f6d405fe28.tar.gz rust-a8e34dfc29df9ca817e9d1e91f3e49f6d405fe28.zip | |
trans: Make partitioning available in LocalCrateContext.
| -rw-r--r-- | src/librustc_trans/context.rs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 9f5fe28ee82..9692d31ee14 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -96,6 +96,7 @@ pub struct LocalCrateContext<'tcx> { llmod: ModuleRef, llcx: ContextRef, tn: TypeNames, // FIXME: This seems to be largely unused. + codegen_unit: CodegenUnit<'tcx>, needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty<'tcx>, bool>>, fn_pointer_shims: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>, drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, ValueRef>>, @@ -201,18 +202,8 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> { -> CrateContextList<'a, 'tcx> { CrateContextList { shared: shared_ccx, - // FIXME: We don't actually use the codegen unit partitioning yet. - local_ccxs: codegen_units.iter().map(|cgu| { - // 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[..]) + local_ccxs: codegen_units.into_iter().map(|codegen_unit| { + LocalCrateContext::new(shared_ccx, codegen_unit) }).collect() } } @@ -497,10 +488,21 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { impl<'tcx> LocalCrateContext<'tcx> { fn new<'a>(shared: &SharedCrateContext<'a, 'tcx>, - name: &str) + codegen_unit: CodegenUnit<'tcx>) -> LocalCrateContext<'tcx> { 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 { Some(debuginfo::CrateDebugContext::new(llmod)) @@ -511,6 +513,7 @@ impl<'tcx> LocalCrateContext<'tcx> { let local_ccx = LocalCrateContext { llmod: llmod, llcx: llcx, + codegen_unit: codegen_unit, tn: TypeNames::new(), needs_unwind_cleanup_cache: RefCell::new(FnvHashMap()), fn_pointer_shims: RefCell::new(FnvHashMap()), @@ -668,6 +671,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { self.local().llcx } + pub fn codegen_unit(&self) -> &CodegenUnit<'tcx> { + &self.local().codegen_unit + } + pub fn td(&self) -> llvm::TargetDataRef { unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) } } |
