@@ -38,7 +38,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
38
38
use middle:: lang_items:: StartFnLangItem ;
39
39
use rustc:: ty:: subst:: Substs ;
40
40
use rustc:: traits;
41
- use rustc:: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
41
+ use rustc:: ty:: { self , Ty , TyCtxt } ;
42
42
use rustc:: ty:: adjustment:: CustomCoerceUnsized ;
43
43
use rustc:: dep_graph:: { DepNode , WorkProduct } ;
44
44
use rustc:: hir:: map as hir_map;
@@ -51,7 +51,7 @@ use adt;
51
51
use attributes;
52
52
use builder:: Builder ;
53
53
use callee:: { Callee } ;
54
- use common:: { BlockAndBuilder , C_bool , C_bytes_in_context , C_i32 , C_uint } ;
54
+ use common:: { C_bool , C_bytes_in_context , C_i32 , C_uint } ;
55
55
use collector:: { self , TransItemCollectionMode } ;
56
56
use common:: { C_struct_in_context , C_u64 , C_undef } ;
57
57
use common:: { CrateContext , FunctionContext } ;
@@ -161,7 +161,7 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOp_) -> llvm::RealPredicate {
161
161
}
162
162
163
163
pub fn compare_simd_types < ' a , ' tcx > (
164
- bcx : & BlockAndBuilder < ' a , ' tcx > ,
164
+ bcx : & Builder < ' a , ' tcx > ,
165
165
lhs : ValueRef ,
166
166
rhs : ValueRef ,
167
167
t : Ty < ' tcx > ,
@@ -218,7 +218,7 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
218
218
219
219
/// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer.
220
220
pub fn unsize_thin_ptr < ' a , ' tcx > (
221
- bcx : & BlockAndBuilder < ' a , ' tcx > ,
221
+ bcx : & Builder < ' a , ' tcx > ,
222
222
src : ValueRef ,
223
223
src_ty : Ty < ' tcx > ,
224
224
dst_ty : Ty < ' tcx >
@@ -242,7 +242,7 @@ pub fn unsize_thin_ptr<'a, 'tcx>(
242
242
243
243
/// Coerce `src`, which is a reference to a value of type `src_ty`,
244
244
/// to a value of type `dst_ty` and store the result in `dst`
245
- pub fn coerce_unsized_into < ' a , ' tcx > ( bcx : & BlockAndBuilder < ' a , ' tcx > ,
245
+ pub fn coerce_unsized_into < ' a , ' tcx > ( bcx : & Builder < ' a , ' tcx > ,
246
246
src : ValueRef ,
247
247
src_ty : Ty < ' tcx > ,
248
248
dst : ValueRef ,
@@ -272,10 +272,10 @@ pub fn coerce_unsized_into<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>,
272
272
assert_eq ! ( def_a, def_b) ;
273
273
274
274
let src_fields = def_a. variants [ 0 ] . fields . iter ( ) . map ( |f| {
275
- monomorphize:: field_ty ( bcx. tcx ( ) , substs_a, f)
275
+ monomorphize:: field_ty ( bcx. ccx . tcx ( ) , substs_a, f)
276
276
} ) ;
277
277
let dst_fields = def_b. variants [ 0 ] . fields . iter ( ) . map ( |f| {
278
- monomorphize:: field_ty ( bcx. tcx ( ) , substs_b, f)
278
+ monomorphize:: field_ty ( bcx. ccx . tcx ( ) , substs_b, f)
279
279
} ) ;
280
280
281
281
let src = adt:: MaybeSizedValue :: sized ( src) ;
@@ -322,7 +322,7 @@ pub fn custom_coerce_unsize_info<'scx, 'tcx>(scx: &SharedCrateContext<'scx, 'tcx
322
322
}
323
323
324
324
pub fn cast_shift_expr_rhs (
325
- cx : & BlockAndBuilder , op : hir:: BinOp_ , lhs : ValueRef , rhs : ValueRef
325
+ cx : & Builder , op : hir:: BinOp_ , lhs : ValueRef , rhs : ValueRef
326
326
) -> ValueRef {
327
327
cast_shift_rhs ( op, lhs, rhs, |a, b| cx. trunc ( a, b) , |a, b| cx. zext ( a, b) )
328
328
}
@@ -421,7 +421,7 @@ pub fn load_ty<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> V
421
421
422
422
/// Helper for storing values in memory. Does the necessary conversion if the in-memory type
423
423
/// differs from the type used for SSA values.
424
- pub fn store_ty < ' a , ' tcx > ( cx : & BlockAndBuilder < ' a , ' tcx > , v : ValueRef , dst : ValueRef , t : Ty < ' tcx > ) {
424
+ pub fn store_ty < ' a , ' tcx > ( cx : & Builder < ' a , ' tcx > , v : ValueRef , dst : ValueRef , t : Ty < ' tcx > ) {
425
425
debug ! ( "store_ty: {:?} : {:?} <- {:?}" , Value ( dst) , t, Value ( v) ) ;
426
426
427
427
if common:: type_is_fat_ptr ( cx. ccx , t) {
@@ -433,7 +433,7 @@ pub fn store_ty<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>, v: ValueRef, dst: Valu
433
433
}
434
434
}
435
435
436
- pub fn store_fat_ptr < ' a , ' tcx > ( cx : & BlockAndBuilder < ' a , ' tcx > ,
436
+ pub fn store_fat_ptr < ' a , ' tcx > ( cx : & Builder < ' a , ' tcx > ,
437
437
data : ValueRef ,
438
438
extra : ValueRef ,
439
439
dst : ValueRef ,
@@ -459,15 +459,15 @@ pub fn load_fat_ptr<'a, 'tcx>(
459
459
( ptr, meta)
460
460
}
461
461
462
- pub fn from_immediate ( bcx : & BlockAndBuilder , val : ValueRef ) -> ValueRef {
462
+ pub fn from_immediate ( bcx : & Builder , val : ValueRef ) -> ValueRef {
463
463
if val_ty ( val) == Type :: i1 ( bcx. ccx ) {
464
464
bcx. zext ( val, Type :: i8 ( bcx. ccx ) )
465
465
} else {
466
466
val
467
467
}
468
468
}
469
469
470
- pub fn to_immediate ( bcx : & BlockAndBuilder , val : ValueRef , ty : Ty ) -> ValueRef {
470
+ pub fn to_immediate ( bcx : & Builder , val : ValueRef , ty : Ty ) -> ValueRef {
471
471
if ty. is_bool ( ) {
472
472
bcx. trunc ( val, Type :: i1 ( bcx. ccx ) )
473
473
} else {
@@ -523,11 +523,13 @@ pub fn call_memcpy<'a, 'tcx>(b: &Builder<'a, 'tcx>,
523
523
b. call ( memcpy, & [ dst_ptr, src_ptr, size, align, volatile] , None ) ;
524
524
}
525
525
526
- pub fn memcpy_ty < ' a , ' tcx > ( bcx : & BlockAndBuilder < ' a , ' tcx > ,
527
- dst : ValueRef ,
528
- src : ValueRef ,
529
- t : Ty < ' tcx > ,
530
- align : Option < u32 > ) {
526
+ pub fn memcpy_ty < ' a , ' tcx > (
527
+ bcx : & Builder < ' a , ' tcx > ,
528
+ dst : ValueRef ,
529
+ src : ValueRef ,
530
+ t : Ty < ' tcx > ,
531
+ align : Option < u32 > ,
532
+ ) {
531
533
let ccx = bcx. ccx ;
532
534
533
535
if type_is_zero_size ( ccx, t) {
@@ -553,11 +555,6 @@ pub fn call_memset<'a, 'tcx>(b: &Builder<'a, 'tcx>,
553
555
b. call ( llintrinsicfn, & [ ptr, fill_byte, size, align, volatile] , None )
554
556
}
555
557
556
- pub fn alloc_ty < ' a , ' tcx > ( bcx : & BlockAndBuilder < ' a , ' tcx > , ty : Ty < ' tcx > , name : & str ) -> ValueRef {
557
- assert ! ( !ty. has_param_types( ) ) ;
558
- bcx. fcx ( ) . alloca ( type_of:: type_of ( bcx. ccx , ty) , name)
559
- }
560
-
561
558
pub fn trans_instance < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > , instance : Instance < ' tcx > ) {
562
559
let _s = if ccx. sess ( ) . trans_stats ( ) {
563
560
let mut instance_name = String :: new ( ) ;
@@ -623,7 +620,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
623
620
// We create an alloca to hold a pointer of type `ret.original_ty`
624
621
// which will hold the pointer to the right alloca which has the
625
622
// final ret value
626
- fcx . alloca ( fn_ty. ret . memory_ty ( ccx) , "sret_slot" )
623
+ bcx . alloca ( fn_ty. ret . memory_ty ( ccx) , "sret_slot" )
627
624
} ;
628
625
let dest_val = adt:: MaybeSizedValue :: sized ( dest) ; // Can return unsized value
629
626
let mut llarg_idx = fn_ty. ret . is_indirect ( ) as usize ;
@@ -756,12 +753,7 @@ pub fn maybe_create_entry_wrapper(ccx: &CrateContext) {
756
753
// `main` should respect same config for frame pointer elimination as rest of code
757
754
attributes:: set_frame_pointer_elimination ( ccx, llfn) ;
758
755
759
- let llbb = unsafe {
760
- let name = CString :: new ( "top" ) . unwrap ( ) ;
761
- llvm:: LLVMAppendBasicBlockInContext ( ccx. llcx ( ) , llfn, name. as_ptr ( ) )
762
- } ;
763
- let bld = Builder :: with_ccx ( ccx) ;
764
- bld. position_at_end ( llbb) ;
756
+ let bld = Builder :: new_block ( ccx, llfn, "top" ) ;
765
757
766
758
debuginfo:: gdb:: insert_reference_to_gdb_debug_scripts_section_global ( ccx, & bld) ;
767
759
0 commit comments