@@ -96,6 +96,7 @@ pub struct LocalCrateContext<'tcx> {
96
96
llmod : ModuleRef ,
97
97
llcx : ContextRef ,
98
98
tn : TypeNames , // FIXME: This seems to be largely unused.
99
+ codegen_unit : CodegenUnit < ' tcx > ,
99
100
needs_unwind_cleanup_cache : RefCell < FnvHashMap < Ty < ' tcx > , bool > > ,
100
101
fn_pointer_shims : RefCell < FnvHashMap < Ty < ' tcx > , ValueRef > > ,
101
102
drop_glues : RefCell < FnvHashMap < DropGlueKind < ' tcx > , ValueRef > > ,
@@ -201,18 +202,8 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> {
201
202
-> CrateContextList < ' a , ' tcx > {
202
203
CrateContextList {
203
204
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)
216
207
} ) . collect ( )
217
208
}
218
209
}
@@ -497,10 +488,21 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
497
488
498
489
impl < ' tcx > LocalCrateContext < ' tcx > {
499
490
fn new < ' a > ( shared : & SharedCrateContext < ' a , ' tcx > ,
500
- name : & str )
491
+ codegen_unit : CodegenUnit < ' tcx > )
501
492
-> LocalCrateContext < ' tcx > {
502
493
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[ ..] ) ;
504
506
505
507
let dbg_cx = if shared. tcx . sess . opts . debuginfo != NoDebugInfo {
506
508
Some ( debuginfo:: CrateDebugContext :: new ( llmod) )
@@ -511,6 +513,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
511
513
let local_ccx = LocalCrateContext {
512
514
llmod : llmod,
513
515
llcx : llcx,
516
+ codegen_unit : codegen_unit,
514
517
tn : TypeNames :: new ( ) ,
515
518
needs_unwind_cleanup_cache : RefCell :: new ( FnvHashMap ( ) ) ,
516
519
fn_pointer_shims : RefCell :: new ( FnvHashMap ( ) ) ,
@@ -668,6 +671,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
668
671
self . local ( ) . llcx
669
672
}
670
673
674
+ pub fn codegen_unit ( & self ) -> & CodegenUnit < ' tcx > {
675
+ & self . local ( ) . codegen_unit
676
+ }
677
+
671
678
pub fn td ( & self ) -> llvm:: TargetDataRef {
672
679
unsafe { llvm:: LLVMRustGetModuleDataLayout ( self . llmod ( ) ) }
673
680
}
0 commit comments