Subzero: Pull the node name out of the node structure.
Instead, non-empty node names are kept in a single vector in the Cfg
object.
This is toward the goal of pulling non-POD fields out of the CfgNode
class so that CfgNode can be arena-allocated and not leak memory.
Also, actual setting of the node name is now guarded by ALLOW_DUMP.
BUG= none
R=jvoung@chromium.org, kschimpf@google.com
Review URL: https://codereview.chromium.org/787333005
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index 59035f8..920f373 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -22,15 +22,15 @@
namespace Ice {
-CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber, IceString Name)
- : Func(Func), Number(LabelNumber), Name(Name), HasReturn(false),
+CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber)
+ : Func(Func), Number(LabelNumber), NameIndex(-1), HasReturn(false),
NeedsPlacement(false), InstCountEstimate(0) {}
// Returns the name the node was created with. If no name was given,
// it synthesizes a (hopefully) unique name.
IceString CfgNode::getName() const {
- if (!Name.empty())
- return Name;
+ if (NameIndex >= 0)
+ return Func->getNodeName(NameIndex);
return "__" + std::to_string(getIndex());
}
@@ -219,8 +219,9 @@
// out-edge list, this node's in-edge list, and the Phi instruction's
// operand list.
CfgNode *CfgNode::splitIncomingEdge(CfgNode *Pred, SizeT EdgeIndex) {
- CfgNode *NewNode =
- Func->makeNode("split_" + Pred->getName() + "_" + getName() + "_" +
+ CfgNode *NewNode = Func->makeNode();
+ if (ALLOW_DUMP)
+ NewNode->setName("split_" + Pred->getName() + "_" + getName() + "_" +
std::to_string(EdgeIndex));
// The new node is added to the end of the node list, and will later
// need to be sorted into a reasonable topological order.