[llvm-commits] [llvm] r165551 - 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
Tue Oct 9 14:49:52 PDT 2012
Author: void
Date: Tue Oct 9 16:49:51 2012
New Revision: 165551
URL: http://llvm.org/viewvc/llvm-project?rev=165551&view=rev
Log:
Use the attribute enums to query if a function has an attribute.
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=165551&r1=165550&r2=165551&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Tue Oct 9 16:49:51 2012
@@ -1268,13 +1268,7 @@
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;
+ bool hasFnAttr(Attributes::AttrVal A) const;
/// @brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
@@ -1285,7 +1279,7 @@
}
/// @brief Return true if the call should not be inlined.
- bool isNoInline() const { return fnHasNoInlineAttr(); }
+ bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
void setIsNoInline(bool Value = true) {
if (Value) addAttribute(~0, Attribute::NoInline);
else removeAttribute(~0, Attribute::NoInline);
@@ -1293,7 +1287,7 @@
/// @brief Return true if the call can return twice
bool canReturnTwice() const {
- return fnHasReturnsTwiceAttr();
+ return hasFnAttr(Attributes::ReturnsTwice);
}
void setCanReturnTwice(bool Value = true) {
if (Value) addAttribute(~0, Attribute::ReturnsTwice);
@@ -1302,7 +1296,7 @@
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return fnHasReadNoneAttr();
+ return hasFnAttr(Attributes::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
@@ -1311,7 +1305,7 @@
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || fnHasReadOnlyAttr();
+ return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
@@ -1319,14 +1313,14 @@
}
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const { return fnHasNoReturnAttr(); }
+ bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
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 fnHasNoUnwindAttr(); }
+ bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
@@ -3037,13 +3031,7 @@
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;
+ bool hasFnAttr(Attributes::AttrVal A) const;
/// @brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
@@ -3054,7 +3042,7 @@
}
/// @brief Return true if the call should not be inlined.
- bool isNoInline() const { return fnHasNoInlineAttr(); }
+ bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
void setIsNoInline(bool Value = true) {
if (Value) addAttribute(~0, Attribute::NoInline);
else removeAttribute(~0, Attribute::NoInline);
@@ -3062,7 +3050,7 @@
/// @brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return fnHasReadNoneAttr();
+ return hasFnAttr(Attributes::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
@@ -3071,7 +3059,7 @@
/// @brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || fnHasReadOnlyAttr();
+ return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
@@ -3079,14 +3067,14 @@
}
/// @brief Determine if the call cannot return.
- bool doesNotReturn() const { return fnHasNoReturnAttr(); }
+ bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
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 fnHasNoUnwindAttr(); }
+ bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=165551&r1=165550&r2=165551&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Tue Oct 9 16:49:51 2012
@@ -185,29 +185,8 @@
}
/// \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));
+ bool hasFnAttr(Attributes::AttrVal A) const {
+ CALLSITE_DELEGATE_GETTER(hasFnAttr(A));
}
/// \brief Return true if the call or the callee has the given attribute.
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=165551&r1=165550&r2=165551&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Tue Oct 9 16:49:51 2012
@@ -132,7 +132,7 @@
static bool hasNoAliasAttr(const Value *V, bool LookThroughBitCast) {
ImmutableCallSite CS(LookThroughBitCast ? V->stripPointerCasts() : V);
- return CS && CS.fnHasNoAliasAttr();
+ return CS && CS.hasFnAttr(Attributes::NoAlias);
}
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=165551&r1=165550&r2=165551&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Oct 9 16:49:51 2012
@@ -342,54 +342,11 @@
setAttributes(PAL);
}
-bool CallInst::fnHasNoAliasAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoAlias))
+bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoAlias);
- return false;
-}
-bool CallInst::fnHasNoInlineAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoInline))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoInline);
- return false;
-}
-bool CallInst::fnHasNoReturnAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoReturn))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoReturn);
- return false;
-}
-bool CallInst::fnHasNoUnwindAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoUnwind))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoUnwind);
- return false;
-}
-bool CallInst::fnHasReadNoneAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::ReadNone))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReadNone);
- return false;
-}
-bool CallInst::fnHasReadOnlyAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::ReadOnly))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReadOnly);
- return false;
-}
-bool CallInst::fnHasReturnsTwiceAttr() const {
- if (AttributeList.getParamAttributes(~0U).
- hasAttribute(Attributes::ReturnsTwice))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReturnsTwice);
+ return F->getParamAttributes(~0U).hasAttribute(A);
return false;
}
@@ -613,54 +570,11 @@
return setSuccessor(idx, B);
}
-bool InvokeInst::fnHasNoAliasAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoAlias))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoAlias);
- return false;
-}
-bool InvokeInst::fnHasNoInlineAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoInline))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoInline);
- return false;
-}
-bool InvokeInst::fnHasNoReturnAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoReturn))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoReturn);
- return false;
-}
-bool InvokeInst::fnHasNoUnwindAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::NoUnwind))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::NoUnwind);
- return false;
-}
-bool InvokeInst::fnHasReadNoneAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::ReadNone))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReadNone);
- return false;
-}
-bool InvokeInst::fnHasReadOnlyAttr() const {
- if (AttributeList.getParamAttributes(~0U).hasAttribute(Attributes::ReadOnly))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReadOnly);
- return false;
-}
-bool InvokeInst::fnHasReturnsTwiceAttr() const {
- if (AttributeList.getParamAttributes(~0U).
- hasAttribute(Attributes::ReturnsTwice))
+bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(~0U).hasAttribute(Attributes::ReturnsTwice);
+ return F->getParamAttributes(~0U).hasAttribute(A);
return false;
}
More information about the llvm-commits
mailing list