[llvm-commits] [llvm] r165466 - in /llvm/trunk: include/llvm/Instructions.h include/llvm/Support/CallSite.h lib/Analysis/MemoryBuiltins.cpp lib/VMCore/Instructions.cpp
Bill Wendling
isanbard at gmail.com
Mon Oct 8 17:28:54 PDT 2012
Author: void
Date: Mon Oct 8 19:28:54 2012
New Revision: 165466
URL: http://llvm.org/viewvc/llvm-project?rev=165466&view=rev
Log:
Remove more uses of the attribute enums by supplying appropriate query methods for them.
No functionality change intended.
Modified:
llvm/trunk/include/llvm/Instructions.h
llvm/trunk/include/llvm/Support/CallSite.h
llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=165466&r1=165465&r2=165466&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Mon Oct 8 19:28:54 2012
@@ -1267,20 +1267,29 @@
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
+ /// @brief Determine whether this call has the given attribute.
+ bool fnHasNoAliasAttr() const;
+ bool fnHasNoInlineAttr() const;
+ bool fnHasNoReturnAttr() const;
+ bool fnHasNoUnwindAttr() const;
+ bool fnHasReadNoneAttr() const;
+ bool fnHasReadOnlyAttr() const;
+ bool fnHasReturnsTwiceAttr() const;
+
/// \brief Return true if this call has the given attribute.
bool hasFnAttr(Attributes N) const {
return paramHasAttr(~0, N);
}
/// @brief Determine whether the call or the callee has the given attributes.
- bool paramHasSExtAttr(unsigned i) const;
- bool paramHasZExtAttr(unsigned i) const;
+ bool paramHasByValAttr(unsigned i) const;
bool paramHasInRegAttr(unsigned i) const;
- bool paramHasStructRetAttr(unsigned i) const;
bool paramHasNestAttr(unsigned i) const;
- bool paramHasByValAttr(unsigned i) const;
bool paramHasNoAliasAttr(unsigned i) const;
bool paramHasNoCaptureAttr(unsigned i) const;
+ bool paramHasSExtAttr(unsigned i) const;
+ bool paramHasStructRetAttr(unsigned i) const;
+ bool paramHasZExtAttr(unsigned i) const;
/// @brief Determine whether the call or the callee has the given attribute.
bool paramHasAttr(unsigned i, Attributes attr) const;
@@ -1291,7 +1300,7 @@
}
/// @brief Return true if the call should not be inlined.
- bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
+ bool isNoInline() const { return fnHasNoInlineAttr(); }
void setIsNoInline(bool Value = true) {
if (Value) addAttribute(~0, Attribute::NoInline);
else removeAttribute(~0, Attribute::NoInline);
@@ -1299,7 +1308,7 @@
/// @brief Return true if the call can return twice
bool canReturnTwice() const {
- return hasFnAttr(Attribute::ReturnsTwice);
+ return fnHasReturnsTwiceAttr();
}
void setCanReturnTwice(bool Value = true) {
if (Value) addAttribute(~0, Attribute::ReturnsTwice);
@@ -1308,7 +1317,7 @@
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return hasFnAttr(Attribute::ReadNone);
+ return fnHasReadNoneAttr();
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
@@ -1317,7 +1326,7 @@
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
+ return doesNotAccessMemory() || fnHasReadOnlyAttr();
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
@@ -1325,14 +1334,14 @@
}
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
+ bool doesNotReturn() const { return fnHasNoReturnAttr(); }
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
else removeAttribute(~0, Attribute::NoReturn);
}
/// @brief Determine if the call cannot unwind.
- bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
+ bool doesNotThrow() const { return fnHasNoUnwindAttr(); }
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
@@ -1342,7 +1351,7 @@
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasAttr(1, Attribute::StructRet);
+ return paramHasStructRetAttr(1);
}
/// @brief Determine if any call argument is an aggregate passed by value.
@@ -3039,6 +3048,15 @@
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
+ /// @brief Determine whether this call has the NoAlias attribute.
+ bool fnHasNoAliasAttr() const;
+ bool fnHasNoInlineAttr() const;
+ bool fnHasNoReturnAttr() const;
+ bool fnHasNoUnwindAttr() const;
+ bool fnHasReadNoneAttr() const;
+ bool fnHasReadOnlyAttr() const;
+ bool fnHasReturnsTwiceAttr() const;
+
/// \brief Return true if this call has the given attribute.
bool hasFnAttr(Attributes N) const {
return paramHasAttr(~0, N);
@@ -3063,7 +3081,7 @@
}
/// @brief Return true if the call should not be inlined.
- bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
+ bool isNoInline() const { return fnHasNoInlineAttr(); }
void setIsNoInline(bool Value = true) {
if (Value) addAttribute(~0, Attribute::NoInline);
else removeAttribute(~0, Attribute::NoInline);
@@ -3071,7 +3089,7 @@
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return hasFnAttr(Attribute::ReadNone);
+ return fnHasReadNoneAttr();
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
@@ -3080,7 +3098,7 @@
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
+ return doesNotAccessMemory() || fnHasReadOnlyAttr();
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
@@ -3088,14 +3106,14 @@
}
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
+ bool doesNotReturn() const { return fnHasNoReturnAttr(); }
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
else removeAttribute(~0, Attribute::NoReturn);
}
/// @brief Determine if the call cannot unwind.
- bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
+ bool doesNotThrow() const { return fnHasNoUnwindAttr(); }
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
@@ -3105,7 +3123,7 @@
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasAttr(1, Attribute::StructRet);
+ return paramHasStructRetAttr(1);
}
/// @brief Determine if any call argument is an aggregate passed by value.
Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=165466&r1=165465&r2=165466&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Mon Oct 8 19:28:54 2012
@@ -185,6 +185,27 @@
}
/// \brief Return true if this function has the given attribute.
+ bool fnHasNoAliasAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasNoAliasAttr());
+ }
+ bool fnHasNoInlineAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasNoInlineAttr());
+ }
+ bool fnHasNoReturnAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasNoReturnAttr());
+ }
+ bool fnHasNoUnwindAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasNoUnwindAttr());
+ }
+ bool fnHasReadNoneAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasReadNoneAttr());
+ }
+ bool fnHasReadOnlyAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasReadOnlyAttr());
+ }
+ bool fnHasReturnsTwiceAttr() const {
+ CALLSITE_DELEGATE_GETTER(fnHasReturnsTwiceAttr());
+ }
bool hasFnAttr(Attributes N) const {
CALLSITE_DELEGATE_GETTER(hasFnAttr(N));
}
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=165466&r1=165465&r2=165466&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Mon Oct 8 19:28:54 2012
@@ -132,7 +132,7 @@
static bool hasNoAliasAttr(const Value *V, bool LookThroughBitCast) {
ImmutableCallSite CS(LookThroughBitCast ? V->stripPointerCasts() : V);
- return CS && CS.hasFnAttr(Attribute::NoAlias);
+ return CS && CS.fnHasNoAliasAttr();
}
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=165466&r1=165465&r2=165466&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Oct 8 19:28:54 2012
@@ -342,6 +342,56 @@
setAttributes(PAL);
}
+bool CallInst::fnHasNoAliasAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoAliasAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoAliasAttr();
+ return false;
+}
+bool CallInst::fnHasNoInlineAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoInlineAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoInlineAttr();
+ return false;
+}
+bool CallInst::fnHasNoReturnAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoReturnAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoReturnAttr();
+ return false;
+}
+bool CallInst::fnHasNoUnwindAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoUnwindAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoUnwindAttr();
+ return false;
+}
+bool CallInst::fnHasReadNoneAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReadNoneAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReadNoneAttr();
+ return false;
+}
+bool CallInst::fnHasReadOnlyAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReadOnlyAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReadOnlyAttr();
+ return false;
+}
+bool CallInst::fnHasReturnsTwiceAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReturnsTwiceAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReturnsTwiceAttr();
+ return false;
+}
+
bool CallInst::paramHasSExtAttr(unsigned i) const {
if (AttributeList.getParamAttributes(i).hasSExtAttr())
return true;
@@ -626,6 +676,56 @@
return setSuccessor(idx, B);
}
+bool InvokeInst::fnHasNoAliasAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoAliasAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoAliasAttr();
+ return false;
+}
+bool InvokeInst::fnHasNoInlineAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoInlineAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoInlineAttr();
+ return false;
+}
+bool InvokeInst::fnHasNoReturnAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoReturnAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoReturnAttr();
+ return false;
+}
+bool InvokeInst::fnHasNoUnwindAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasNoUnwindAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasNoUnwindAttr();
+ return false;
+}
+bool InvokeInst::fnHasReadNoneAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReadNoneAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReadNoneAttr();
+ return false;
+}
+bool InvokeInst::fnHasReadOnlyAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReadOnlyAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReadOnlyAttr();
+ return false;
+}
+bool InvokeInst::fnHasReturnsTwiceAttr() const {
+ if (AttributeList.getParamAttributes(~0U).hasReturnsTwiceAttr())
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->getParamAttributes(~0U).hasReturnsTwiceAttr();
+ return false;
+}
+
bool InvokeInst::paramHasSExtAttr(unsigned i) const {
if (AttributeList.getParamAttributes(i).hasSExtAttr())
return true;
More information about the llvm-commits
mailing list