Move the capture analysis from MemoryDependencyAnalysis to a more general place

so that it can be reused in MemCpyOptimizer.  This analysis is needed to remove
an unnecessary memcpy when returning a struct into a local variable.
rdar://11341081
PR12686


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier
2012-05-14 20:35:04 +00:00
parent 5262abb268
commit 3a884f5c17
6 changed files with 128 additions and 89 deletions

View File

@@ -662,7 +662,11 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy,
// the use analysis, we also need to know that it does not sneakily
// access dest. We rely on AA to figure this out for us.
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
if (AA.getModRefInfo(C, cpyDest, srcSize) != AliasAnalysis::NoModRef)
AliasAnalysis::ModRefResult MR = AA.getModRefInfo(C, cpyDest, srcSize);
// If necessary, perform additional analysis.
if (MR != AliasAnalysis::NoModRef)
MR = AA.callCapturesBefore(C, cpyDest, srcSize, &DT);
if (MR != AliasAnalysis::NoModRef)
return false;
// All the checks have passed, so do the transformation.