diff options
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 18 | ||||
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysisEvaluator.cpp | 77 | ||||
-rw-r--r-- | llvm/lib/Analysis/MemorySSA.cpp | 25 |
3 files changed, 71 insertions, 49 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index a499a6e6413..a6585df949f 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -372,6 +372,24 @@ FunctionModRefBehavior AAResults::getModRefBehavior(const Function *F) { return Result; } +raw_ostream &llvm::operator<<(raw_ostream &OS, AliasResult AR) { + switch (AR) { + case NoAlias: + OS << "NoAlias"; + break; + case MustAlias: + OS << "MustAlias"; + break; + case MayAlias: + OS << "MayAlias"; + break; + case PartialAlias: + OS << "PartialAlias"; + break; + } + return OS; +} + //===----------------------------------------------------------------------===// // Helper method implementation //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp b/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp index f737cecc43d..764ae916035 100644 --- a/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/llvm/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -41,7 +41,7 @@ static cl::opt<bool> PrintMustModRef("print-mustmodref", cl::ReallyHidden); static cl::opt<bool> EvalAAMD("evaluate-aa-metadata", cl::ReallyHidden); -static void PrintResults(const char *Msg, bool P, const Value *V1, +static void PrintResults(AliasResult AR, bool P, const Value *V1, const Value *V2, const Module *M) { if (PrintAll || P) { std::string o1, o2; @@ -50,18 +50,15 @@ static void PrintResults(const char *Msg, bool P, const Value *V1, V1->printAsOperand(os1, true, M); V2->printAsOperand(os2, true, M); } - + if (o2 < o1) std::swap(o1, o2); - errs() << " " << Msg << ":\t" - << o1 << ", " - << o2 << "\n"; + errs() << " " << AR << ":\t" << o1 << ", " << o2 << "\n"; } } -static inline void -PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, - Module *M) { +static inline void PrintModRefResults(const char *Msg, bool P, Instruction *I, + Value *Ptr, Module *M) { if (PrintAll || P) { errs() << " " << Msg << ": Ptr: "; Ptr->printAsOperand(errs(), true, M); @@ -69,21 +66,19 @@ PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, } } -static inline void -PrintModRefResults(const char *Msg, bool P, CallSite CSA, CallSite CSB, - Module *M) { +static inline void PrintModRefResults(const char *Msg, bool P, CallSite CSA, + CallSite CSB, Module *M) { if (PrintAll || P) { - errs() << " " << Msg << ": " << *CSA.getInstruction() - << " <-> " << *CSB.getInstruction() << '\n'; + errs() << " " << Msg << ": " << *CSA.getInstruction() << " <-> " + << *CSB.getInstruction() << '\n'; } } -static inline void -PrintLoadStoreResults(const char *Msg, bool P, const Value *V1, - const Value *V2, const Module *M) { +static inline void PrintLoadStoreResults(AliasResult AR, bool P, + const Value *V1, const Value *V2, + const Module *M) { if (PrintAll || P) { - errs() << " " << Msg << ": " << *V1 - << " <-> " << *V2 << '\n'; + errs() << " " << AR << ": " << *V1 << " <-> " << *V2 << '\n'; } } @@ -155,22 +150,22 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) { Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType(); if (I2ElTy->isSized()) I2Size = DL.getTypeStoreSize(I2ElTy); - switch (AA.alias(*I1, I1Size, *I2, I2Size)) { + AliasResult AR = AA.alias(*I1, I1Size, *I2, I2Size); + switch (AR) { case NoAlias: - PrintResults("NoAlias", PrintNoAlias, *I1, *I2, F.getParent()); + PrintResults(AR, PrintNoAlias, *I1, *I2, F.getParent()); ++NoAliasCount; break; case MayAlias: - PrintResults("MayAlias", PrintMayAlias, *I1, *I2, F.getParent()); + PrintResults(AR, PrintMayAlias, *I1, *I2, F.getParent()); ++MayAliasCount; break; case PartialAlias: - PrintResults("PartialAlias", PrintPartialAlias, *I1, *I2, - F.getParent()); + PrintResults(AR, PrintPartialAlias, *I1, *I2, F.getParent()); ++PartialAliasCount; break; case MustAlias: - PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent()); + PrintResults(AR, PrintMustAlias, *I1, *I2, F.getParent()); ++MustAliasCount; break; } @@ -181,26 +176,23 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) { // iterate over all pairs of load, store for (Value *Load : Loads) { for (Value *Store : Stores) { - switch (AA.alias(MemoryLocation::get(cast<LoadInst>(Load)), - MemoryLocation::get(cast<StoreInst>(Store)))) { + AliasResult AR = AA.alias(MemoryLocation::get(cast<LoadInst>(Load)), + MemoryLocation::get(cast<StoreInst>(Store))); + switch (AR) { case NoAlias: - PrintLoadStoreResults("NoAlias", PrintNoAlias, Load, Store, - F.getParent()); + PrintLoadStoreResults(AR, PrintNoAlias, Load, Store, F.getParent()); ++NoAliasCount; break; case MayAlias: - PrintLoadStoreResults("MayAlias", PrintMayAlias, Load, Store, - F.getParent()); + PrintLoadStoreResults(AR, PrintMayAlias, Load, Store, F.getParent()); ++MayAliasCount; break; case PartialAlias: - PrintLoadStoreResults("PartialAlias", PrintPartialAlias, Load, Store, - F.getParent()); + PrintLoadStoreResults(AR, PrintPartialAlias, Load, Store, F.getParent()); ++PartialAliasCount; break; case MustAlias: - PrintLoadStoreResults("MustAlias", PrintMustAlias, Load, Store, - F.getParent()); + PrintLoadStoreResults(AR, PrintMustAlias, Load, Store, F.getParent()); ++MustAliasCount; break; } @@ -211,26 +203,23 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) { for (SetVector<Value *>::iterator I1 = Stores.begin(), E = Stores.end(); I1 != E; ++I1) { for (SetVector<Value *>::iterator I2 = Stores.begin(); I2 != I1; ++I2) { - switch (AA.alias(MemoryLocation::get(cast<StoreInst>(*I1)), - MemoryLocation::get(cast<StoreInst>(*I2)))) { + AliasResult AR = AA.alias(MemoryLocation::get(cast<StoreInst>(*I1)), + MemoryLocation::get(cast<StoreInst>(*I2))); + switch (AR) { case NoAlias: - PrintLoadStoreResults("NoAlias", PrintNoAlias, *I1, *I2, - F.getParent()); + PrintLoadStoreResults(AR, PrintNoAlias, *I1, *I2, F.getParent()); ++NoAliasCount; break; case MayAlias: - PrintLoadStoreResults("MayAlias", PrintMayAlias, *I1, *I2, - F.getParent()); + PrintLoadStoreResults(AR, PrintMayAlias, *I1, *I2, F.getParent()); ++MayAliasCount; break; case PartialAlias: - PrintLoadStoreResults("PartialAlias", PrintPartialAlias, *I1, *I2, - F.getParent()); + PrintLoadStoreResults(AR, PrintPartialAlias, *I1, *I2, F.getParent()); ++PartialAliasCount; break; case MustAlias: - PrintLoadStoreResults("MustAlias", PrintMustAlias, *I1, *I2, - F.getParent()); + PrintLoadStoreResults(AR, PrintMustAlias, *I1, *I2, F.getParent()); ++MustAliasCount; break; } diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp index 43fc7d40d78..dda42274fdc 100644 --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -1857,12 +1857,24 @@ void MemoryAccess::print(raw_ostream &OS) const { void MemoryDef::print(raw_ostream &OS) const { MemoryAccess *UO = getDefiningAccess(); + auto printID = [&OS](MemoryAccess *A) { + if (A && A->getID()) + OS << A->getID(); + else + OS << LiveOnEntryStr; + }; + OS << getID() << " = MemoryDef("; - if (UO && UO->getID()) - OS << UO->getID(); - else - OS << LiveOnEntryStr; - OS << ')'; + printID(UO); + OS << ")"; + + if (isOptimized()) { + OS << "->"; + printID(getOptimized()); + + if (Optional<AliasResult> AR = getOptimizedAccessType()) + OS << " " << *AR; + } } void MemoryPhi::print(raw_ostream &OS) const { @@ -1899,6 +1911,9 @@ void MemoryUse::print(raw_ostream &OS) const { else OS << LiveOnEntryStr; OS << ')'; + + if (Optional<AliasResult> AR = getOptimizedAccessType()) + OS << " " << *AR; } void MemoryAccess::dump() const { |