[llvm] r259683 - Minor performance tweaks to llvm-tblgen (and a few that might be a good idea)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 11:41:40 PST 2016
On Wed, Feb 3, 2016 at 11:34 AM, Reid Kleckner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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())) {
>
This is a bit more novel/noteworthy & might merit a comment about why we're
using dyn_cast to do the same work as getNameInitAsString. Perhaps.
> + 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;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160203/91402b54/attachment.html>
More information about the llvm-commits
mailing list