[llvm] dc41c55 - [NFC] Make AttributeList::hasAttribute(AttributeList::ReturnIndex) its own method
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 16:27:38 PDT 2021
Author: Arthur Eubanks
Date: 2021-08-13T16:27:11-07:00
New Revision: dc41c558dd907a676fb390d3a05a93bda960e3c0
URL: https://github.com/llvm/llvm-project/commit/dc41c558dd907a676fb390d3a05a93bda960e3c0
DIFF: https://github.com/llvm/llvm-project/commit/dc41c558dd907a676fb390d3a05a93bda960e3c0.diff
LOG: [NFC] Make AttributeList::hasAttribute(AttributeList::ReturnIndex) its own method
AttributeList::hasAttribute() is confusing. In an attempt to change the
name to something that suggests using other methods, fix up some
existing uses.
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 09863187c611..734279433c93 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -657,6 +657,11 @@ class AttributeList {
return hasAttribute(ReturnIndex, Kind);
}
+ /// Return true if the attribute exists for the return value.
+ bool hasRetAttr(StringRef Kind) const {
+ return hasAttribute(ReturnIndex, Kind);
+ }
+
/// Return true if attributes exist for the return value.
bool hasRetAttrs() const { return hasAttributes(ReturnIndex); }
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index af891cd67f8a..4c3758ebdb09 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -455,6 +455,11 @@ class Function : public GlobalObject, public ilist_node<Function> {
return getAttributes().getParamAttr(ArgNo, Kind);
}
+ /// check if an attribute is in the list of attributes for the return value.
+ bool hasRetAttribute(Attribute::AttrKind Kind) const {
+ return getAttributes().hasRetAttr(Kind);
+ }
+
/// gets the attribute from the list of attributes.
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const {
return AttributeSets.getAttribute(i, Kind);
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 65cada3d735d..142e1f29a641 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -2272,12 +2272,12 @@ class CallBase : public Instruction {
/// Determine whether the return value has the given attribute. Supports
/// Attribute::AttrKind and StringRef as \p AttrKind types.
template <typename AttrKind> bool hasRetAttrImpl(AttrKind Kind) const {
- if (Attrs.hasAttribute(AttributeList::ReturnIndex, Kind))
+ if (Attrs.hasRetAttr(Kind))
return true;
// Look at the callee, if available.
if (const Function *F = getCalledFunction())
- return F->getAttributes().hasAttribute(AttributeList::ReturnIndex, Kind);
+ return F->getAttributes().hasRetAttr(Kind);
return false;
}
};
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 385a9ec7457d..a727b76162d4 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -3807,7 +3807,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
if (isAMustTailRetVal(RetVal)) return;
Value *ShadowPtr = getShadowPtrForRetval(RetVal, IRB);
bool HasNoUndef =
- F.hasAttribute(AttributeList::ReturnIndex, Attribute::NoUndef);
+ F.hasRetAttribute(Attribute::NoUndef);
bool StoreShadow = !(ClEagerChecks && HasNoUndef);
// FIXME: Consider using SpecialCaseList to specify a list of functions that
// must always return fully initialized values. For now, we hardcode "main".
More information about the llvm-commits
mailing list