[llvm] f80ae58 - [NFC] Cleanup calls to AttributeList::getAttribute(FunctionIndex)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 16:27:36 PDT 2021
Author: Arthur Eubanks
Date: 2021-08-13T16:27:11-07:00
New Revision: f80ae580686b99b69224c38ec4db6c982c814fe3
URL: https://github.com/llvm/llvm-project/commit/f80ae580686b99b69224c38ec4db6c982c814fe3
DIFF: https://github.com/llvm/llvm-project/commit/f80ae580686b99b69224c38ec4db6c982c814fe3.diff
LOG: [NFC] Cleanup calls to AttributeList::getAttribute(FunctionIndex)
getAttribute() is confusing, use a clearer method.
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/IR/Function.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 08220b1d6413..09863187c611 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -691,6 +691,16 @@ class AttributeList {
return getAttribute(ArgNo + FirstArgIndex, Kind);
}
+ /// Return the attribute object that exists for the function.
+ Attribute getFnAttr(Attribute::AttrKind Kind) const {
+ return getAttribute(FunctionIndex, Kind);
+ }
+
+ /// Return the attribute object that exists for the function.
+ Attribute getFnAttr(StringRef Kind) const {
+ return getAttribute(FunctionIndex, Kind);
+ }
+
/// Return the alignment of the return value.
MaybeAlign getRetAlignment() const;
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index ce0bbb54d846..af891cd67f8a 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -363,12 +363,12 @@ class Function : public GlobalObject, public ilist_node<Function> {
/// Return the attribute for the given attribute kind.
Attribute getFnAttribute(Attribute::AttrKind Kind) const {
- return getAttribute(AttributeList::FunctionIndex, Kind);
+ return AttributeSets.getFnAttr(Kind);
}
/// Return the attribute for the given attribute kind.
Attribute getFnAttribute(StringRef Kind) const {
- return getAttribute(AttributeList::FunctionIndex, Kind);
+ return AttributeSets.getFnAttr(Kind);
}
/// Return the stack alignment for the function.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 9e21a213a77a..aebd89e93329 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6735,9 +6735,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
case Intrinsic::debugtrap:
case Intrinsic::trap: {
StringRef TrapFuncName =
- I.getAttributes()
- .getAttribute(AttributeList::FunctionIndex, "trap-func-name")
- .getValueAsString();
+ I.getAttributes().getFnAttr("trap-func-name").getValueAsString();
if (TrapFuncName.empty()) {
switch (Intrinsic) {
case Intrinsic::trap:
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index e7857b93333f..5e93aa08c5af 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1825,8 +1825,7 @@ void Verifier::verifyParameterAttrs(AttributeSet Attrs, Type *Ty,
void Verifier::checkUnsignedBaseTenFuncAttr(AttributeList Attrs, StringRef Attr,
const Value *V) {
if (Attrs.hasFnAttr(Attr)) {
- StringRef S = Attrs.getAttribute(AttributeList::FunctionIndex, Attr)
- .getValueAsString();
+ StringRef S = Attrs.getFnAttr(Attr).getValueAsString();
unsigned N;
if (S.getAsInteger(10, N))
CheckFailed("\"" + Attr + "\" takes an unsigned integer: " + S, V);
@@ -2018,8 +2017,7 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
}
if (Attrs.hasFnAttr("frame-pointer")) {
- StringRef FP = Attrs.getAttribute(AttributeList::FunctionIndex,
- "frame-pointer").getValueAsString();
+ StringRef FP = Attrs.getFnAttr("frame-pointer").getValueAsString();
if (FP != "all" && FP != "non-leaf" && FP != "none")
CheckFailed("invalid value for 'frame-pointer' attribute: " + FP, V);
}
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 77701bf1d0c6..76b088cb5519 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1534,8 +1534,7 @@ static StringRef getDeoptLowering(CallBase *Call) {
// with values.
const AttributeList &CSAS = Call->getAttributes();
if (CSAS.hasFnAttr(DeoptLowering))
- return CSAS.getAttribute(AttributeList::FunctionIndex, DeoptLowering)
- .getValueAsString();
+ return CSAS.getFnAttr(DeoptLowering).getValueAsString();
Function *F = Call->getCalledFunction();
assert(F && F->hasFnAttribute(DeoptLowering));
return F->getFnAttribute(DeoptLowering).getValueAsString();
More information about the llvm-commits
mailing list