Skip to content

Commit d0d1320

Browse files
committed
rustc_trans: collapse {Local,Shared}CrateContext.
1 parent b762c2d commit d0d1320

File tree

12 files changed

+113
-243
lines changed

12 files changed

+113
-243
lines changed

src/librustc_trans/base.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ use builder::Builder;
5757
use callee;
5858
use common::{C_bool, C_bytes_in_context, C_i32, C_usize};
5959
use rustc_mir::monomorphize::collector::{self, MonoItemCollectionMode};
60-
use common::{self, C_struct_in_context, C_array, CrateContext, val_ty};
60+
use common::{self, C_struct_in_context, C_array, val_ty};
6161
use consts;
62-
use context::{self, LocalCrateContext, SharedCrateContext};
62+
use context::{self, CrateContext};
6363
use debuginfo;
6464
use declare;
6565
use meth;
@@ -232,13 +232,13 @@ pub fn unsize_thin_ptr<'a, 'tcx>(
232232
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) |
233233
(&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }),
234234
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => {
235-
assert!(bcx.ccx.shared().type_is_sized(a));
235+
assert!(bcx.ccx.type_is_sized(a));
236236
let ptr_ty = bcx.ccx.layout_of(b).llvm_type(bcx.ccx).ptr_to();
237237
(bcx.pointercast(src, ptr_ty), unsized_info(bcx.ccx, a, b, None))
238238
}
239239
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
240240
let (a, b) = (src_ty.boxed_ty(), dst_ty.boxed_ty());
241-
assert!(bcx.ccx.shared().type_is_sized(a));
241+
assert!(bcx.ccx.type_is_sized(a));
242242
let ptr_ty = bcx.ccx.layout_of(b).llvm_type(bcx.ccx).ptr_to();
243243
(bcx.pointercast(src, ptr_ty), unsized_info(bcx.ccx, a, b, None))
244244
}
@@ -721,7 +721,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
721721
let link_meta = link::build_link_meta(crate_hash);
722722
let exported_symbol_node_ids = find_exported_symbols(tcx);
723723

724-
let shared_ccx = SharedCrateContext::new(tcx);
725724
// Translate the metadata.
726725
let llmod_id = "metadata";
727726
let (metadata_llcx, metadata_llmod, metadata) =
@@ -770,7 +769,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
770769
// Run the translation item collector and partition the collected items into
771770
// codegen units.
772771
let codegen_units =
773-
shared_ccx.tcx().collect_and_partition_translation_items(LOCAL_CRATE).1;
772+
tcx.collect_and_partition_translation_items(LOCAL_CRATE).1;
774773
let codegen_units = (*codegen_units).clone();
775774

776775
// Force all codegen_unit queries so they are already either red or green
@@ -910,7 +909,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
910909

911910
symbol_names_test::report_symbol_names(tcx);
912911

913-
if shared_ccx.sess().trans_stats() {
912+
if tcx.sess.trans_stats() {
914913
println!("--- trans stats ---");
915914
println!("n_glues_created: {}", all_stats.n_glues_created);
916915
println!("n_null_glues: {}", all_stats.n_null_glues);
@@ -926,7 +925,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
926925
}
927926
}
928927

929-
if shared_ccx.sess().count_llvm_insns() {
928+
if tcx.sess.count_llvm_insns() {
930929
for (k, v) in all_stats.llvm_insns.iter() {
931930
println!("{:7} {}", *v, *k);
932931
}
@@ -1204,10 +1203,8 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12041203
.to_fingerprint().to_hex());
12051204

12061205
// Instantiate translation items without filling out definitions yet...
1207-
let scx = SharedCrateContext::new(tcx);
1208-
let lcx = LocalCrateContext::new(&scx, cgu, &llmod_id);
1206+
let ccx = CrateContext::new(tcx, cgu, &llmod_id);
12091207
let module = {
1210-
let ccx = CrateContext::new(&scx, &lcx);
12111208
let trans_items = ccx.codegen_unit()
12121209
.items_in_deterministic_order(ccx.tcx());
12131210
for &(trans_item, (linkage, visibility)) in &trans_items {
@@ -1268,7 +1265,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12681265
}
12691266
};
12701267

1271-
(lcx.into_stats(), module)
1268+
(ccx.into_stats(), module)
12721269
}
12731270
}
12741271

src/librustc_trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use syntax::abi::Abi;
3838
use syntax::symbol::InternedString;
3939
use syntax_pos::{Span, DUMMY_SP};
4040

41-
pub use context::{CrateContext, SharedCrateContext};
41+
pub use context::CrateContext;
4242

4343
pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
4444
ty.needs_drop(tcx, ty::ParamEnv::empty(traits::Reveal::All))

src/librustc_trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
299299
// As an optimization, all shared statics which do not have interior
300300
// mutability are placed into read-only memory.
301301
if m != hir::MutMutable {
302-
if ccx.shared().type_is_freeze(ty) {
302+
if ccx.type_is_freeze(ty) {
303303
llvm::LLVMSetGlobalConstant(g, llvm::True);
304304
}
305305
}

0 commit comments

Comments
 (0)