Don't analyze arguments already marked 'nocapture'.
authorDuncan Sands <baldrick@free.fr>
Wed, 31 Dec 2008 18:08:59 +0000 (18:08 +0000)
committerDuncan Sands <baldrick@free.fr>
Wed, 31 Dec 2008 18:08:59 +0000 (18:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61532 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Argument.h
lib/Transforms/IPO/FunctionAttrs.cpp
lib/VMCore/Function.cpp

index 9faff549f262b63f78d95b2b665f322ada468e8f..9c0636779849899fe6389c07c8e1b086087e09ee 100644 (file)
@@ -56,6 +56,10 @@ public:
   /// it in its containing function.
   bool hasNoAliasAttr() const;
   
+  /// hasNoCaptureAttr - Return true if this argument has the nocapture
+  /// attribute on it in its containing function.
+  bool hasNoCaptureAttr() const;
+  
   /// hasSRetAttr - Return true if this argument has the sret attribute on it in
   /// its containing function.
   bool hasStructRetAttr() const;
index 9ed605cf9f3ac045e77973fd4fb53936edef4cab..1824a710c5155e0f861353707fb43eb1121f82c6 100644 (file)
@@ -263,7 +263,8 @@ bool FunctionAttrs::AddNoCaptureAttrs(const std::vector<CallGraphNode *> &SCC) {
       continue;
 
     for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A!=E; ++A)
-      if (isa<PointerType>(A->getType()) && !isCaptured(*F, A)) {
+      if (isa<PointerType>(A->getType()) && !A->hasNoCaptureAttr() &&
+          !isCaptured(*F, A)) {
         A->addAttr(Attribute::NoCapture);
         NumNoCapture++;
         Changed = true;
index ddc6ace327864adfa3201c5d1b7796e3a4a3a962..f83fe435cd0e2243695e97074e6a001d26353f2c 100644 (file)
@@ -102,6 +102,13 @@ bool Argument::hasNoAliasAttr() const {
   return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoAlias);
 }
 
+/// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
+/// on it in its containing function.
+bool Argument::hasNoCaptureAttr() const {
+  if (!isa<PointerType>(getType())) return false;
+  return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoCapture);
+}
+
 /// hasSRetAttr - Return true if this argument has the sret attribute on
 /// it in its containing function.
 bool Argument::hasStructRetAttr() const {