about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2016-12-19 07:47:09 -0700
committerMark Simulacrum <mark.simulacrum@gmail.com>2016-12-20 20:03:35 -0700
commit5301d380b66066f71b3eabe1408f88cda348f084 (patch)
tree3da17d21acd075fc2595ff2e4ec1e02d5a74aef9
parent0256f60461cf607a7f84554926298c0fb74f381e (diff)
downloadrust-5301d380b66066f71b3eabe1408f88cda348f084.tar.gz
rust-5301d380b66066f71b3eabe1408f88cda348f084.zip
Remove unused bcx from LocalAnalyzer.
-rw-r--r--src/librustc_trans/mir/analyze.rs40
-rw-r--r--src/librustc_trans/mir/mod.rs2
-rw-r--r--src/librustc_trans/mir/rvalue.rs9
3 files changed, 22 insertions, 29 deletions
diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs
index 71375f1160c..3f94af82553 100644
--- a/src/librustc_trans/mir/analyze.rs
+++ b/src/librustc_trans/mir/analyze.rs
@@ -16,14 +16,13 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use rustc::mir::{self, Location, TerminatorKind};
 use rustc::mir::visit::{Visitor, LvalueContext};
 use rustc::mir::traversal;
-use common::{self, BlockAndBuilder};
+use common;
 use super::MirContext;
 use super::rvalue;
 
