diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 47e47e5cba1..53d229528d9 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -275,8 +275,14 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, pointerSize = ~0UL; } else if (CallSite::get(QI).getInstruction() != 0) { // Call insts need special handling. Check is they can modify our pointer - if (AA.getModRefInfo(CallSite::get(QI), dependee, dependeeSize) != - AliasAnalysis::NoModRef) { + AliasAnalysis::ModRefResult MR = AA.getModRefInfo(CallSite::get(QI), + dependee, dependeeSize); + + if (MR != AliasAnalysis::NoModRef) { + // Loads don't depend on read-only calls + if (isa(query) && MR == AliasAnalysis::Ref) + continue; + if (!start || block) { depGraphLocal.insert(std::make_pair(query, std::make_pair(QI, true))); reverseDep.insert(std::make_pair(QI, query)); @@ -294,6 +300,11 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, dependee, dependeeSize); if (R != AliasAnalysis::NoAlias) { + // May-alias loads don't depend on each other + if (isa(query) && isa(QI) && + R == AliasAnalysis::MayAlias) + continue; + if (!start || block) { depGraphLocal.insert(std::make_pair(query, std::make_pair(QI, true))); reverseDep.insert(std::make_pair(QI, query));