Skip to content

Commit 92e4858

Browse files
committedMar 17, 2016
mir: Load FatPtr constants instead of keeping them indirect.
·
1.89.01.9.0
1 parent eb43d95 commit 92e4858

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
 

‎src/librustc_trans/trans/mir/constant.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use trans::abi;
1717
use trans::common::{self, BlockAndBuilder, C_bool, C_bytes, C_floating_f64, C_integral,
1818
C_str_slice, C_undef};
1919
use trans::consts;
20+
use trans::datum;
2021
use trans::expr;
2122
use trans::inline;
2223
use trans::type_of;
@@ -122,7 +123,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
122123
let d = bcx.with_block(|bcx| {
123124
expr::trans(bcx, expr)
124125
});
125-
OperandRef::from_rvalue_datum(d.datum.to_rvalue_datum(d.bcx, "").datum)
126+
127+
let datum = d.datum.to_rvalue_datum(d.bcx, "").datum;
128+
129+
match datum.kind.mode {
130+
datum::RvalueMode::ByValue => {
131+
OperandRef {
132+
ty: datum.ty,
133+
val: OperandValue::Immediate(datum.val)
134+
}
135+
}
136+
datum::RvalueMode::ByRef => self.trans_load(bcx, datum.val, datum.ty)
137+
}
126138
}
127139
mir::Literal::Value { ref value } => {
128140
self.trans_constval(bcx, value, ty)

‎src/librustc_trans/trans/mir/operand.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ impl<'tcx> OperandRef<'tcx> {
8181
_ => unreachable!()
8282
}
8383
}
84-
85-
pub fn from_rvalue_datum(datum: datum::Datum<'tcx, datum::Rvalue>) -> OperandRef {
86-
OperandRef {
87-
ty: datum.ty,
88-
val: match datum.kind.mode {
89-
datum::RvalueMode::ByRef => OperandValue::Ref(datum.val),
90-
datum::RvalueMode::ByValue => OperandValue::Immediate(datum.val),
91-
}
92-
}
93-
}
9484
}
9585

9686
impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {

0 commit comments

Comments
 (0)
Please sign in to comment.