diff options
author | Matthias Braun <matze@braunis.de> | 2016-01-29 22:25:13 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-01-29 22:25:13 +0000 |
commit | 31eeb76f5e3b73f2eb5364ee840789c74723eb1b (patch) | |
tree | 0a670e07492b29a16677c741189589a143fc97b6 /llvm/lib/IR/Attributes.cpp | |
parent | 5e378ddc1e0396e1296f934d8b1da7ce108d67b6 (diff) | |
download | llvm-31eeb76f5e3b73f2eb5364ee840789c74723eb1b.zip llvm-31eeb76f5e3b73f2eb5364ee840789c74723eb1b.tar.gz llvm-31eeb76f5e3b73f2eb5364ee840789c74723eb1b.tar.bz2 |
AttributeSetNode: Summarize existing attributes in a bitset.
The majority of queries just checks for the existince of an enum
attribute. We only have 48 of those and can summaryiz them in an
uint64_t bitfield so we can avoid searching the list. This improves
"opt" compile time by 1-4% in my measurements.
Differential Revision: http://reviews.llvm.org/D16617
llvm-svn: 259251
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index ee5a234..af5fe85 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -498,13 +498,6 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C, return PA; } -bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const { - for (iterator I = begin(), E = end(); I != E; ++I) - if (I->hasAttribute(Kind)) - return true; - return false; -} - bool AttributeSetNode::hasAttribute(StringRef Kind) const { for (iterator I = begin(), E = end(); I != E; ++I) if (I->hasAttribute(Kind)) @@ -513,9 +506,11 @@ bool AttributeSetNode::hasAttribute(StringRef Kind) const { } Attribute AttributeSetNode::getAttribute(Attribute::AttrKind Kind) const { - for (iterator I = begin(), E = end(); I != E; ++I) - if (I->hasAttribute(Kind)) - return *I; + if (hasAttribute(Kind)) { + for (iterator I = begin(), E = end(); I != E; ++I) + if (I->hasAttribute(Kind)) + return *I; + } return Attribute(); } |