Subzero: Improve non-MINIMAL string performance.
In a DUMP-enabled build, such as the standard Release+Asserts build, translator performance has regressed as a result of 467ffe51bebcb3ae3e3ce745c38fc20e8837c31c (https://codereview.chromium.org/1838753002).
This is because Variable and CfgNode names are being instantiated unconditionally, rather than on-demand.
This CL restores most of that performance by going back to being on-demand. Note that it should have no effect on MINIMAL build performance.
Also, it turns out that Variable::getName() does not really need the Cfg* parameter, so that is removed (and all its callers are fixed transitively).
In addition, Variable and CfgNode are made more uniform with respect to each other in terms of inline definitions of the ctor, getName(), and setName().
BUG= none
R=jpp@chromium.org, kschimpf@google.com
Review URL: https://codereview.chromium.org/1866463002 .
diff --git a/src/IceOperand.h b/src/IceOperand.h
index 04895f6..06b11e6 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -647,9 +647,12 @@
}
SizeT getIndex() const { return Number; }
- std::string getName(const Cfg *Func) const;
+ std::string getName() const {
+ if (Name.hasStdString())
+ return Name.toString();
+ return "__" + std::to_string(getIndex());
+ }
virtual void setName(const Cfg *Func, const std::string &NewName) {
- (void)Func;
if (NewName.empty())
return;
Name = VariableString::createWithString(Func, NewName);
@@ -669,10 +672,10 @@
void setStackOffset(int32_t Offset) { StackOffset = Offset; }
/// Returns the variable's stack offset in symbolic form, to improve
/// readability in DecorateAsm mode.
- std::string getSymbolicStackOffset(const Cfg *Func) const {
+ std::string getSymbolicStackOffset() const {
if (!BuildDefs::dump())
return "";
- return "lv$" + getName(Func);
+ return "lv$" + getName();
}
bool hasReg() const { return getRegNum().hasValue(); }
@@ -755,12 +758,6 @@
Vars = VarsReal;
Vars[0] = this;
NumVars = 1;
- if (BuildDefs::dump()) {
- Name = VariableString::createWithString(
- Func, "__" + std::to_string(getIndex()));
- } else {
- Name = VariableString::createWithoutString(Func);
- }
}
/// Number is unique across all variables, and is used as a (bit)vector index
/// for liveness analysis.
@@ -805,8 +802,8 @@
void setName(const Cfg *Func, const std::string &NewName) override {
Variable::setName(Func, NewName);
if (LoVar && HiVar) {
- LoVar->setName(Func, getName(Func) + "__lo");
- HiVar->setName(Func, getName(Func) + "__hi");
+ LoVar->setName(Func, getName() + "__lo");
+ HiVar->setName(Func, getName() + "__hi");
}
}
@@ -835,8 +832,8 @@
LoVar->setIsArg(getIsArg());
HiVar->setIsArg(getIsArg());
if (BuildDefs::dump()) {
- LoVar->setName(Func, getName(Func) + "__lo");
- HiVar->setName(Func, getName(Func) + "__hi");
+ LoVar->setName(Func, getName() + "__lo");
+ HiVar->setName(Func, getName() + "__hi");
}
}