Subzero: Don't store std::string objects inside Variable.
Instead, extend 668a7a333d6ddc3102b5b7c7c07448f6d259113c to include both CfgNode and Variable, keeping a pool of strings in the Cfg.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/798693003
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index 6357129..615c81c 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -131,16 +131,17 @@
++TrimmedBegin;
}
-IceString Variable::getName() const {
- if (!Name.empty())
- return Name;
+IceString Variable::getName(const Cfg *Func) const {
+ if (Func && NameIndex >= 0)
+ return Func->getIdentifierName(NameIndex);
return "__" + std::to_string(getIndex());
}
Variable Variable::asType(Type Ty) {
// Note: This returns a Variable, even if the "this" object is a
// subclass of Variable.
- Variable V(kVariable, Ty, Number, Name);
+ Variable V(kVariable, Ty, Number);
+ V.NameIndex = NameIndex;
V.RegNum = RegNum;
V.StackOffset = StackOffset;
return V;
@@ -405,12 +406,12 @@
if (!ALLOW_DUMP)
return;
if (Func == NULL) {
- Str << "%" << getName();
+ Str << "%" << getName(Func);
return;
}
if (Func->getContext()->isVerbose(IceV_RegOrigins) ||
(!hasReg() && !Func->getTarget()->hasComputedFrame()))
- Str << "%" << getName();
+ Str << "%" << getName(Func);
if (hasReg()) {
if (Func->getContext()->isVerbose(IceV_RegOrigins))
Str << ":";