diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-02-13 07:06:27 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-02-13 07:06:27 +0000 |
commit | 826f7cebfd347bf2218ba35486bc13623523ed7f (patch) | |
tree | 05aeae843a370b72f8d4c64d8a9a119fb65fb844 /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 9194e8b0c827c97f396b209c7f4eeb75759e7068 (diff) | |
download | external_llvm-826f7cebfd347bf2218ba35486bc13623523ed7f.zip external_llvm-826f7cebfd347bf2218ba35486bc13623523ed7f.tar.gz external_llvm-826f7cebfd347bf2218ba35486bc13623523ed7f.tar.bz2 |
BasicAA was making the assumption that a local allocation which hadn't escaped
couldn't ever be the return of call instruction. However, it's quite possible
that said local allocation is itself the return of a function call. That's
what malloc and calloc are for, actually.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 1b26dc4..ef91850 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -319,7 +319,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { // If the pointer is to a locally allocated object that does not escape, // then the call can not mod/ref the pointer unless the call takes the // argument without capturing it. - if (isNonEscapingLocalObject(Object)) { + if (isNonEscapingLocalObject(Object) && CS.getInstruction() != Object) { bool passedAsArg = false; // TODO: Eventually only check 'nocapture' arguments. for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); @@ -414,10 +414,10 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // non-escaping local object, then we know the object couldn't escape to a // point where the call could return it. if ((isa<CallInst>(O1) || isa<InvokeInst>(O1)) && - isNonEscapingLocalObject(O2)) + isNonEscapingLocalObject(O2) && O1 != O2) return NoAlias; if ((isa<CallInst>(O2) || isa<InvokeInst>(O2)) && - isNonEscapingLocalObject(O1)) + isNonEscapingLocalObject(O1) && O1 != O2) return NoAlias; // If we have two gep instructions with must-alias'ing base pointers, figure |