Skip to content

Commit f059f26

Browse files
committed
---
yaml --- r: 277419 b: refs/heads/try c: c55d9e5 h: refs/heads/master i: 277417: fd6b8c4 277415: 4d6086f
1 parent e603a06 commit f059f26

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 89edd96be86fd65d63f63a208062c8baf86e7d7c
4+
refs/heads/try: c55d9e591b1f66d4677dac2efda6b70afcd4b345
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/mir/mod.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::mir::repr as mir;
1616
use rustc::mir::tcx::LvalueTy;
1717
use session::config::FullDebugInfo;
1818
use base;
19-
use common::{self, Block, BlockAndBuilder, FunctionContext};
19+
use common::{self, Block, BlockAndBuilder, CrateContext, FunctionContext};
2020
use debuginfo::{self, declare_local, DebugLoc, VariableAccess, VariableKind};
2121
use machine;
2222
use type_of;
@@ -109,12 +109,21 @@ enum TempRef<'tcx> {
109109
}
110110

111111
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+
}
118127
}
119128
}
120129

@@ -160,17 +169,11 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
160169
TempRef::Lvalue(LvalueRef::alloca(&bcx,
161170
mty,
162171
&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)
169172
} else {
170173
// If this is an immediate temp, we do not create an
171174
// alloca in advance. Instead we wait until we see the
172175
// definition and update the operand there.
173-
TempRef::Operand(None)
176+
TempRef::new_operand(bcx.ccx(), mty)
174177
})
175178
.collect();
176179

0 commit comments

Comments
 (0)