//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Streams.h"
#include <set>
+#include <sstream>
using namespace llvm;
-namespace {
- cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
+static cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
- cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden);
- cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden);
- cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden);
+static cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden);
+static cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden);
+static cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden);
- cl::opt<bool> PrintNoModRef("print-no-modref", cl::ReallyHidden);
- cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden);
- cl::opt<bool> PrintRef("print-ref", cl::ReallyHidden);
- cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden);
+static cl::opt<bool> PrintNoModRef("print-no-modref", cl::ReallyHidden);
+static cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden);
+static cl::opt<bool> PrintRef("print-ref", cl::ReallyHidden);
+static cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden);
+namespace {
class VISIBILITY_HIDDEN AAEval : public FunctionPass {
unsigned NoAlias, MayAlias, MustAlias;
unsigned NoModRef, Mod, Ref, ModRef;
public:
static char ID; // Pass identification, replacement for typeid
- AAEval() : FunctionPass((intptr_t)&ID) {}
+ AAEval() : FunctionPass(&ID) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AliasAnalysis>();
bool runOnFunction(Function &F);
bool doFinalization(Module &M);
};
-
- char AAEval::ID = 0;
- RegisterPass<AAEval>
- X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator");
}
+char AAEval::ID = 0;
+static RegisterPass<AAEval>
+X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
+
FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
-static inline void PrintResults(const char *Msg, bool P, Value *V1, Value *V2,
- Module *M) {
+static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2,
+ const Module *M) {
if (P) {
- cerr << " " << Msg << ":\t";
- WriteAsOperand(*cerr.stream(), V1, true, M) << ", ";
- WriteAsOperand(*cerr.stream(), V2, true, M) << "\n";
+ std::stringstream s1, s2;
+ WriteAsOperand(s1, V1, true, M);
+ WriteAsOperand(s2, V2, true, M);
+ std::string o1(s1.str()), o2(s2.str());
+ if (o2 < o1)
+ std::swap(o1, o2);
+ cerr << " " << Msg << ":\t"
+ << o1 << ", "
+ << o2 << "\n";
}
}