From: Chris Lattner Date: Thu, 3 Jan 2008 00:29:27 +0000 (+0000) Subject: Don't create a new ParamAttrsList (which copies the vector) just to X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=89e94bd00c1a7e24b42e653fc5c0f4b00a3dee61;p=oota-llvm.git Don't create a new ParamAttrsList (which copies the vector) just to get a profile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45524 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ParameterAttributes.h b/include/llvm/ParameterAttributes.h index 05c3ebe9397..2b557bd684b 100644 --- a/include/llvm/ParameterAttributes.h +++ b/include/llvm/ParameterAttributes.h @@ -266,7 +266,10 @@ class ParamAttrsList : public FoldingSetNode { /// @name Implementation Details /// @{ public: - void Profile(FoldingSetNodeID &ID) const; + void Profile(FoldingSetNodeID &ID) const { + Profile(ID, attrs); + } + static void Profile(FoldingSetNodeID &ID, const ParamAttrsVector &Attrs); void dump() const; /// @} diff --git a/lib/VMCore/ParameterAttributes.cpp b/lib/VMCore/ParameterAttributes.cpp index aaf80cd7658..b6c29922a61 100644 --- a/lib/VMCore/ParameterAttributes.cpp +++ b/lib/VMCore/ParameterAttributes.cpp @@ -106,9 +106,10 @@ ParamAttrsList::areCompatible(const ParamAttrsList *A, const ParamAttrsList *B){ return true; } -void ParamAttrsList::Profile(FoldingSetNodeID &ID) const { - for (unsigned i = 0; i < attrs.size(); ++i) - ID.AddInteger(unsigned(attrs[i].attrs) << 16 | unsigned(attrs[i].index)); +void ParamAttrsList::Profile(FoldingSetNodeID &ID, + const ParamAttrsVector &Attrs) { + for (unsigned i = 0; i < Attrs.size(); ++i) + ID.AddInteger(unsigned(Attrs[i].attrs) << 16 | unsigned(Attrs[i].index)); } const ParamAttrsList * @@ -127,11 +128,10 @@ ParamAttrsList::get(const ParamAttrsVector &attrVec) { #endif // Otherwise, build a key to look up the existing attributes. - ParamAttrsList key(attrVec); FoldingSetNodeID ID; - key.Profile(ID); + ParamAttrsList::Profile(ID, attrVec); void *InsertPos; - ParamAttrsList* PAL = ParamAttrsLists->FindNodeOrInsertPos(ID, InsertPos); + ParamAttrsList *PAL = ParamAttrsLists->FindNodeOrInsertPos(ID, InsertPos); // If we didn't find any existing attributes of the same shape then // create a new one and insert it.