#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CommandLine.h"
-#include <iostream>
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Streams.h"
using namespace llvm;
namespace {
cl::opt<bool>
PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
- class AliasAnalysisCounter : public ModulePass, public AliasAnalysis {
+ class VISIBILITY_HIDDEN AliasAnalysisCounter
+ : public ModulePass, public AliasAnalysis {
unsigned No, May, Must;
unsigned NoMR, JustRef, JustMod, MR;
const char *Name;
Module *M;
public:
- AliasAnalysisCounter() {
+ static char ID; // Class identification, replacement for typeinfo
+ AliasAnalysisCounter() : ModulePass((intptr_t) &ID) {
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";
+ cerr << " " << Val << " " << Desc << " responses ("
+ << Val*100/Sum << "%)\n";
}
~AliasAnalysisCounter() {
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"
- << " " << AASum << " Total Alias Queries Performed\n";
+ cerr << "\n===== Alias Analysis Counter Report =====\n"
+ << " Analysis counted: " << Name << "\n"
+ << " " << AASum << " Total Alias Queries Performed\n";
if (AASum) {
printLine("no alias", No, AASum);
printLine("may alias", May, AASum);
printLine("must alias", Must, AASum);
- std::cerr
- << " Alias Analysis Counter Summary: " << No*100/AASum << "%/"
- << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n";
+ cerr << " Alias Analysis Counter Summary: " << No*100/AASum << "%/"
+ << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n";
}
- std::cerr
- << " " << MRSum << " Total Mod/Ref Queries Performed\n";
+ cerr << " " << MRSum << " Total Mod/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);
- std::cerr
- << " Mod/Ref Analysis Counter Summary: " << NoMR*100/MRSum<< "%/"
- << JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/"
- << MR*100/MRSum <<"%\n\n";
+ cerr << " Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum<< "%/"
+ << JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/"
+ << MR*100/MRSum <<"%\n\n";
}
}
}
}
};
+ char AliasAnalysisCounter::ID = 0;
RegisterPass<AliasAnalysisCounter>
X("count-aa", "Count Alias Analysis Query Responses");
RegisterAnalysisGroup<AliasAnalysis> Y(X);
}
if (PrintAll || (PrintAllFailures && R == MayAlias)) {
- std::cerr << AliasString << ":\t";
- std::cerr << "[" << V1Size << "B] ";
- WriteAsOperand(std::cerr, V1, true, true, M) << ", ";
- std::cerr << "[" << V2Size << "B] ";
- WriteAsOperand(std::cerr, V2, true, true, M) << "\n";
+ cerr << AliasString << ":\t";
+ cerr << "[" << V1Size << "B] ";
+ WriteAsOperand(*cerr.stream(), V1, true, M) << ", ";
+ cerr << "[" << V2Size << "B] ";
+ WriteAsOperand(*cerr.stream(), V2, true, M) << "\n";
}
return R;
}
if (PrintAll || (PrintAllFailures && R == ModRef)) {
- std::cerr << MRString << ": Ptr: ";
- std::cerr << "[" << Size << "B] ";
- WriteAsOperand(std::cerr, P, true, true, M);
- std::cerr << "\t<->" << *CS.getInstruction();
+ cerr << MRString << ": Ptr: ";
+ cerr << "[" << Size << "B] ";
+ WriteAsOperand(*cerr.stream(), P, true, M);
+ cerr << "\t<->" << *CS.getInstruction();
}
return R;
}