[llvm] r259683 - Minor performance tweaks to llvm-tblgen (and a few that might be a good idea)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 11:34:29 PST 2016
Author: rnk
Date: Wed Feb 3 13:34:28 2016
New Revision: 259683
URL: http://llvm.org/viewvc/llvm-project?rev=259683&view=rev
Log:
Minor performance tweaks to llvm-tblgen (and a few that might be a good idea)
Summary:
This patch adds a reserve call to an expensive function
(`llvm::LoadIntrinsics`), and may fix a few other low hanging
performance fruit (I've put them in comments for now, so we can
discuss).
**Motivation:**
As I'm sure other developers do, when I build LLVM, I build the entire
project with the same config (`Debug`, `MinSizeRel`, `Release`, or
`RelWithDebInfo`). However, the `Debug` config also builds llvm-tblgen
in `Debug` mode. Later build steps that run llvm-tblgen then can
actually be the slowest steps in the entire build. Nobody likes slow
builds.
Reviewers: rnk, dblaikie
Differential Revision: http://reviews.llvm.org/D16832
Patch by Alexander G. Riccio
Modified:
llvm/trunk/include/llvm/TableGen/Record.h
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
llvm/trunk/utils/TableGen/CodeGenTarget.cpp
Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=259683&r1=259682&r2=259683&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Wed Feb 3 13:34:28 2016
@@ -1307,9 +1307,14 @@ public:
}
bool isSubClassOf(StringRef Name) const {
- for (const auto &SCPair : SuperClasses)
- if (SCPair.first->getNameInitAsString() == Name)
+ for (const auto &SCPair : SuperClasses) {
+ if (const auto *SI = dyn_cast<StringInit>(SCPair.first->getNameInit())) {
+ if (SI->getValue() == Name)
+ return true;
+ } else if (SCPair.first->getNameInitAsString() == Name) {
return true;
+ }
+ }
return false;
}
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=259683&r1=259682&r2=259683&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Wed Feb 3 13:34:28 2016
@@ -49,7 +49,9 @@ CGIOperandList::CGIOperandList(Record *R
unsigned MIOperandNo = 0;
std::set<std::string> OperandNames;
- for (unsigned i = 0, e = InDI->getNumArgs()+OutDI->getNumArgs(); i != e; ++i){
+ unsigned e = InDI->getNumArgs() + OutDI->getNumArgs();
+ OperandList.reserve(e);
+ for (unsigned i = 0; i != e; ++i){
Init *ArgInit;
std::string ArgName;
if (i < NumDefs) {
Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=259683&r1=259682&r2=259683&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Wed Feb 3 13:34:28 2016
@@ -441,6 +441,7 @@ std::vector<CodeGenIntrinsic> llvm::Load
std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic");
std::vector<CodeGenIntrinsic> Result;
+ Result.reserve(I.size());
for (unsigned i = 0, e = I.size(); i != e; ++i) {
bool isTarget = I[i]->getValueAsBit("isTarget");
@@ -448,7 +449,7 @@ std::vector<CodeGenIntrinsic> llvm::Load
Result.push_back(CodeGenIntrinsic(I[i]));
}
std::sort(Result.begin(), Result.end(),
- [](CodeGenIntrinsic LHS, CodeGenIntrinsic RHS) {
+ [](const CodeGenIntrinsic& LHS, const CodeGenIntrinsic& RHS) {
return LHS.Name < RHS.Name;
});
return Result;
More information about the llvm-commits
mailing list