aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-01-09 12:55:47 +0100
committerNikita Popov <npopov@redhat.com>2023-01-09 12:59:16 +0100
commit9afb6360fcbb5c94f37f6c1328bfa76ca8e20021 (patch)
tree01aade15041ff80caa5b7886b59ef9facab2b779 /llvm/lib/IR/Attributes.cpp
parent07d6af6a71001c3d3a7aae21085646e642fbb56c (diff)
downloadllvm-9afb6360fcbb5c94f37f6c1328bfa76ca8e20021.zip
llvm-9afb6360fcbb5c94f37f6c1328bfa76ca8e20021.tar.gz
llvm-9afb6360fcbb5c94f37f6c1328bfa76ca8e20021.tar.bz2
[Attributes] Avoid duplicate hasAttribute() query (NFC)
removeAttribute() already performs a hasAttribute() check, so no need to also do it in the caller. Instead check whether the attribute set was changed. This makes the implementations in line with removeAttributesAtIndex().
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 8bcb080..8c989c4 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -1380,18 +1380,20 @@ AttributeList
AttributeList::removeAttributeAtIndex(LLVMContext &C, unsigned Index,
Attribute::AttrKind Kind) const {
AttributeSet Attrs = getAttributes(Index);
- if (!Attrs.hasAttribute(Kind))
+ AttributeSet NewAttrs = Attrs.removeAttribute(C, Kind);
+ if (Attrs == NewAttrs)
return *this;
- return setAttributesAtIndex(C, Index, Attrs.removeAttribute(C, Kind));
+ return setAttributesAtIndex(C, Index, NewAttrs);
}
AttributeList AttributeList::removeAttributeAtIndex(LLVMContext &C,
unsigned Index,
StringRef Kind) const {
AttributeSet Attrs = getAttributes(Index);
- if (!Attrs.hasAttribute(Kind))
+ AttributeSet NewAttrs = Attrs.removeAttribute(C, Kind);
+ if (Attrs == NewAttrs)
return *this;
- return setAttributesAtIndex(C, Index, Attrs.removeAttribute(C, Kind));
+ return setAttributesAtIndex(C, Index, NewAttrs);
}
AttributeList AttributeList::removeAttributesAtIndex(