Add method to query for NoCapture attribute.
authorBill Wendling <isanbard@gmail.com>
Thu, 4 Oct 2012 07:18:12 +0000 (07:18 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 4 Oct 2012 07:18:12 +0000 (07:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165212 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
include/llvm/Support/CallSite.h
lib/VMCore/Instructions.cpp

index 711bced70ff46fd1e95fc78601539c080e33a3ae..5ff1c37ae6c573f0cd23fa1662bc364a5b29f1a3 100644 (file)
@@ -1280,6 +1280,7 @@ public:
   bool paramHasNestAttr(unsigned i) const;
   bool paramHasByValAttr(unsigned i) const;
   bool paramHasNoAliasAttr(unsigned i) const;
+  bool paramHasNoCaptureAttr(unsigned i) const;
 
   /// @brief Determine whether the call or the callee has the given attribute.
   bool paramHasAttr(unsigned i, Attributes attr) const;
@@ -3051,6 +3052,7 @@ public:
   bool paramHasNestAttr(unsigned i) const;
   bool paramHasByValAttr(unsigned i) const;
   bool paramHasNoAliasAttr(unsigned i) const;
+  bool paramHasNoCaptureAttr(unsigned i) const;
 
   /// @brief Determine whether the call or the callee has the given attribute.
   bool paramHasAttr(unsigned i, Attributes attr) const;
index 98c48d9aaaf9767dffd952cb2ba13f0707c86283..3c5a8d4dc474d2261583083e4a4a705447e8c28d 100644 (file)
@@ -211,6 +211,9 @@ public:
   bool paramHasNoAliasAttr(unsigned i) const {
     CALLSITE_DELEGATE_GETTER(paramHasNoAliasAttr(i));
   }
+  bool paramHasNoCaptureAttr(unsigned i) const {
+    CALLSITE_DELEGATE_GETTER(paramHasNoCaptureAttr(i));
+  }
 
   /// paramHasAttr - whether the call or the callee has the given attribute.
   bool paramHasAttr(uint16_t i, Attributes attr) const {
@@ -267,12 +270,12 @@ public:
 
   /// @brief Determine whether this argument is not captured.
   bool doesNotCapture(unsigned ArgNo) const {
-    return paramHasAttr(ArgNo + 1, Attribute::NoCapture);
+    return paramHasNoCaptureAttr(ArgNo + 1);
   }
 
   /// @brief Determine whether this argument is passed by value.
   bool isByValArgument(unsigned ArgNo) const {
-    return paramHasAttr(ArgNo + 1, Attribute::ByVal);
+    return paramHasByValAttr(ArgNo + 1);
   }
 
   /// hasArgument - Returns true if this CallSite passes the given Value* as an
index 9b700451beee05c5c93bb85553dde531edaff27e..e3cbf220d4a3a97ed75c1a1a754a2392ad76be28 100644 (file)
@@ -398,6 +398,14 @@ bool CallInst::paramHasNoAliasAttr(unsigned i) const {
   return false;
 }
 
+bool CallInst::paramHasNoCaptureAttr(unsigned i) const {
+  if (AttributeList.getParamAttributes(i).hasNoCaptureAttr())
+    return true;
+  if (const Function *F = getCalledFunction())
+    return F->getParamAttributes(i).hasNoCaptureAttr();
+  return false;
+}
+
 bool CallInst::paramHasAttr(unsigned i, Attributes attr) const {
   if (AttributeList.paramHasAttr(i, attr))
     return true;
@@ -674,6 +682,14 @@ bool InvokeInst::paramHasNoAliasAttr(unsigned i) const {
   return false;
 }
 
+bool InvokeInst::paramHasNoCaptureAttr(unsigned i) const {
+  if (AttributeList.getParamAttributes(i).hasNoCaptureAttr())
+    return true;
+  if (const Function *F = getCalledFunction())
+    return F->getParamAttributes(i).hasNoCaptureAttr();
+  return false;
+}
+
 bool InvokeInst::paramHasAttr(unsigned i, Attributes attr) const {
   if (AttributeList.paramHasAttr(i, attr))
     return true;