summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/AliasAnalysisCounter.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-08-14 02:05:41 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-08-14 02:05:41 +0000
commit7a9ba04809a8097cd474fa2c59f4fe6608aba0c2 (patch)
tree16b817cea477766b30b7eeb9a4f6c15c87b1d430 /llvm/lib/Analysis/AliasAnalysisCounter.cpp
parent1238f341bab1541d1160f156319d993be20489ac (diff)
downloadbcm5719-llvm-7a9ba04809a8097cd474fa2c59f4fe6608aba0c2.tar.gz
bcm5719-llvm-7a9ba04809a8097cd474fa2c59f4fe6608aba0c2.zip
[PM/AA] Hoist the AA counter pass into a header to match the analysis
pattern. Also hoist the creation routine out of the generic header and into the pass header now that we have one. I've worked to not make any changes, even formatting ones here. I'll clean up the formatting and other things in a follow-up patch now that the code is in the right place. llvm-svn: 245004
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysisCounter.cpp')
-rw-r--r--llvm/lib/Analysis/AliasAnalysisCounter.cpp93
1 files changed, 1 insertions, 92 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysisCounter.cpp b/llvm/lib/Analysis/AliasAnalysisCounter.cpp
index 6c53b41d3a1..821badeb42f 100644
--- a/llvm/lib/Analysis/AliasAnalysisCounter.cpp
+++ b/llvm/lib/Analysis/AliasAnalysisCounter.cpp
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Analysis/Passes.h"
+#include "llvm/Analysis/AliasAnalysisCounter.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
@@ -27,97 +27,6 @@ PrintAll("count-aa-print-all-queries", cl::ReallyHidden, cl::init(true));
static cl::opt<bool>
PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
-namespace {
- class AliasAnalysisCounter : public ModulePass, public AliasAnalysis {
- unsigned No, May, Partial, Must;
- unsigned NoMR, JustRef, JustMod, MR;
- Module *M;
- public:
- static char ID; // Class identification, replacement for typeinfo
- AliasAnalysisCounter() : ModulePass(ID) {
- initializeAliasAnalysisCounterPass(*PassRegistry::getPassRegistry());
- No = May = Partial = Must = 0;
- NoMR = JustRef = JustMod = MR = 0;
- }
-
- void printLine(const char *Desc, unsigned Val, unsigned Sum) {
- errs() << " " << Val << " " << Desc << " responses ("
- << Val*100/Sum << "%)\n";
- }
- ~AliasAnalysisCounter() override {
- unsigned AASum = No+May+Partial+Must;
- unsigned MRSum = NoMR+JustRef+JustMod+MR;
- if (AASum + MRSum) { // Print a report if any counted queries occurred...
- errs() << "\n===== Alias Analysis Counter Report =====\n"
- << " Analysis counted:\n"
- << " " << AASum << " Total Alias Queries Performed\n";
- if (AASum) {
- printLine("no alias", No, AASum);
- printLine("may alias", May, AASum);
- printLine("partial alias", Partial, AASum);
- printLine("must alias", Must, AASum);
- errs() << " Alias Analysis Counter Summary: " << No*100/AASum << "%/"
- << May*100/AASum << "%/"
- << Partial*100/AASum << "%/"
- << Must*100/AASum<<"%\n\n";
- }
-
- errs() << " " << MRSum << " Total MRI_Mod/MRI_Ref Queries Performed\n";
- if (MRSum) {
- printLine("no mod/ref", NoMR, MRSum);
- printLine("ref", JustRef, MRSum);
- printLine("mod", JustMod, MRSum);
- printLine("mod/ref", MR, MRSum);
- errs() << " MRI_Mod/MRI_Ref Analysis Counter Summary: "
- << NoMR * 100 / MRSum << "%/" << JustRef * 100 / MRSum << "%/"
- << JustMod * 100 / MRSum << "%/" << MR * 100 / MRSum
- << "%\n\n";
- }
- }
- }
-
- bool runOnModule(Module &M) override {
- this->M = &M;
- InitializeAliasAnalysis(this, &M.getDataLayout());
- return false;
- }
-
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AliasAnalysis::getAnalysisUsage(AU);
- AU.addRequired<AliasAnalysis>();
- AU.setPreservesAll();
- }
-
- /// getAdjustedAnalysisPointer - This method is used when a pass implements
- /// an analysis interface through multiple inheritance. If needed, it
- /// should override this to adjust the this pointer as needed for the
- /// specified pass info.
- void *getAdjustedAnalysisPointer(AnalysisID PI) override {
- if (PI == &AliasAnalysis::ID)
- return (AliasAnalysis*)this;
- return this;
- }
-
- // FIXME: We could count these too...
- bool pointsToConstantMemory(const MemoryLocation &Loc,
- bool OrLocal) override {
- return getAnalysis<AliasAnalysis>().pointsToConstantMemory(Loc, OrLocal);
- }
-
- // Forwarding functions: just delegate to a real AA implementation, counting
- // the number of responses...
- AliasResult alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB) override;
-
- ModRefInfo getModRefInfo(ImmutableCallSite CS,
- const MemoryLocation &Loc) override;
- ModRefInfo getModRefInfo(ImmutableCallSite CS1,
- ImmutableCallSite CS2) override {
- return AliasAnalysis::getModRefInfo(CS1,CS2);
- }
- };
-}
-
char AliasAnalysisCounter::ID = 0;
INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis, "count-aa",
"Count Alias Analysis Query Responses", false, true, false)
OpenPOWER on IntegriCloud