]> git.lizzy.rs Git - rust.git/commitdiff
address nits from dotdash
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 3 Nov 2015 20:50:04 +0000 (15:50 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 3 Nov 2015 23:00:35 +0000 (18:00 -0500)
src/librustc_trans/trans/mir/analyze.rs
src/librustc_trans/trans/mir/mod.rs
src/librustc_trans/trans/mir/rvalue.rs

index acf6e53468ef552b666be874a319a8eefac16892..f5fa897bca63122c0b768a6b39819c408f12061e 100644 (file)
@@ -30,7 +30,7 @@ pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
         if
             ty.is_scalar() ||
             ty.is_unique() ||
-            ty.is_region_ptr() ||
+            (ty.is_region_ptr() && !common::type_is_fat_ptr(bcx.tcx(), ty)) ||
             ty.is_simd()
         {
             // These sorts of types are immediates that we can store
@@ -42,7 +42,7 @@ pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
             // for newtypes, but we currently force some types
             // (e.g. structs) into an alloca unconditionally, just so
             // that we don't have to deal with having two pathways
-            // (gep vs getvalue etc).
+            // (gep vs extractvalue etc).
             analyzer.mark_as_lvalue(index);
         }
     }
index fb652c6dc7e3e70a66743eeb2ced28792f7220a8..3b018cc132184b54ccac287a770c65a5e402d533 100644 (file)
@@ -55,6 +55,9 @@ pub struct MirContext<'bcx, 'tcx:'bcx> {
     ///     - nor should it appear in an lvalue path like `tmp.a`
     /// - the operand must be defined by an rvalue that can generate immediate
     ///   values
+    ///
+    /// Avoiding allocs can also be important for certain intrinsics,
+    /// notably `expect`.
     temps: Vec<TempRef<'tcx>>,
 
     /// The arguments to the function; as args are lvalues, these are
index dc73c60c9a077395361e50624a56711c7a239a02..94cc7857a14f0a94ddff73d91641f13a5cb16eb9 100644 (file)
@@ -20,6 +20,7 @@
 use trans::common::{self, Block, Result};
 use trans::debuginfo::DebugLoc;
 use trans::declare;
+use trans::expr;
 use trans::machine;
 use trans::type_::Type;
 use trans::type_of;
@@ -55,6 +56,9 @@ pub fn trans_rvalue(&mut self,
 
             mir::Rvalue::Aggregate(_, ref operands) => {
                 for (i, operand) in operands.iter().enumerate() {
+                    // Note: perhaps this should be StructGep, but
+                    // note that in some cases the values here will
+                    // not be structs but arrays.
                     let lldest_i = build::GEPi(bcx, lldest, &[0, i]);
                     self.trans_operand_into(bcx, lldest_i, operand);
                 }
@@ -70,8 +74,10 @@ pub fn trans_rvalue(&mut self,
                 let llbase1 = build::GEPi(bcx, llbase, &[from_start]);
                 let adj = common::C_uint(ccx, from_start + from_end);
                 let lllen1 = build::Sub(bcx, lllen, adj, DebugLoc::None);
-                build::Store(bcx, llbase1, build::GEPi(bcx, lldest, &[0, abi::FAT_PTR_ADDR]));
-                build::Store(bcx, lllen1, build::GEPi(bcx, lldest, &[0, abi::FAT_PTR_EXTRA]));
+                let lladdrdest = expr::get_dataptr(bcx, lldest);
+                build::Store(bcx, llbase1, lladdrdest);
+                let llmetadest = expr::get_meta(bcx, lldest);
+                build::Store(bcx, lllen1, llmetadest);
                 bcx
             }