Skip to content

Commit 19d2f08

Browse files
---
yaml --- r: 276452 b: refs/heads/master c: a8e34df h: refs/heads/master
1 parent ea34aec commit 19d2f08

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bebcb285ad187153a71296c42a02e4bb9c2297f5
2+
refs/heads/master: a8e34dfc29df9ca817e9d1e91f3e49f6d405fe28
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_trans/context.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub struct LocalCrateContext<'tcx> {
9696
llmod: ModuleRef,
9797
llcx: ContextRef,
9898
tn: TypeNames, // FIXME: This seems to be largely unused.
99+
codegen_unit: CodegenUnit<'tcx>,
99100
needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty<'tcx>, bool>>,
100101
fn_pointer_shims: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
101102
drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, ValueRef>>,
@@ -201,18 +202,8 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> {
201202
-> CrateContextList<'a, 'tcx> {
202203
CrateContextList {
203204
shared: shared_ccx,
204-
// FIXME: We don't actually use the codegen unit partitioning yet.
205-
local_ccxs: codegen_units.iter().map(|cgu| {
206-
// Append ".rs" to crate name as LLVM module identifier.
207-
//
208-
// LLVM code generator emits a ".file filename" directive
209-
// for ELF backends. Value of the "filename" is set as the
210-
// LLVM module identifier. Due to a LLVM MC bug[1], LLVM
211-
// crashes if the module identifier is same as other symbols
212-
// such as a function name in the module.
213-
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
214-
let llmod_id = format!("{}.rs", cgu.name);
215-
LocalCrateContext::new(shared_ccx, &llmod_id[..])
205+
local_ccxs: codegen_units.into_iter().map(|codegen_unit| {
206+
LocalCrateContext::new(shared_ccx, codegen_unit)
216207
}).collect()
217208
}
218209
}
@@ -497,10 +488,21 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
497488

498489
impl<'tcx> LocalCrateContext<'tcx> {
499490
fn new<'a>(shared: &SharedCrateContext<'a, 'tcx>,
500-
name: &str)
491+
codegen_unit: CodegenUnit<'tcx>)
501492
-> LocalCrateContext<'tcx> {
502493
unsafe {
503-
let (llcx, llmod) = create_context_and_module(&shared.tcx.sess, name);
494+
// Append ".rs" to LLVM module identifier.
495+
//
496+
// LLVM code generator emits a ".file filename" directive
497+
// for ELF backends. Value of the "filename" is set as the
498+
// LLVM module identifier. Due to a LLVM MC bug[1], LLVM
499+
// crashes if the module identifier is same as other symbols
500+
// such as a function name in the module.
501+
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
502+
let llmod_id = format!("{}.rs", codegen_unit.name);
503+
504+
let (llcx, llmod) = create_context_and_module(&shared.tcx.sess,
505+
&llmod_id[..]);
504506

505507
let dbg_cx = if shared.tcx.sess.opts.debuginfo != NoDebugInfo {
506508
Some(debuginfo::CrateDebugContext::new(llmod))
@@ -511,6 +513,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
511513
let local_ccx = LocalCrateContext {
512514
llmod: llmod,
513515
llcx: llcx,
516+
codegen_unit: codegen_unit,
514517
tn: TypeNames::new(),
515518
needs_unwind_cleanup_cache: RefCell::new(FnvHashMap()),
516519
fn_pointer_shims: RefCell::new(FnvHashMap()),
@@ -668,6 +671,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
668671
self.local().llcx
669672
}
670673

674+
pub fn codegen_unit(&self) -> &CodegenUnit<'tcx> {
675+
&self.local().codegen_unit
676+
}
677+
671678
pub fn td(&self) -> llvm::TargetDataRef {
672679
unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
673680
}

0 commit comments

Comments
 (0)