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/IceCfg.h b/src/IceCfg.h
index 970b838..c313a89 100644
--- a/src/IceCfg.h
+++ b/src/IceCfg.h
@@ -59,9 +59,17 @@
void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; }
CfgNode *getEntryNode() const { return Entry; }
// Create a node and append it to the end of the linearized list.
- CfgNode *makeNode(const IceString &Name = "");
+ CfgNode *makeNode();
SizeT getNumNodes() const { return Nodes.size(); }
const NodeList &getNodes() const { return Nodes; }
+ // Adds a name to the list and returns its index, suitable for the
+ // argument to getNodeName(). No checking for duplicates is done.
+ int32_t addNodeName(const IceString &Name) {
+ int32_t Index = NodeNames.size();
+ NodeNames.push_back(Name);
+ return Index;
+ }
+ const IceString &getNodeName(int32_t Index) const { return NodeNames[Index]; }
// Manage instruction numbering.
InstNumberT newInstNumber() { return NextInstNumber++; }
@@ -175,6 +183,7 @@
IceString ErrorMessage;
CfgNode *Entry; // entry basic block
NodeList Nodes; // linearized node list; Entry should be first
+ std::vector<IceString> NodeNames;
InstNumberT NextInstNumber;
VarList Variables;
VarList Args; // subset of Variables, in argument order