[llvm] d1675e4 - [AttrBuilder] Remove empty() / td_empty() methods
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 15 08:57:27 PST 2022
Author: Nikita Popov
Date: 2022-01-15T17:57:18+01:00
New Revision: d1675e494411050bd3b56ae55ff9c6fd93349c37
URL: https://github.com/llvm/llvm-project/commit/d1675e494411050bd3b56ae55ff9c6fd93349c37
DIFF: https://github.com/llvm/llvm-project/commit/d1675e494411050bd3b56ae55ff9c6fd93349c37.diff
LOG: [AttrBuilder] Remove empty() / td_empty() methods
The empty() method is a footgun: It only checks whether there are
non-string attributes, which is not at all obvious from its name,
and of dubious usefulness. td_empty() is entirely unused.
Drop these methods in favor of hasAttributes(), which checks
whether there are any attributes, regardless of whether these are
string or enum attributes.
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
llvm/lib/Transforms/Utils/InlineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index a03e7a319f03e..84e4977240363 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -1207,10 +1207,6 @@ class AttrBuilder {
/// Attribute.getIntValue().
AttrBuilder &addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr);
- /// Return true if the builder contains no target-independent
- /// attributes.
- bool empty() const { return Attrs.none(); }
-
// Iterators for target-dependent attributes.
using td_type = decltype(TargetDepAttrs)::value_type;
using td_iterator = decltype(TargetDepAttrs)::iterator;
@@ -1230,8 +1226,6 @@ class AttrBuilder {
return td_const_range(td_begin(), td_end());
}
- bool td_empty() const { return TargetDepAttrs.empty(); }
-
bool operator==(const AttrBuilder &B) const;
bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
};
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index ae9bc09f9360e..bbd751d4ee2c3 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1186,7 +1186,7 @@ static bool MayContainThrowingOrExitingCall(Instruction *Begin,
static AttrBuilder IdentifyValidAttributes(CallBase &CB) {
AttrBuilder AB(CB.getContext(), CB.getAttributes(), AttributeList::ReturnIndex);
- if (AB.empty())
+ if (!AB.hasAttributes())
return AB;
AttrBuilder Valid(CB.getContext());
// Only allow these white listed attributes to be propagated back to the
@@ -1208,7 +1208,7 @@ static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap) {
return;
AttrBuilder Valid = IdentifyValidAttributes(CB);
- if (Valid.empty())
+ if (!Valid.hasAttributes())
return;
auto *CalledFunction = CB.getCalledFunction();
auto &Context = CalledFunction->getContext();
More information about the llvm-commits
mailing list