[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.
This commit is contained in:
Nikita Popov 2021-05-22 18:53:17 +02:00
parent 6f9ac11e39
commit fd46ed3f39
1 changed files with 5 additions and 1 deletions

View File

@ -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);
}