diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-05-22 18:53:17 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-05-22 18:55:25 +0200 |
commit | fd46ed3f397d6cf41bc6c5a04ab2089f585afe44 (patch) | |
tree | 2ee5b1d35d010c53c17c68d02fe9001dae9d2b26 /llvm/lib/IR/Attributes.cpp | |
parent | 6f9ac11e3960bf5953b3af4b0c4e2682ea802081 (diff) | |
download | llvm-fd46ed3f397d6cf41bc6c5a04ab2089f585afe44.zip llvm-fd46ed3f397d6cf41bc6c5a04ab2089f585afe44.tar.gz llvm-fd46ed3f397d6cf41bc6c5a04ab2089f585afe44.tar.bz2 |
[IR] Optimize no-op removal from AttributeSet (NFC)
When removing an AttrBuilder from an AttributeSet, first check
whether there is any overlap. If nothing is being removed, we can
directly return the original set.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index adf8e6d..450543d 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -781,8 +781,12 @@ AttributeSet AttributeSet::removeAttribute(LLVMContext &C, } AttributeSet AttributeSet::removeAttributes(LLVMContext &C, - const AttrBuilder &Attrs) const { + const AttrBuilder &Attrs) const { AttrBuilder B(*this); + // If there is nothing to remove, directly return the original set. + if (!B.overlaps(Attrs)) + return *this; + B.remove(Attrs); return get(C, B); } |