Skip to content

Commit 6fac0a1

Browse files
Change *.fcx.ccx to *.ccx
1 parent 15c9e5e commit 6fac0a1

File tree

8 files changed

+34
-41
lines changed

8 files changed

+34
-41
lines changed

src/librustc_trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub fn load_ty<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> V
424424
pub fn store_ty<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>, v: ValueRef, dst: ValueRef, t: Ty<'tcx>) {
425425
debug!("store_ty: {:?} : {:?} <- {:?}", Value(dst), t, Value(v));
426426

427-
if common::type_is_fat_ptr(cx.ccx(), t) {
427+
if common::type_is_fat_ptr(cx.ccx, t) {
428428
let lladdr = cx.extract_value(v, abi::FAT_PTR_ADDR);
429429
let llextra = cx.extract_value(v, abi::FAT_PTR_EXTRA);
430430
store_fat_ptr(cx, lladdr, llextra, dst, t);
@@ -656,7 +656,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
656656

657657
if let Some(cast_ty) = fcx.fn_ty.ret.cast {
658658
let load = bcx.load(bcx.pointercast(dest, cast_ty.ptr_to()));
659-
let llalign = llalign_of_min(fcx.ccx, fcx.fn_ty.ret.ty);
659+
let llalign = llalign_of_min(ccx, fcx.fn_ty.ret.ty);
660660
unsafe {
661661
llvm::LLVMSetAlignment(load, llalign);
662662
}

src/librustc_trans/cleanup.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ impl<'tcx> CleanupScope<'tcx> {
175175
// The landing pad return type (the type being propagated). Not sure
176176
// what this represents but it's determined by the personality
177177
// function and this is what the EH proposal example uses.
178-
let llretty = Type::struct_(fcx.ccx,
179-
&[Type::i8p(fcx.ccx), Type::i32(fcx.ccx)],
180-
false);
178+
let llretty = Type::struct_(fcx.ccx, &[Type::i8p(fcx.ccx), Type::i32(fcx.ccx)], false);
181179

182180
// The only landing pad clause will be 'cleanup'
183181
let llretval = pad_bcx.landing_pad(llretty, llpersonality, 1, pad_bcx.fcx().llfn);

src/librustc_trans/common.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,17 +421,14 @@ impl<'a, 'tcx> BlockAndBuilder<'a, 'tcx> {
421421
r
422422
}
423423

424-
pub fn ccx(&self) -> &'a CrateContext<'a, 'tcx> {
425-
self.fcx.ccx
426-
}
427424
pub fn fcx(&self) -> &'a FunctionContext<'a, 'tcx> {
428425
self.fcx
429426
}
430427
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
431-
self.fcx.ccx.tcx()
428+
self.ccx.tcx()
432429
}
433430
pub fn sess(&self) -> &'a Session {
434-
self.fcx.ccx.sess()
431+
self.ccx.sess()
435432
}
436433

437434
pub fn llbb(&self) -> BasicBlockRef {

src/librustc_trans/glue.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>,
474474
}
475475
}
476476

