@@ -16,7 +16,7 @@ use rustc::mir::repr as mir;
16
16
use rustc:: mir:: tcx:: LvalueTy ;
17
17
use session:: config:: FullDebugInfo ;
18
18
use base;
19
- use common:: { self , Block , BlockAndBuilder , FunctionContext } ;
19
+ use common:: { self , Block , BlockAndBuilder , CrateContext , FunctionContext } ;
20
20
use debuginfo:: { self , declare_local, DebugLoc , VariableAccess , VariableKind } ;
21
21
use machine;
22
22
use type_of;
@@ -109,12 +109,21 @@ enum TempRef<'tcx> {
109
109
}
110
110
111
111
impl < ' tcx > TempRef < ' tcx > {
112
- fn new_operand ( val : OperandValue , ty : ty:: Ty < ' tcx > ) -> TempRef < ' tcx > {
113
- let op = OperandRef {
114
- val : val,
115
- ty : ty
116
- } ;
117
- TempRef :: Operand ( Some ( op) )
112
+ fn new_operand < ' bcx > ( ccx : & CrateContext < ' bcx , ' tcx > ,
113
+ ty : ty:: Ty < ' tcx > ) -> TempRef < ' tcx > {
114
+ if common:: type_is_zero_size ( ccx, ty) {
115
+ // Zero-size temporaries aren't always initialized, which
116
+ // doesn't matter because they don't contain data, but
117
+ // we need something in the operand.
118
+ let val = OperandValue :: Immediate ( common:: C_nil ( ccx) ) ;
119
+ let op = OperandRef {
120
+ val : val,
121
+ ty : ty
122
+ } ;
123
+ TempRef :: Operand ( Some ( op) )
124
+ } else {
125
+ TempRef :: Operand ( None )
126
+ }
118
127
}
119
128
}
120
129
@@ -160,17 +169,11 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
160
169
TempRef :: Lvalue ( LvalueRef :: alloca ( & bcx,
161
170
mty,
162
171
& format ! ( "temp{:?}" , i) ) )
163
- } else if common:: type_is_zero_size ( bcx. ccx ( ) , mty) {
164
- // Zero-size temporaries aren't always initialized, which
165
- // doesn't matter because they don't contain data, but
166
- // we need something in the operand.
167
- let val = OperandValue :: Immediate ( common:: C_nil ( bcx. ccx ( ) ) ) ;
168
- TempRef :: new_operand ( val, mty)
169
172
} else {
170
173
// If this is an immediate temp, we do not create an
171
174
// alloca in advance. Instead we wait until we see the
172
175
// definition and update the operand there.
173
- TempRef :: Operand ( None )
176
+ TempRef :: new_operand ( bcx . ccx ( ) , mty )
174
177
} )
175
178
. collect ( ) ;
176
179
0 commit comments