Skip to content

Commit b46c0fc

Browse files
committed
address nits from dotdash
1 parent 9c9f4be commit b46c0fc

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/librustc_trans/trans/mir/analyze.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
3030
if
3131
ty.is_scalar() ||
3232
ty.is_unique() ||
33-
ty.is_region_ptr() ||
33+
(ty.is_region_ptr() && !common::type_is_fat_ptr(bcx.tcx(), ty)) ||
3434
ty.is_simd()
3535
{
3636
// These sorts of types are immediates that we can store
@@ -42,7 +42,7 @@ pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
4242
// for newtypes, but we currently force some types
4343
// (e.g. structs) into an alloca unconditionally, just so
4444
// that we don't have to deal with having two pathways
45-
// (gep vs getvalue etc).
45+
// (gep vs extractvalue etc).
4646
analyzer.mark_as_lvalue(index);
4747
}
4848
}

src/librustc_trans/trans/mir/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ pub struct MirContext<'bcx, 'tcx:'bcx> {
5555
/// - nor should it appear in an lvalue path like `tmp.a`
5656
/// - the operand must be defined by an rvalue that can generate immediate
5757
/// values
58+
///
59+
/// Avoiding allocs can also be important for certain intrinsics,
60+
/// notably `expect`.
5861
temps: Vec<TempRef<'tcx>>,
5962

6063
/// The arguments to the function; as args are lvalues, these are

src/librustc_trans/trans/mir/rvalue.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use trans::build;
2020
use trans::common::{self, Block, Result};
2121
use trans::debuginfo::DebugLoc;
2222
use trans::declare;
23+
use trans::expr;
2324
use trans::machine;
2425
use trans::type_::Type;
2526
use trans::type_of;
@@ -55,6 +56,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
5556

5657
mir::Rvalue::Aggregate(_, ref operands) => {
5758
for (i, operand) in operands.iter().enumerate() {
59+
// Note: perhaps this should be StructGep, but
60+
// note that in some cases the values here will
61+
// not be structs but arrays.
5862
let lldest_i = build::GEPi(bcx, lldest, &[0, i]);
5963
self.trans_operand_into(bcx, lldest_i, operand);
6064
}
@@ -70,8 +74,10 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
7074
let llbase1 = build::GEPi(bcx, llbase, &[from_start]);
7175
let adj = common::C_uint(ccx, from_start + from_end);
7276
let lllen1 = build::Sub(bcx, lllen, adj, DebugLoc::None);
73-
build::Store(bcx, llbase1, build::GEPi(bcx, lldest, &[0, abi::FAT_PTR_ADDR]));
74-
build::Store(bcx, lllen1, build::GEPi(bcx, lldest, &[0, abi::FAT_PTR_EXTRA]));
77+
let lladdrdest = expr::get_dataptr(bcx, lldest);
78+
build::Store(bcx, llbase1, lladdrdest);
79+
let llmetadest = expr::get_meta(bcx, lldest);
80+
build::Store(bcx, lllen1, llmetadest);
7581
bcx
7682
}
7783

0 commit comments

Comments
 (0)