Skip to content

Commit 88202c5

Browse files
Replace bcx.ccx() with bcx.ccx
1 parent f103ea4 commit 88202c5

File tree

17 files changed

+238
-239
lines changed

17 files changed

+238
-239
lines changed

src/librustc_trans/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl ArgType {
235235
if self.is_ignore() {
236236
return;
237237
}
238-
let ccx = bcx.ccx();
238+
let ccx = bcx.ccx;
239239
if self.is_indirect() {
240240
let llsz = llsize_of(ccx, self.ty);
241241
let llalign = llalign_of_min(ccx, self.ty);

src/librustc_trans/adt.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ pub fn trans_switch<'a, 'tcx>(
308308
scrutinee: ValueRef,
309309
range_assert: bool
310310
) -> (BranchKind, Option<ValueRef>) {
311-
let l = bcx.ccx().layout_of(t);
311+
let l = bcx.ccx.layout_of(t);
312312
match *l {
313313
layout::CEnum { .. } | layout::General { .. } |
314314
layout::RawNullablePointer { .. } | layout::StructWrappedNullablePointer { .. } => {
@@ -343,7 +343,7 @@ pub fn trans_get_discr<'a, 'tcx>(
343343
};
344344

345345
debug!("trans_get_discr t: {:?}", t);
346-
let l = bcx.ccx().layout_of(t);
346+
let l = bcx.ccx.layout_of(t);
347347

348348
let val = match *l {
349349
layout::CEnum { discr, min, max, .. } => {
@@ -354,11 +354,11 @@ pub fn trans_get_discr<'a, 'tcx>(
354354
load_discr(bcx, discr, ptr, 0, def.variants.len() as u64 - 1,
355355
range_assert)
356356
}
357-
layout::Univariant { .. } | layout::UntaggedUnion { .. } => C_u8(bcx.ccx(), 0),
357+
layout::Univariant { .. } | layout::UntaggedUnion { .. } => C_u8(bcx.ccx, 0),
358358
layout::RawNullablePointer { nndiscr, .. } => {
359359
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
360-
let llptrty = type_of::sizing_type_of(bcx.ccx(),
361-
monomorphize::field_ty(bcx.ccx().tcx(), substs,
360+
let llptrty = type_of::sizing_type_of(bcx.ccx,
361+
monomorphize::field_ty(bcx.ccx.tcx(), substs,
362362
&def.variants[nndiscr as usize].fields[0]));
363363
bcx.icmp(cmp, bcx.load(scrutinee), C_null(llptrty))
364364
}
@@ -390,7 +390,7 @@ fn struct_wrapped_nullable_bitdiscr(
390390
fn load_discr(bcx: &BlockAndBuilder, ity: layout::Integer, ptr: ValueRef, min: u64, max: u64,
391391
range_assert: bool)
392392
-> ValueRef {
393-
let llty = Type::from_integer(bcx.ccx(), ity);
393+
let llty = Type::from_integer(bcx.ccx, ity);
394394
assert_eq!(val_ty(ptr), llty.ptr_to());
395395
let bits = ity.size().bits();
396396
assert!(bits <= 64);
@@ -416,16 +416,16 @@ fn load_discr(bcx: &BlockAndBuilder, ity: layout::Integer, ptr: ValueRef, min: u
416416
///
417417
/// This should ideally be less tightly tied to `_match`.
418418
pub fn trans_case<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, t: Ty<'tcx>, value: Disr) -> ValueRef {
419-
let l = bcx.ccx().layout_of(t);
419+
let l = bcx.ccx.layout_of(t);
420420
match *l {
421421
layout::CEnum { discr, .. }
422422
| layout::General { discr, .. }=> {
423-
C_integral(Type::from_integer(bcx.ccx(), discr), value.0, true)
423+
C_integral(Type::from_integer(bcx.ccx, discr), value.0, true)
424424
}
425425
layout::RawNullablePointer { .. } |
426426
layout::StructWrappedNullablePointer { .. } => {
427427
assert!(value == Disr(0) || value == Disr(1));
428-
C_bool(bcx.ccx(), value != Disr(0))
428+
C_bool(bcx.ccx, value != Disr(0))
429429
}
430430
_ => {
431431
bug!("{} does not have a discriminant. Represented as {:#?}", t, l);
@@ -438,15 +438,15 @@ pub fn trans_case<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, t: Ty<'tcx>, value:
438438
pub fn trans_set_discr<'a, 'tcx>(
439439
bcx: &BlockAndBuilder<'a, 'tcx>, t: Ty<'tcx>, val: ValueRef, to: Disr
440440
) {
441-
let l = bcx.ccx().layout_of(t);
441+
let l = bcx.ccx.layout_of(t);
442442
match *l {
443443
layout::CEnum{ discr, min, max, .. } => {
444444
assert_discr_in_range(Disr(min), Disr(max), to);
445-
bcx.store(C_integral(Type::from_integer(bcx.ccx(), discr), to.0, true),
445+
bcx.store(C_integral(Type::from_integer(bcx.ccx, discr), to.0, true),
446446
val);
447447
}
448448
layout::General{ discr, .. } => {
449-
bcx.store(C_integral(Type::from_integer(bcx.ccx(), discr), to.0, true),
449+
bcx.store(C_integral(Type::from_integer(bcx.ccx, discr), to.0, true),
450450
bcx.struct_gep(val, 0));
451451
}
452452
layout::Univariant { .. }
@@ -455,9 +455,9 @@ pub fn trans_set_discr<'a, 'tcx>(
455455
assert_eq!(to, Disr(0));
456456
}
457457
layout::RawNullablePointer { nndiscr, .. } => {
458-
let nnty = compute_fields(bcx.ccx(), t, nndiscr as usize, false)[0];
458+
let nnty = compute_fields(bcx.ccx, t, nndiscr as usize, false)[0];
459459
if to.0 != nndiscr {
460-
let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
460+
let llptrty = type_of::sizing_type_of(bcx.ccx, nnty);
461461
bcx.store(C_null(llptrty), val);
462462
}
463463
}
@@ -467,10 +467,10 @@ pub fn trans_set_discr<'a, 'tcx>(
467467
// Issue #34427: As workaround for LLVM bug on
468468
// ARM, use memset of 0 on whole struct rather
469469
// than storing null to single target field.
470-
let llptr = bcx.pointercast(val, Type::i8(bcx.ccx()).ptr_to());
471-
let fill_byte = C_u8(bcx.ccx(), 0);
472-
let size = C_uint(bcx.ccx(), nonnull.stride().bytes());
473-
let align = C_i32(bcx.ccx(), nonnull.align.abi() as i32);
470+
let llptr = bcx.pointercast(val, Type::i8(bcx.ccx).ptr_to());
471+
let fill_byte = C_u8(bcx.ccx, 0);
472+
let size = C_uint(bcx.ccx, nonnull.stride().bytes());
473+
let align = C_i32(bcx.ccx, nonnull.align.abi() as i32);
474474
base::call_memset(bcx, llptr, fill_byte, size, align, false);
475475
} else {
476476
let path = discrfield.iter().map(|&i| i as usize).collect::<Vec<_>>();
@@ -504,7 +504,7 @@ pub fn trans_field_ptr<'a, 'tcx>(
504504
discr: Disr,
505505
ix: usize
506506
) -> ValueRef {
507-
let l = bcx.ccx().layout_of(t);
507+
let l = bcx.ccx.layout_of(t);
508508
debug!("trans_field_ptr on {} represented as {:#?}", t, l);
509509
// Note: if this ever needs to generate conditionals (e.g., if we
510510
// decide to do some kind of cdr-coding-like non-unique repr
@@ -513,7 +513,7 @@ pub fn trans_field_ptr<'a, 'tcx>(
513513
layout::Univariant { ref variant, .. } => {
514514
assert_eq!(discr, Disr(0));
515515
struct_field_ptr(bcx, &variant,
516-
&compute_fields(bcx.ccx(), t, 0, false),
516+
&compute_fields(bcx.ccx, t, 0, false),
517517
val, ix, false)
518518
}
519519
layout::Vector { count, .. } => {
@@ -522,37 +522,37 @@ pub fn trans_field_ptr<'a, 'tcx>(
522522
bcx.struct_gep(val.value, ix)
523523
}
524524
layout::General { discr: d, ref variants, .. } => {
525-
let mut fields = compute_fields(bcx.ccx(), t, discr.0 as usize, false);
526-
fields.insert(0, d.to_ty(&bcx.ccx().tcx(), false));
525+
let mut fields = compute_fields(bcx.ccx, t, discr.0 as usize, false);
526+
fields.insert(0, d.to_ty(&bcx.ccx.tcx(), false));
527527
struct_field_ptr(bcx, &variants[discr.0 as usize],
528528
&fields,
529529
val, ix + 1, true)
530530
}
531531
layout::UntaggedUnion { .. } => {
532-
let fields = compute_fields(bcx.ccx(), t, 0, false);
533-
let ty = type_of::in_memory_type_of(bcx.ccx(), fields[ix]);
532+
let fields = compute_fields(bcx.ccx, t, 0, false);
533+
let ty = type_of::in_memory_type_of(bcx.ccx, fields[ix]);
534534
bcx.pointercast(val.value, ty.ptr_to())
535535
}
536536
layout::RawNullablePointer { nndiscr, .. } |
537537
layout::StructWrappedNullablePointer { nndiscr, .. } if discr.0 != nndiscr => {
538-
let nullfields = compute_fields(bcx.ccx(), t, (1-nndiscr) as usize, false);
538+
let nullfields = compute_fields(bcx.ccx, t, (1-nndiscr) as usize, false);
539539
// The unit-like case might have a nonzero number of unit-like fields.
540540
// (e.d., Result of Either with (), as one side.)
541-
let ty = type_of::type_of(bcx.ccx(), nullfields[ix]);
542-
assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0);
541+
let ty = type_of::type_of(bcx.ccx, nullfields[ix]);
542+
assert_eq!(machine::llsize_of_alloc(bcx.ccx, ty), 0);
543543
bcx.pointercast(val.value, ty.ptr_to())
544544
}
545545
layout::RawNullablePointer { nndiscr, .. } => {
546-
let nnty = compute_fields(bcx.ccx(), t, nndiscr as usize, false)[0];
546+
let nnty = compute_fields(bcx.ccx, t, nndiscr as usize, false)[0];
547547
assert_eq!(ix, 0);
548548
assert_eq!(discr.0, nndiscr);
549-
let ty = type_of::type_of(bcx.ccx(), nnty);
549+
let ty = type_of::type_of(bcx.ccx, nnty);
550550
bcx.pointercast(val.value, ty.ptr_to())
551551
}
552552
layout::StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
553553
assert_eq!(discr.0, nndiscr);
554554
struct_field_ptr(bcx, &nonnull,
555-
&compute_fields(bcx.ccx(), t, discr.0 as usize, false),
555+
&compute_fields(bcx.ccx, t, discr.0 as usize, false),
556556
val, ix, false)
557557
}
558558
_ => bug!("element access in type without elements: {} represented as {:#?}", t, l)
@@ -568,7 +568,7 @@ fn struct_field_ptr<'a, 'tcx>(
568568
needs_cast: bool
569569
) -> ValueRef {
570570
let fty = fields[ix];
571-
let ccx = bcx.ccx();
571+
let ccx = bcx.ccx;
572572

573573
let ptr_val = if needs_cast {
574574
let fields = st.field_index_by_increasing_offset().map(|i| {
@@ -585,7 +585,7 @@ fn struct_field_ptr<'a, 'tcx>(
585585
// * Packed struct - There is no alignment padding
586586
// * Field is sized - pointer is properly aligned already
587587
if st.offsets[ix] == layout::Size::from_bytes(0) || st.packed ||
588-
bcx.ccx().shared().type_is_sized(fty) {
588+
bcx.ccx.shared().type_is_sized(fty) {
589589
return bcx.struct_gep(ptr_val, st.memory_index[ix] as usize);
590590
}
591591

@@ -624,7 +624,7 @@ fn struct_field_ptr<'a, 'tcx>(
624624

625625

626626
let offset = st.offsets[ix].bytes();
627-
let unaligned_offset = C_uint(bcx.ccx(), offset);
627+
let unaligned_offset = C_uint(bcx.ccx, offset);
628628

629629
// Get the alignment of the field
630630
let (_, align) = glue::size_and_align_of_dst(bcx, fty, meta);
@@ -635,18 +635,18 @@ fn struct_field_ptr<'a, 'tcx>(
635635
// (unaligned offset + (align - 1)) & -align
636636

637637
// Calculate offset
638-
let align_sub_1 = bcx.sub(align, C_uint(bcx.ccx(), 1u64));
638+
let align_sub_1 = bcx.sub(align, C_uint(bcx.ccx, 1u64));
639639
let offset = bcx.and(bcx.add(unaligned_offset, align_sub_1),
640640
bcx.neg(align));
641641

642642
debug!("struct_field_ptr: DST field offset: {:?}", Value(offset));
643643

644644
// Cast and adjust pointer
645-
let byte_ptr = bcx.pointercast(ptr_val, Type::i8p(bcx.ccx()));
645+
let byte_ptr = bcx.pointercast(ptr_val, Type::i8p(bcx.ccx));
646646
let byte_ptr = bcx.gep(byte_ptr, &[offset]);
647647

648648
// Finally, cast back to the type expected
649-
let ll_fty = type_of::in_memory_type_of(bcx.ccx(), fty);
649+
let ll_fty = type_of::in_memory_type_of(bcx.ccx, fty);
650650
debug!("struct_field_ptr: Field type is {:?}", ll_fty);
651651
bcx.pointercast(byte_ptr, ll_fty.ptr_to())
652652
}

src/librustc_trans/asm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn trans_inline_asm<'a, 'tcx>(
4848
if out.is_indirect {
4949
indirect_outputs.push(val.unwrap());
5050
} else {
51-
output_types.push(type_of::type_of(bcx.ccx(), ty));
51+
output_types.push(type_of::type_of(bcx.ccx, ty));
5252
}
5353
}
5454
if !indirect_outputs.is_empty() {
@@ -79,9 +79,9 @@ pub fn trans_inline_asm<'a, 'tcx>(
7979
// Depending on how many outputs we have, the return type is different
8080
let num_outputs = output_types.len();
8181
let output_type = match num_outputs {
82-
0 => Type::void(bcx.ccx()),
82+
0 => Type::void(bcx.ccx),
8383
1 => output_types[0],
84-
_ => Type::struct_(bcx.ccx(), &output_types[..], false)
84+
_ => Type::struct_(bcx.ccx, &output_types[..], false)
8585
};
8686

8787
let dialect = match ia.dialect {
@@ -112,12 +112,12 @@ pub fn trans_inline_asm<'a, 'tcx>(
112112
// back to source locations. See #17552.
113113
unsafe {
114114
let key = "srcloc";
115-
let kind = llvm::LLVMGetMDKindIDInContext(bcx.ccx().llcx(),
115+
let kind = llvm::LLVMGetMDKindIDInContext(bcx.ccx.llcx(),
116116
key.as_ptr() as *const c_char, key.len() as c_uint);
117117

118-
let val: llvm::ValueRef = C_i32(bcx.ccx(), ia.expn_id.into_u32() as i32);
118+
let val: llvm::ValueRef = C_i32(bcx.ccx, ia.expn_id.into_u32() as i32);
119119

120120
llvm::LLVMSetMetadata(r, kind,
121-
llvm::LLVMMDNodeInContext(bcx.ccx().llcx(), &val, 1));
121+
llvm::LLVMMDNodeInContext(bcx.ccx.llcx(), &val, 1));
122122
}
123123
}

src/librustc_trans/base.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ 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));
236-
let ptr_ty = type_of::in_memory_type_of(bcx.ccx(), b).ptr_to();
237-
(bcx.pointercast(src, ptr_ty), unsized_info(bcx.ccx(), a, b, None))
235+
assert!(bcx.ccx.shared().type_is_sized(a));
236+
let ptr_ty = type_of::in_memory_type_of(bcx.ccx, b).ptr_to();
237+
(bcx.pointercast(src, ptr_ty), unsized_info(bcx.ccx, a, b, None))
238238
}
239239
_ => bug!("unsize_thin_ptr: called on bad types"),
240240
}
@@ -252,13 +252,13 @@ pub fn coerce_unsized_into<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>,
252252
(&ty::TyRef(..), &ty::TyRef(..)) |
253253
(&ty::TyRef(..), &ty::TyRawPtr(..)) |
254254
(&ty::TyRawPtr(..), &ty::TyRawPtr(..)) => {
255-
let (base, info) = if common::type_is_fat_ptr(bcx.ccx(), src_ty) {
255+
let (base, info) = if common::type_is_fat_ptr(bcx.ccx, src_ty) {
256256
// fat-ptr to fat-ptr unsize preserves the vtable
257257
// i.e. &'a fmt::Debug+Send => &'a fmt::Debug
258258
// So we need to pointercast the base to ensure
259259
// the types match up.
260260
let (base, info) = load_fat_ptr(bcx, src, src_ty);
261-
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), dst_ty);
261+
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx, dst_ty);
262262
let base = bcx.pointercast(base, llcast_ty);
263263
(base, info)
264264
} else {
@@ -283,7 +283,7 @@ pub fn coerce_unsized_into<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>,
283283

284284
let iter = src_fields.zip(dst_fields).enumerate();
285285
for (i, (src_fty, dst_fty)) in iter {
286-
if type_is_zero_size(bcx.ccx(), dst_fty) {
286+
if type_is_zero_size(bcx.ccx, dst_fty) {
287287
continue;
288288
}
289289

@@ -460,16 +460,16 @@ pub fn load_fat_ptr<'a, 'tcx>(
460460
}
461461

462462
pub fn from_immediate(bcx: &BlockAndBuilder, val: ValueRef) -> ValueRef {
463-
if val_ty(val) == Type::i1(bcx.ccx()) {
464-
bcx.zext(val, Type::i8(bcx.ccx()))
463+
if val_ty(val) == Type::i1(bcx.ccx) {
464+
bcx.zext(val, Type::i8(bcx.ccx))
465465
} else {
466466
val
467467
}
468468
}
469469

470470
pub fn to_immediate(bcx: &BlockAndBuilder, val: ValueRef, ty: Ty) -> ValueRef {
471471
if ty.is_bool() {
472-
bcx.trunc(val, Type::i1(bcx.ccx()))
472+
bcx.trunc(val, Type::i1(bcx.ccx))
473473
} else {
474474
val
475475
}
@@ -526,7 +526,7 @@ pub fn call_memcpy<'a, 'tcx>(b: &Builder<'a, 'tcx>,
526526
pub fn memcpy_ty<'a, 'tcx>(
527527
bcx: &BlockAndBuilder<'a, 'tcx>, dst: ValueRef, src: ValueRef, t: Ty<'tcx>
528528
) {
529-
let ccx = bcx.ccx();
529+
let ccx = bcx.ccx;
530530

531531
if type_is_zero_size(ccx, t) {
532532
return;
@@ -537,7 +537,7 @@ pub fn memcpy_ty<'a, 'tcx>(
537537
let llsz = llsize_of(ccx, llty);
538538
let llalign = type_of::align_of(ccx, t);
539539
call_memcpy(bcx, dst, src, llsz, llalign as u32);
540-
} else if common::type_is_fat_ptr(bcx.ccx(), t) {
540+
} else if common::type_is_fat_ptr(bcx.ccx, t) {
541541
let (data, extra) = load_fat_ptr(bcx, src, t);
542542
store_fat_ptr(bcx, data, extra, dst, t);
543543
} else {
@@ -560,7 +560,7 @@ pub fn call_memset<'a, 'tcx>(b: &Builder<'a, 'tcx>,
560560

561561
pub fn alloc_ty<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, ty: Ty<'tcx>, name: &str) -> ValueRef {
562562
assert!(!ty.has_param_types());
563-
bcx.fcx().alloca(type_of::type_of(bcx.ccx(), ty), name)
563+
bcx.fcx().alloca(type_of::type_of(bcx.ccx, ty), name)
564564
}
565565

566566
pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance<'tcx>) {
@@ -638,7 +638,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
638638
let lldestptr = adt::trans_field_ptr(&bcx, sig.output(), dest_val, Disr::from(disr), i);
639639
let arg = &fcx.fn_ty.args[arg_idx];
640640
arg_idx += 1;
641-
if common::type_is_fat_ptr(bcx.ccx(), arg_ty) {
641+
if common::type_is_fat_ptr(bcx.ccx, arg_ty) {
642642
let meta = &fcx.fn_ty.args[arg_idx];
643643
arg_idx += 1;
644644
arg.store_fn_arg(&bcx, &mut llarg_idx, get_dataptr(&bcx, lldestptr));

src/librustc_trans/callee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
368368
// to drop `self` when the body returns, or in case it unwinds.
369369
let self_scope = fcx.schedule_drop_mem(llenv, closure_ty);
370370
let fn_ret = callee.ty.fn_ret();
371-
let fn_ty = callee.direct_fn_type(bcx.ccx(), &[]);
371+
let fn_ty = callee.direct_fn_type(bcx.ccx, &[]);
372372

373373
let first_llarg = if fn_ty.ret.is_indirect() && !fcx.fn_ty.ret.is_ignore() {
374374
Some(get_param(fcx.llfn, 0))
@@ -378,7 +378,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
378378
let llargs = first_llarg.into_iter().chain(llargs[self_idx..].iter().cloned())
379379
.collect::<Vec<_>>();
380380

381-
let llfn = callee.reify(bcx.ccx());
381+
let llfn = callee.reify(bcx.ccx);
382382
let llret;
383383
if let Some(landing_pad) = self_scope.landing_pad {
384384
let normal_bcx = bcx.fcx().build_new_block("normal-return");

src/librustc_trans/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub fn declare_local<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>,
431431
variable_access: VariableAccess,
432432
variable_kind: VariableKind,
433433
span: Span) {
434-
let cx: &CrateContext = bcx.ccx();
434+
let cx = bcx.ccx;
435435

436436
let file = span_start(cx, span).file;
437437
let filename = file.name.clone();

0 commit comments

Comments
 (0)