[llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 9 14:41:00 PST 2003


Changes in directory llvm/lib/Analysis:

AliasAnalysisEvaluator.cpp updated: 1.3 -> 1.4

---
Log message:

Allow printing of various types of alias analysis results


---
Diffs of the changes:

Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp
diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.3 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.4
--- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.3	Sat Feb  8 17:04:50 2003
+++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp	Sun Feb  9 14:40:13 2003
@@ -13,10 +13,16 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Pass.h"
 #include "llvm/Function.h"
-#include "llvm/Support/InstIterator.h"
 #include "llvm/Type.h"
+#include "llvm/Support/InstIterator.h"
+#include "llvm/Assembly/Writer.h"
+#include "Support/CommandLine.h"
 
 namespace {
+  cl::opt<bool> PrintNo  ("print-no-alias-results", cl::ReallyHidden);
+  cl::opt<bool> PrintMay ("print-may-alias-results", cl::ReallyHidden);
+  cl::opt<bool> PrintMust("print-must-alias-results", cl::ReallyHidden);
+
   class AAEval : public FunctionPass {
     unsigned No, May, Must;
 
@@ -35,6 +41,14 @@
   X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator");
 }
 
+static inline void PrintResults(const char *Msg, bool P, Value *V1, Value *V2) {
+  if (P) {
+    std::cerr << "  " << Msg << ":\t";
+    WriteAsOperand(std::cerr, V1) << ", ";
+    WriteAsOperand(std::cerr, V2) << "\n";
+  }
+}
+
 bool AAEval::runOnFunction(Function &F) {
   AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
   
@@ -48,14 +62,23 @@
     if (isa<PointerType>((*I)->getType())) // Add all pointer instructions
       Pointers.push_back(*I);
 
+  if (PrintNo || PrintMay || PrintMust)
+    std::cerr << "Function: " << F.getName() << "\n";
+
   // iterate over the worklist, and run the full (n^2)/2 disambiguations
   for (std::vector<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
        I1 != E; ++I1)
     for (std::vector<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2)
       switch (AA.alias(*I1, *I2)) {
-      case AliasAnalysis::NoAlias:   ++No; break;
-      case AliasAnalysis::MayAlias:  ++May; break;
-      case AliasAnalysis::MustAlias: ++Must; break;
+      case AliasAnalysis::NoAlias:
+        PrintResults("No", PrintNo, *I1, *I2);
+        ++No; break;
+      case AliasAnalysis::MayAlias:
+        PrintResults("May", PrintMay, *I1, *I2);
+        ++May; break;
+      case AliasAnalysis::MustAlias:
+        PrintResults("Must", PrintMust, *I1, *I2);
+        ++Must; break;
       default:
         std::cerr << "Unknown alias query result!\n";
       }





More information about the llvm-commits mailing list