Allow counting multiple passes, and print the pass name counted

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5504 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-02-07 20:39:17 +00:00
parent 70e332d34b
commit a89feb55e0

View File

@ -10,10 +10,31 @@
#include <iostream>
namespace {
unsigned No = 0, May = 0, Must = 0;
class AliasAnalysisCounter : public Pass, public AliasAnalysis {
unsigned No, May, Must;
const char *Name;
public:
AliasAnalysisCounter() : No(0), May(0), Must(0) {}
~AliasAnalysisCounter() {
unsigned Sum = No+May+Must;
if (Sum) { // 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 (" <<Must*100/Sum<<"%)\n"
<< " Alias Analysis Counter Summary: " << No*100/Sum << "%/"
<< May*100/Sum << "%/" << Must*100/Sum<<"%\n\n";
}
}
bool run(Module &M) {
Name = dynamic_cast<Pass*>(&getAnalysis<AliasAnalysis>())->getPassName();
return false;
}
struct AliasAnalysisCounter : public Pass, public AliasAnalysis {
bool run(Module &M) { return false; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AliasAnalysis>();
AU.setPreservesAll();
@ -44,21 +65,4 @@ namespace {
RegisterOpt<AliasAnalysisCounter>
X("count-aa", "Count Alias Analysis Query Responses");
RegisterAnalysisGroup<AliasAnalysis, AliasAnalysisCounter> Y;
struct ResultPrinter {
~ResultPrinter() {
unsigned Sum = No+May+Must;
if (Sum) { // Print a report if any counted queries occurred...
std::cerr
<< "\n===== Alias Analysis Counter Report =====\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 (" <<Must*100/Sum<<"%)\n"
<< " Alias Analysis Counter Summary: " << No*100/Sum << "%/"
<< May*100/Sum << "%/" << Must*100/Sum<<"%\n\n";
}
}
} RP;
}