From d67ff79f572b06c0435f6d6133053cbed200b9d0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 26 Feb 2003 19:27:05 +0000 Subject: [PATCH] Adjust to new AA interface Add tracking for Mod/Ref info llvm-svn: 5634 --- lib/Analysis/AliasAnalysisCounter.cpp | 65 ++++++++++++++++++++------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index ba41092128b..d0471d76389 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -12,35 +12,59 @@ namespace { class AliasAnalysisCounter : public Pass, public AliasAnalysis { unsigned No, May, Must; + unsigned NoMR, JustRef, JustMod, MR; const char *Name; public: - AliasAnalysisCounter() : No(0), May(0), Must(0) {} + AliasAnalysisCounter() { + No = May = Must = 0; + NoMR = JustRef = JustMod = MR = 0; + } + + void printLine(const char *Desc, unsigned Val, unsigned Sum) { + std::cerr << " " << Val << " " << Desc << " responses (" + << Val*100/Sum << "%)\n"; + } ~AliasAnalysisCounter() { - unsigned Sum = No+May+Must; - if (Sum) { // Print a report if any counted queries occurred... + unsigned AASum = No+May+Must; + unsigned MRSum = NoMR+JustRef+JustMod+MR; + if (AASum + MRSum) { // Print a report if any counted queries occurred... std::cerr << "\n===== Alias Analysis Counter Report =====\n" << " Analysis counted: " << Name << "\n" - << " " << Sum << " Total Alias Queries Performed\n" - << " " << No << " no alias responses (" << No*100/Sum << "%)\n" - << " " << May << " may alias responses (" << May*100/Sum << "%)\n" - << " " << Must << " must alias responses (" <(&getAnalysis())->getPassName(); return false; } virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AliasAnalysis::getAnalysisUsage(AU); AU.addRequired(); AU.setPreservesAll(); } - Result count(Result R) { + AliasResult count(AliasResult R) { switch (R) { default: assert(0 && "Unknown alias type!"); case NoAlias: No++; return NoAlias; @@ -48,17 +72,24 @@ namespace { case MustAlias: Must++; return MustAlias; } } + ModRefResult count(ModRefResult R) { + switch (R) { + default: assert(0 && "Unknown mod/ref type!"); + case NoModRef: NoMR++; return NoModRef; + case Ref: JustRef++; return Ref; + case Mod: JustMod++; return Mod; + case ModRef: MR++; return ModRef; + } + } // Forwarding functions: just delegate to a real AA implementation, counting // the number of responses... - Result alias(const Value *V1, const Value *V2) { - return count(getAnalysis().alias(V1, V2)); + AliasResult alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + return count(getAnalysis().alias(V1, V1Size, V2, V2Size)); } - Result canCallModify(const CallInst &CI, const Value *Ptr) { - return count(getAnalysis().canCallModify(CI, Ptr)); - } - Result canInvokeModify(const InvokeInst &I, const Value *Ptr) { - return count(getAnalysis().canInvokeModify(I, Ptr)); + ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) { + return count(getAnalysis().getModRefInfo(CS, P, Size)); } };