summaryrefslogtreecommitdiff
path: root/lib/Analysis/Lint.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-06-01 20:51:40 +0000
committerDan Gohman <gohman@apple.com>2010-06-01 20:51:40 +0000
commit10e7726e6c317b2fe08533d555ef07b4c206aee2 (patch)
tree2a7fb7b7c3b16fa697d1017d5bf4589dbdab663b /lib/Analysis/Lint.cpp
parent9126c0d42a5176e5865171713fae4a62e3c69912 (diff)
downloadllvm-10e7726e6c317b2fe08533d555ef07b4c206aee2.tar.gz
llvm-10e7726e6c317b2fe08533d555ef07b4c206aee2.tar.bz2
llvm-10e7726e6c317b2fe08533d555ef07b4c206aee2.tar.xz
Fix the noalias checking so that it doesn't worry about
an argument aliasing itself. Thanks Duncan! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Lint.cpp')
-rw-r--r--lib/Analysis/Lint.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp
index 1e836af1c5..6c137333d6 100644
--- a/lib/Analysis/Lint.cpp
+++ b/lib/Analysis/Lint.cpp
@@ -215,7 +215,6 @@ void Lint::visitCallSite(CallSite CS) {
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 @@ void Lint::visitCallSite(CallSite CS) {
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 @@ void Lint::visitCallSite(CallSite CS) {
}
}
}
-
- // 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())