477-
let value = if cx.ccx().shared().type_is_sized(t) {
477+
let value = if cx.ccx.shared().type_is_sized(t) {
478478
adt::MaybeSizedValue::sized(av)
479479
} else {
480480
// FIXME(#36457) -- we should pass unsized values as two arguments
@@ -493,7 +493,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>,
493493
}
494494
ty::TyArray(_, n) => {
495495
let base = get_dataptr(&cx, value.value);
496-
let len = C_uint(cx.ccx(), n);
496+
let len = C_uint(cx.ccx, n);
497497
let unit_ty = t.sequence_element_type(cx.tcx());
498498
cx = tvec::slice_for_each(&cx, base, unit_ty, len, |bb, vv| drop_ty(bb, vv, unit_ty));
499499
}
@@ -514,7 +514,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>,
514514
for (i, &Field(_, field_ty)) in fields.iter().enumerate() {
515515
let llfld_a = adt::trans_field_ptr(&cx, t, value, Disr::from(discr), i);
516516

517-
let val = if cx.ccx().shared().type_is_sized(field_ty) {
517+
let val = if cx.ccx.shared().type_is_sized(field_ty) {
518518
llfld_a
519519
} else {
520520
// FIXME(#36457) -- we should pass unsized values as two arguments
@@ -530,8 +530,6 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>,
530530
bug!("Union in `glue::drop_structural_ty`");
531531
}
532532
AdtKind::Enum => {
533-
let fcx = cx.fcx();
534-
let ccx = fcx.ccx;
535533
let n_variants = adt.variants.len();
536534

537535
// NB: we must hit the discriminant first so that structural
@@ -562,23 +560,23 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>,
562560
// from the outer function, and any other use case will only
563561
// call this for an already-valid enum in which case the `ret
564562
// void` will never be hit.
565-
let ret_void_cx = fcx.build_new_block("enum-iter-ret-void");
563+
let ret_void_cx = cx.fcx().build_new_block("enum-iter-ret-void");
566564
ret_void_cx.ret_void();
567565
let llswitch = cx.switch(lldiscrim_a, ret_void_cx.llbb(), n_variants);
568-
let next_cx = fcx.build_new_block("enum-iter-next");
566+
let next_cx = cx.fcx().build_new_block("enum-iter-next");
569567

570568
for variant in &adt.variants {
571569
let variant_cx_name = format!("enum-iter-variant-{}",
572570
&variant.disr_val.to_string());
573-
let variant_cx = fcx.build_new_block(&variant_cx_name);
571+
let variant_cx = cx.fcx().build_new_block(&variant_cx_name);
574572
let case_val = adt::trans_case(&cx, t, Disr::from(variant.disr_val));
575573
variant_cx.add_case(llswitch, case_val, variant_cx.llbb());
576574
iter_variant(&variant_cx, t, value, variant, substs);
577575
variant_cx.br(next_cx.llbb());
578576
}
579577
cx = next_cx;
580578
}
581-
_ => ccx.sess().unimpl("value from adt::trans_switch in drop_structural_ty"),
579+
_ => cx.ccx.sess().unimpl("value from adt::trans_switch in drop_structural_ty"),
582580
}
583581
}
584582
},

src/librustc_trans/mir/analyze.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ pub fn lvalue_locals<'a, 'tcx>(mircx: &MirContext<'a, 'tcx>) -> BitVector {
3333
ty.is_unique() ||
3434
ty.is_region_ptr() ||
3535
ty.is_simd() ||
36-
common::type_is_zero_size(mircx.fcx.ccx, ty)
36+
common::type_is_zero_size(mircx.ccx, ty)
3737
{
3838
// These sorts of types are immediates that we can store
3939
// in an ValueRef without an alloca.
40-
assert!(common::type_is_immediate(mircx.fcx.ccx, ty) ||
41-
common::type_is_fat_ptr(mircx.fcx.ccx, ty));
42-
} else if common::type_is_imm_pair(mircx.fcx.ccx, ty) {
40+
assert!(common::type_is_immediate(mircx.ccx, ty) ||
41+
common::type_is_fat_ptr(mircx.ccx, ty));
42+
} else if common::type_is_imm_pair(mircx.ccx, ty) {
4343
// We allow pairs and uses of any of their 2 fields.
4444
} else {
4545
// These sorts of types require an alloca. Note that
@@ -112,7 +112,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
112112
literal: mir::Literal::Item { def_id, .. }, ..
113113
}),
114114
ref args, ..
115-
} if Some(def_id) == self.cx.fcx.ccx.tcx().lang_items.box_free_fn() => {
115+
} if Some(def_id) == self.cx.ccx.tcx().lang_items.box_free_fn() => {
116116
// box_free(x) shares with `drop x` the property that it
117117
// is not guaranteed to be statically dominated by the
118118
// definition of x, so x must always be in an alloca.
@@ -135,10 +135,10 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
135135
// Allow uses of projections of immediate pair fields.
136136
if let mir::Lvalue::Projection(ref proj) = *lvalue {
137137
if let mir::Lvalue::Local(_) = proj.base {
138-
let ty = proj.base.ty(self.cx.mir, self.cx.fcx.ccx.tcx());
138+
let ty = proj.base.ty(self.cx.mir, self.cx.ccx.tcx());
139139

140-
let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx()));
141-
if common::type_is_imm_pair(self.cx.fcx.ccx, ty) {
140+
let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx()));
141+
if common::type_is_imm_pair(self.cx.ccx, ty) {
142142
if let mir::ProjectionElem::Field(..) = proj.elem {
143143
if let LvalueContext::Consume = context {
144144
return;
@@ -166,11 +166,11 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
166166
}
167167

168168
LvalueContext::Drop => {
169-
let ty = lvalue.ty(self.cx.mir, self.cx.fcx.ccx.tcx());
170-
let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx()));
169+
let ty = lvalue.ty(self.cx.mir, self.cx.ccx.tcx());
170+
let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx()));
171171

