[llvm] d431c5d - Revert "[NFC] Factor out function to detect if an attribute has an argument."
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 06:04:27 PST 2020
Author: Tyker
Date: 2020-02-02T15:03:06+01:00
New Revision: d431c5d9af22338100c0be71cccfcd3ab425848e
URL: https://github.com/llvm/llvm-project/commit/d431c5d9af22338100c0be71cccfcd3ab425848e
DIFF: https://github.com/llvm/llvm-project/commit/d431c5d9af22338100c0be71cccfcd3ab425848e.diff
LOG: Revert "[NFC] Factor out function to detect if an attribute has an argument."
This reverts commit ff1b9add2ffd47abc649895e33b3e5c30d6f2079.
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/KnowledgeRetention.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 3871db9a200e..3ef8a3bbfd79 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -111,9 +111,6 @@ class Attribute {
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind);
- /// Return true if and only if the attribute has an Argument.
- static bool doesAttrKindHaveArgument(Attribute::AttrKind AttrKind);
-
//===--------------------------------------------------------------------===//
// Attribute Accessors
//===--------------------------------------------------------------------===//
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h
index 8741c0ca9b3d..da6e993e2e58 100644
--- a/llvm/lib/IR/AttributeImpl.h
+++ b/llvm/lib/IR/AttributeImpl.h
@@ -134,7 +134,10 @@ class IntAttributeImpl : public EnumAttributeImpl {
public:
IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)
: EnumAttributeImpl(IntAttrEntry, Kind), Val(Val) {
- assert(Attribute::doesAttrKindHaveArgument(Kind) &&
+ assert((Kind == Attribute::Alignment || Kind == Attribute::StackAlignment ||
+ Kind == Attribute::Dereferenceable ||
+ Kind == Attribute::DereferenceableOrNull ||
+ Kind == Attribute::AllocSize) &&
"Wrong kind for int attribute!");
}
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 5f0008e38fda..78ee00d7821f 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -199,14 +199,6 @@ StringRef Attribute::getNameFromAttrKind(Attribute::AttrKind AttrKind) {
}
}
-bool Attribute::doesAttrKindHaveArgument(Attribute::AttrKind AttrKind) {
- return AttrKind == Attribute::Alignment ||
- AttrKind == Attribute::StackAlignment ||
- AttrKind == Attribute::Dereferenceable ||
- AttrKind == Attribute::AllocSize ||
- AttrKind == Attribute::DereferenceableOrNull;
-}
-
//===----------------------------------------------------------------------===//
// Attribute Accessor Methods
//===----------------------------------------------------------------------===//
@@ -1480,7 +1472,8 @@ void AttrBuilder::clear() {
AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) {
assert((unsigned)Val < Attribute::EndAttrKinds && "Attribute out of range!");
- assert(!Attribute::doesAttrKindHaveArgument(Val) &&
+ assert(Val != Attribute::Alignment && Val != Attribute::StackAlignment &&
+ Val != Attribute::Dereferenceable && Val != Attribute::AllocSize &&
"Adding integer attribute without adding a value!");
Attrs[Val] = true;
return *this;
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 6062baa70dee..6698a6860b39 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1572,13 +1572,6 @@ void Verifier::verifyAttributeTypes(AttributeSet Attrs, bool IsFunction,
if (A.isStringAttribute())
continue;
- if (A.isIntAttribute() !=
- Attribute::doesAttrKindHaveArgument(A.getKindAsEnum())) {
- CheckFailed("Attribute '" + A.getAsString() + "' should have an Argument",
- V);
- return;
- }
-
if (isFuncOnlyAttr(A.getKindAsEnum())) {
if (!IsFunction) {
CheckFailed("Attribute '" + A.getAsString() +
diff --git a/llvm/lib/Transforms/Utils/KnowledgeRetention.cpp b/llvm/lib/Transforms/Utils/KnowledgeRetention.cpp
index 266d10268560..eea947fdb0d9 100644
--- a/llvm/lib/Transforms/Utils/KnowledgeRetention.cpp
+++ b/llvm/lib/Transforms/Utils/KnowledgeRetention.cpp
@@ -124,11 +124,6 @@ struct AssumeBuilderState {
SmallVector<OperandBundleDef, 8> OpBundle;
for (const AssumedKnowledge &Elem : AssumedKnowledgeSet) {
SmallVector<Value *, 2> Args;
- assert(Attribute::getAttrKindFromName(Elem.Name) ==
- Attribute::AttrKind::None ||
- static_cast<bool>(Elem.Argument) ==
- Attribute::doesAttrKindHaveArgument(
- Attribute::getAttrKindFromName(Elem.Name)));
if (Elem.WasOn.getPointer())
Args.push_back(Elem.WasOn.getPointer());
if (Elem.Argument)
More information about the llvm-commits
mailing list