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.

llvm-svn: 64442
This commit is contained in:
Nick Lewycky
2009-02-13 07:06:27 +00:00
parent 76187b4d68
commit c60bd012bc
2 changed files with 199 additions and 3 deletions

View File

@@ -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