-pub fn lvalue_locals<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, mircx: &MirContext<'a, 'tcx>)
-    -> BitVector {
+pub fn lvalue_locals<'a, 'tcx>(mircx: &MirContext<'a, 'tcx>) -> BitVector {
     let mir = mircx.mir;
-    let mut analyzer = LocalAnalyzer::new(mircx, &bcx);
+    let mut analyzer = LocalAnalyzer::new(mircx);
 
     analyzer.visit_mir(mir);
 
@@ -34,13 +33,13 @@ pub fn lvalue_locals<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, mircx: &MirConte
             ty.is_unique() ||
             ty.is_region_ptr() ||
             ty.is_simd() ||
-            common::type_is_zero_size(bcx.ccx(), ty)
+            common::type_is_zero_size(mircx.fcx.ccx, ty)
         {
             // These sorts of types are immediates that we can store
             // in an ValueRef without an alloca.
-            assert!(common::type_is_immediate(bcx.ccx(), ty) ||
-                    common::type_is_fat_ptr(bcx.ccx(), ty));
-        } else if common::type_is_imm_pair(bcx.ccx(), ty) {
+            assert!(common::type_is_immediate(mircx.fcx.ccx, ty) ||
+                    common::type_is_fat_ptr(mircx.fcx.ccx, ty));
+        } else if common::type_is_imm_pair(mircx.fcx.ccx, ty) {
             // We allow pairs and uses of any of their 2 fields.
         } else {
             // These sorts of types require an alloca. Note that
@@ -57,18 +56,15 @@ pub fn lvalue_locals<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, mircx: &MirConte
 }
 
 struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> {
-    mir: &'mir MirContext<'a, 'tcx>,
-    bcx: &'mir BlockAndBuilder<'a, 'tcx>,
+    cx: &'mir MirContext<'a, 'tcx>,
     lvalue_locals: BitVector,
     seen_assigned: BitVector
 }
 
 impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> {
-    fn new(mircx: &'mir MirContext<'a, 'tcx>, bcx: &'mir BlockAndBuilder<'a, 'tcx>)
-           -> LocalAnalyzer<'mir, 'a, 'tcx> {
+    fn new(mircx: &'mir MirContext<'a, 'tcx>) -> LocalAnalyzer<'mir, 'a, 'tcx> {
         LocalAnalyzer {
-            mir: mircx,
-            bcx: bcx,
+            cx: mircx,
             lvalue_locals: BitVector::new(mircx.mir.local_decls.len()),
             seen_assigned: BitVector::new(mircx.mir.local_decls.len())
         }
@@ -96,7 +92,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
 
         if let mir::Lvalue::Local(index) = *lvalue {
             self.mark_assigned(index);
-            if !rvalue::rvalue_creates_operand(self.mir.mir, self.bcx, rvalue) {
+            if !rvalue::rvalue_creates_operand(rvalue) {
                 self.mark_as_lvalue(index);
             }
         } else {
@@ -116,7 +112,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
                     literal: mir::Literal::Item { def_id, .. }, ..
                 }),
                 ref args, ..
-            } if Some(def_id) == self.bcx.tcx().lang_items.box_free_fn() => {
+            } if Some(def_id) == self.cx.fcx.ccx.tcx().lang_items.box_free_fn() => {
                 // box_free(x) shares with `drop x` the property that it
                 // is not guaranteed to be statically dominated by the
                 // definition of x, so x must always be in an alloca.
@@ -139,10 +135,10 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
         // Allow uses of projections of immediate pair fields.
         if let mir::Lvalue::Projection(ref proj) = *lvalue {
             if let mir::Lvalue::Local(_) = proj.base {
-                let ty = proj.base.ty(self.mir.mir, self.bcx.tcx());
+                let ty = proj.base.ty(self.cx.mir, self.cx.fcx.ccx.tcx());
 
-                let ty = self.mir.monomorphize(&ty.to_ty(self.bcx.tcx()));
-                if common::type_is_imm_pair(self.bcx.ccx(), ty) {
+                let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx()));
+                if common::type_is_imm_pair(self.cx.fcx.ccx, ty) {
                     if let mir::ProjectionElem::Field(..) = proj.elem {
                         if let LvalueContext::Consume = context {
                             return;
@@ -170,11 +166,11 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
                 }
 
                 LvalueContext::Drop => {
-                    let ty = lvalue.ty(self.mir.mir, self.bcx.tcx());
-                    let ty = self.mir.monomorphize(&ty.to_ty(self.bcx.tcx()));
+                    let ty = lvalue.ty(self.cx.mir, self.cx.fcx.ccx.tcx());
+                    let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx()));
 
                     // Only need the lvalue if we're actually dropping it.
-                    if self.bcx.ccx().shared().type_needs_drop(ty) {
+                    if self.cx.fcx.ccx.shared().type_needs_drop(ty) {
                         self.mark_as_lvalue(index);
                     }
                 }
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index 4a908e8cea9..846b4162e06 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -235,7 +235,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
         },
     };
 
-    let lvalue_locals = analyze::lvalue_locals(&bcx, &mircx);
+    let lvalue_locals = analyze::lvalue_locals(&mircx);
 
     // Allocate variable and temp allocas
     mircx.locals = {
diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs
index 5037bd9dae3..5f17db73d66 100644
--- a/src/librustc_trans/mir/rvalue.rs
+++ b/src/librustc_trans/mir/rvalue.rs
@@ -166,7 +166,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
             }
 
             _ => {
-                assert!(rvalue_creates_operand(&self.mir, &bcx, rvalue));
+                assert!(rvalue_creates_operand(rvalue));
                 let (bcx, temp) = self.trans_rvalue_operand(bcx, rvalue);
                 self.store_operand(&bcx, dest.llval, temp);
                 bcx
@@ -179,8 +179,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
                                 rvalue: &mir::Rvalue<'tcx>)
                                 -> (BlockAndBuilder<'a, 'tcx>, OperandRef<'tcx>)
     {
-        assert!(rvalue_creates_operand(&self.mir, &bcx, rvalue),
-                "cannot trans {:?} to operand", rvalue);
+        assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
 
         match *rvalue {
             mir::Rvalue::Cast(ref kind, ref source, cast_ty) => {
@@ -662,9 +661,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
     }
 }
 
-pub fn rvalue_creates_operand<'a, 'tcx>(_mir: &mir::Mir<'tcx>,
-                                        _bcx: &BlockAndBuilder<'a, 'tcx>,
-                                        rvalue: &mir::Rvalue<'tcx>) -> bool {
+pub fn rvalue_creates_operand(rvalue: &mir::Rvalue) -> bool {
     match *rvalue {
         mir::Rvalue::Ref(..) |
         mir::Rvalue::Len(..) |