[llvm-commits] [llvm] r105288 - /llvm/trunk/lib/Analysis/Lint.cpp

Dan Gohman gohman at apple.com
Tue Jun 1 13:51:40 PDT 2010


Author: djg
Date: Tue Jun  1 15:51:40 2010
New Revision: 105288

URL: http://llvm.org/viewvc/llvm-project?rev=105288&view=rev
Log:
Fix the noalias checking so that it doesn't worry about
an argument aliasing itself. Thanks Duncan!

Modified:
    llvm/trunk/lib/Analysis/Lint.cpp

Modified: llvm/trunk/lib/Analysis/Lint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=105288&r1=105287&r2=105288&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Lint.cpp (original)
+++ llvm/trunk/lib/Analysis/Lint.cpp Tue Jun  1 15:51:40 2010
@@ -215,7 +215,6 @@
 
     const FunctionType *FT = F->getFunctionType();
     unsigned NumActualArgs = unsigned(CS.arg_end()-CS.arg_begin());
-    std::vector<Value *> NoAliasVals;
 
     Assert1(FT->isVarArg() ?
               FT->getNumParams() <= NumActualArgs :
@@ -233,8 +232,19 @@
         Assert1(Formal->getType() == Actual->getType(),
                 "Undefined behavior: Call argument type mismatches "
                 "callee parameter type", &I);
+
+        // Check that noalias arguments don't alias other arguments. The
+        // AliasAnalysis API isn't expressive enough for what we really want
+        // to do. Known partial overlap is not distinguished from the case
+        // where nothing is known.
         if (Formal->hasNoAliasAttr() && Actual->getType()->isPointerTy())
-          NoAliasVals.push_back(Actual);
+          for (CallSite::arg_iterator BI = CS.arg_begin(); BI != AE; ++BI) {
+            Assert1(AI == BI ||
+                    AA->alias(*AI, ~0u, *BI, ~0u) != AliasAnalysis::MustAlias,
+                    "Unusual: noalias argument aliases another argument", &I);
+          }
+
+        // Check that an sret argument points to valid memory.
         if (Formal->hasStructRetAttr() && Actual->getType()->isPointerTy()) {
           const Type *Ty =
             cast<PointerType>(Formal->getType())->getElementType();
@@ -244,16 +254,6 @@
         }
       }
     }
-
-    // Check that the noalias arguments don't overlap. The AliasAnalysis API
-    // isn't expressive enough for what we really want to do. Known partial
-    // overlap is not distinguished from the case where nothing is known.
-    for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
-         AI != AE; ++AI)
-      for (std::vector<Value *>::iterator J = NoAliasVals.begin(),
-           E = NoAliasVals.end(); J != E; ++J)
-        Assert1(AA->alias(*J, ~0u, *AI, ~0u) != AliasAnalysis::MustAlias,
-                "Unusual: noalias argument aliases another argument", &I);
   }
 
   if (CS.isCall() && cast<CallInst>(CS.getInstruction())->isTailCall())





More information about the llvm-commits mailing list