172172
// Only need the lvalue if we're actually dropping it.
173-
if self.cx.fcx.ccx.shared().type_needs_drop(ty) {
173+
if self.cx.ccx.shared().type_needs_drop(ty) {
174174
self.mark_as_lvalue(index);
175175
}
176176
}

src/librustc_trans/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
838838
return block;
839839
}
840840

841-
if base::wants_msvc_seh(self.fcx.ccx.sess()) {
841+
if base::wants_msvc_seh(self.ccx.sess()) {
842842
return self.blocks[target_bb];
843843
}
844844

src/librustc_trans/mir/lvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
140140
LvalueTy::Downcast { adt_def: _, substs: _, variant_index: v } => v,
141141
};
142142
let discr = discr as u64;
143-
let is_sized = self.fcx.ccx.shared().type_is_sized(projected_ty.to_ty(tcx));
143+
let is_sized = self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx));
144144
let base = if is_sized {
145145
adt::MaybeSizedValue::sized(tr_base.llval)
146146
} else {
@@ -272,7 +272,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
272272
}
273273

274274
pub fn monomorphized_lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> {
275-
let tcx = self.fcx.ccx.tcx();
275+
let tcx = self.ccx.tcx();
276276
let lvalue_ty = lvalue.ty(&self.mir, tcx);
277277
self.monomorphize(&lvalue_ty.to_ty(tcx))
278278
}

src/librustc_trans/mir/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ pub struct MirContext<'a, 'tcx:'a> {
4848

4949
debug_context: debuginfo::FunctionDebugContext,
5050

51-
/// Function context
5251
fcx: &'a common::FunctionContext<'a, 'tcx>,
5352

53+
ccx: &'a CrateContext<'a, 'tcx>,
54+
5455
/// When unwinding is initiated, we have to store this personality
5556
/// value somewhere so that we can load it and re-use it in the
5657
/// resume instruction. The personality is (afaik) some kind of
@@ -100,7 +101,7 @@ pub struct MirContext<'a, 'tcx:'a> {
100101
impl<'a, 'tcx> MirContext<'a, 'tcx> {
101102
pub fn monomorphize<T>(&self, value: &T) -> T
102103
where T: TransNormalize<'tcx> {
103-
monomorphize::apply_param_substs(self.fcx.ccx.shared(), self.param_substs, value)
104+
monomorphize::apply_param_substs(self.ccx.shared(), self.param_substs, value)
104105
}
105106

106107
pub fn set_debug_loc(&mut self, bcx: &BlockAndBuilder, source_info: mir::SourceInfo) {
@@ -123,12 +124,12 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
123124
// (unless the crate is being compiled with `-Z debug-macros`).
124125
if source_info.span.expn_id == NO_EXPANSION ||
125126
source_info.span.expn_id == COMMAND_LINE_EXPN ||
126-
self.fcx.ccx.sess().opts.debugging_opts.debug_macros {
127+
self.ccx.sess().opts.debugging_opts.debug_macros {
127128

128129
let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo);
129130
(scope, source_info.span)
130131
} else {
131-
let cm = self.fcx.ccx.sess().codemap();
132+
let cm = self.ccx.sess().codemap();
132133
// Walk up the macro expansion chain until we reach a non-expanded span.
133134
let mut span = source_info.span;
134135
while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN {
@@ -154,10 +155,8 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
154155
let scope_metadata = self.scopes[scope_id].scope_metadata;
155156
if pos < self.scopes[scope_id].file_start_pos ||
156157
pos >= self.scopes[scope_id].file_end_pos {
157-
let cm = self.fcx.ccx.sess().codemap();
158-
debuginfo::extend_scope_to_file(self.fcx.ccx,
159-
scope_metadata,
160-
&cm.lookup_char_pos(pos).file)
158+
let cm = self.ccx.sess().codemap();
159+
debuginfo::extend_scope_to_file(self.ccx, scope_metadata, &cm.lookup_char_pos(pos).file)
161160
} else {
162161
scope_metadata
163162
}
@@ -225,6 +224,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
225224
let mut mircx = MirContext {
226225
mir: mir,
227226
fcx: fcx,
227+
ccx: fcx.ccx,
228228
llpersonalityslot: None,
229229
blocks: block_bcxs,
230230
unreachable_block: None,

0 commit comments

Comments
 (0)