Don't assume all first results are direct values.

We're about to change that.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-12 10:48:57 -07:00
parent 94e26a845a
commit d133606fe7

View File

@@ -207,13 +207,12 @@ impl DataFlowGraph {
/// Find the original definition of a value, looking through value aliases as well as /// Find the original definition of a value, looking through value aliases as well as
/// copy/spill/fill instructions. /// copy/spill/fill instructions.
pub fn resolve_copies(&self, value: Value) -> Value { pub fn resolve_copies(&self, value: Value) -> Value {
use ir::entities::ExpandedValue::Direct;
let mut v = value; let mut v = value;
for _ in 0..self.insts.len() { for _ in 0..self.insts.len() {
v = self.resolve_aliases(v); v = self.resolve_aliases(v);
v = match v.expand() { v = match self.value_def(v) {
Direct(inst) => { ValueDef::Res(inst, 0) => {
match self[inst] { match self[inst] {
InstructionData::Unary { opcode, arg, .. } => { InstructionData::Unary { opcode, arg, .. } => {
match opcode { match opcode {
@@ -1003,7 +1002,6 @@ mod tests {
#[test] #[test]
fn aliases() { fn aliases() {
use ir::InstBuilder; use ir::InstBuilder;
use ir::entities::ExpandedValue::Direct;
use ir::condcodes::IntCC; use ir::condcodes::IntCC;
let mut func = Function::new(); let mut func = Function::new();
@@ -1020,8 +1018,8 @@ mod tests {
let arg0 = dfg.append_ebb_arg(ebb0, types::I32); let arg0 = dfg.append_ebb_arg(ebb0, types::I32);
let (s, c) = dfg.ins(pos).iadd_cout(v1, arg0); let (s, c) = dfg.ins(pos).iadd_cout(v1, arg0);
let iadd = match s.expand() { let iadd = match dfg.value_def(s) {
Direct(i) => i, ValueDef::Res(i, 0) => i,
_ => panic!(), _ => panic!(),
}; };