Fixed SEA IR bugs.
Bug 1: The type inference visitor did not clear type between visits,
so all instructions had types attached because of this.
Bug 2: The .dot file genration was missing phi ssa edges because
the GetSSAProducers map hasn't got the same semantics.
(Phi Nodes use a single register which has multiple definitions,
not multiple registers with a single definition each)
Bug 3: Added the SE IR id in the textual representation of nodes
in the .dot representation to ease debugging.
Change-Id: Iccbce6f7a3ffba044677c2d548d26af62223be15
diff --git a/compiler/sea_ir/sea.h b/compiler/sea_ir/sea.h
index 3a8efcd..93f35f2 100644
--- a/compiler/sea_ir/sea.h
+++ b/compiler/sea_ir/sea.h
@@ -102,6 +102,17 @@
definition->AddSSAUse(this);
}
+ // Returns the ordered set of Instructions that define the input operands of this instruction.
+ // Precondition: SeaGraph.ConvertToSSA().
+ std::vector<InstructionNode*> GetSSAProducers() {
+ std::vector<InstructionNode*> producers;
+ for (std::vector<std::vector<InstructionNode*>*>::const_iterator
+ cit = definition_edges_.begin(); cit != definition_edges_.end(); cit++) {
+ producers.insert(producers.end(), (*cit)->begin(), (*cit)->end());
+ }
+ return producers;
+ }
+
// Returns the instruction that defines the phi register from predecessor
// on position @predecessor_pos. Note that the return value is vector<> just
// for consistency with the return value of GetSSAUses() on regular instructions,
@@ -117,6 +128,9 @@
private:
int register_no_;
+ // This vector has one entry for each predecessors, each with a single
+ // element, storing the id of the instruction that defines the register
+ // corresponding to this phi function.
std::vector<std::vector<InstructionNode*>*> definition_edges_;
};