Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 1 | //===- AliasAnalysisEvaluator.cpp - Alias Analysis Accuracy Evaluator -----===// |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 2 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 7 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file implements a simple N^2 alias analysis accuracy evaluator. |
| 11 | // Basically, for each function in the program, it simply queries to see how the |
| 12 | // alias analysis implementation answers alias queries between each pair of |
| 13 | // pointers in the function. |
| 14 | // |
| 15 | // This is inspired and adapted from code by: Naveen Neelakantam, Francesco |
| 16 | // Spadini, and Wojciech Stryjewski. |
| 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
Chris Lattner | cfba798 | 2005-03-29 17:44:52 +0000 | [diff] [blame] | 20 | #include "llvm/Constants.h" |
| 21 | #include "llvm/DerivedTypes.h" |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 22 | #include "llvm/Function.h" |
Misha Brukman | 47b14a4 | 2004-07-29 17:30:56 +0000 | [diff] [blame] | 23 | #include "llvm/Instructions.h" |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 24 | #include "llvm/Pass.h" |
Jeff Cohen | 534927d | 2005-01-08 22:01:16 +0000 | [diff] [blame] | 25 | #include "llvm/Analysis/Passes.h" |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 26 | #include "llvm/Analysis/AliasAnalysis.h" |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 27 | #include "llvm/Assembly/Writer.h" |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 28 | #include "llvm/Target/TargetData.h" |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 29 | #include "llvm/Support/InstIterator.h" |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 30 | #include "llvm/Support/CommandLine.h" |
Reid Spencer | d7d83db | 2007-02-05 23:42:17 +0000 | [diff] [blame] | 31 | #include "llvm/Support/Compiler.h" |
Bill Wendling | 6f81b51 | 2006-11-28 22:46:12 +0000 | [diff] [blame] | 32 | #include "llvm/Support/Streams.h" |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 33 | #include <set> |
Gabor Greif | c0734e3 | 2008-02-28 08:38:45 +0000 | [diff] [blame] | 34 | #include <sstream> |
Chris Lattner | 9a4f8ef | 2003-12-10 15:33:59 +0000 | [diff] [blame] | 35 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 36 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 37 | static cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden); |
| 38 | |
| 39 | static cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden); |
| 40 | static cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden); |
| 41 | static cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden); |
| 42 | |
| 43 | static cl::opt<bool> PrintNoModRef("print-no-modref", cl::ReallyHidden); |
| 44 | static cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden); |
| 45 | static cl::opt<bool> PrintRef("print-ref", cl::ReallyHidden); |
| 46 | static cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden); |
| 47 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 48 | namespace { |
Reid Spencer | d7d83db | 2007-02-05 23:42:17 +0000 | [diff] [blame] | 49 | class VISIBILITY_HIDDEN AAEval : public FunctionPass { |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 50 | unsigned NoAlias, MayAlias, MustAlias; |
| 51 | unsigned NoModRef, Mod, Ref, ModRef; |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 52 | |
| 53 | public: |
Nick Lewycky | ecd94c8 | 2007-05-06 13:37:16 +0000 | [diff] [blame] | 54 | static char ID; // Pass identification, replacement for typeid |
Dan Gohman | ae73dc1 | 2008-09-04 17:05:41 +0000 | [diff] [blame] | 55 | AAEval() : FunctionPass(&ID) {} |
Devang Patel | 794fd75 | 2007-05-01 21:15:47 +0000 | [diff] [blame] | 56 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 57 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
| 58 | AU.addRequired<AliasAnalysis>(); |
| 59 | AU.setPreservesAll(); |
| 60 | } |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 61 | |
| 62 | bool doInitialization(Module &M) { |
| 63 | NoAlias = MayAlias = MustAlias = 0; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 64 | NoModRef = Mod = Ref = ModRef = 0; |
Chris Lattner | 0e872cb | 2004-07-17 06:28:49 +0000 | [diff] [blame] | 65 | |
| 66 | if (PrintAll) { |
| 67 | PrintNoAlias = PrintMayAlias = PrintMustAlias = true; |
| 68 | PrintNoModRef = PrintMod = PrintRef = PrintModRef = true; |
| 69 | } |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 70 | return false; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 73 | bool runOnFunction(Function &F); |
| 74 | bool doFinalization(Module &M); |
| 75 | }; |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 78 | char AAEval::ID = 0; |
| 79 | static RegisterPass<AAEval> |
| 80 | X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true); |
| 81 | |
Jeff Cohen | 534927d | 2005-01-08 22:01:16 +0000 | [diff] [blame] | 82 | FunctionPass *llvm::createAAEvalPass() { return new AAEval(); } |
| 83 | |
Gabor Greif | c0734e3 | 2008-02-28 08:38:45 +0000 | [diff] [blame] | 84 | static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2, |
| 85 | const Module *M) { |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 86 | if (P) { |
Gabor Greif | c0734e3 | 2008-02-28 08:38:45 +0000 | [diff] [blame] | 87 | std::stringstream s1, s2; |
| 88 | WriteAsOperand(s1, V1, true, M); |
| 89 | WriteAsOperand(s2, V2, true, M); |
| 90 | std::string o1(s1.str()), o2(s2.str()); |
| 91 | if (o2 < o1) |
| 92 | std::swap(o1, o2); |
| 93 | cerr << " " << Msg << ":\t" |
| 94 | << o1 << ", " |
| 95 | << o2 << "\n"; |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 99 | static inline void |
Chris Lattner | ad48cc7 | 2004-07-17 06:43:20 +0000 | [diff] [blame] | 100 | PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, |
| 101 | Module *M) { |
| 102 | if (P) { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 103 | cerr << " " << Msg << ": Ptr: "; |
Bill Wendling | bcd2498 | 2006-12-07 20:28:15 +0000 | [diff] [blame] | 104 | WriteAsOperand(*cerr.stream(), Ptr, true, M); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 105 | cerr << "\t<->" << *I; |
Chris Lattner | ad48cc7 | 2004-07-17 06:43:20 +0000 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 109 | bool AAEval::runOnFunction(Function &F) { |
| 110 | AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 111 | |
| 112 | const TargetData &TD = AA.getTargetData(); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 113 | |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 114 | std::set<Value *> Pointers; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 115 | std::set<CallSite> CallSites; |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 116 | |
Chris Lattner | e4d5c44 | 2005-03-15 04:54:21 +0000 | [diff] [blame] | 117 | for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 118 | if (isa<PointerType>(I->getType())) // Add all pointer arguments |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 119 | Pointers.insert(I); |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 120 | |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 121 | for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { |
Chris Lattner | 6ffe551 | 2004-04-27 15:13:33 +0000 | [diff] [blame] | 122 | if (isa<PointerType>(I->getType())) // Add all pointer instructions |
| 123 | Pointers.insert(&*I); |
Chris Lattner | ddc77c4 | 2005-03-17 20:25:04 +0000 | [diff] [blame] | 124 | Instruction &Inst = *I; |
| 125 | User::op_iterator OI = Inst.op_begin(); |
Gabor Greif | f73e319 | 2009-03-24 19:28:39 +0000 | [diff] [blame] | 126 | CallSite CS = CallSite::get(&Inst); |
| 127 | if (CS.getInstruction() && |
| 128 | isa<Function>(CS.getCalledValue())) |
Chris Lattner | ddc77c4 | 2005-03-17 20:25:04 +0000 | [diff] [blame] | 129 | ++OI; // Skip actual functions for direct function calls. |
| 130 | for (; OI != Inst.op_end(); ++OI) |
Chris Lattner | cfba798 | 2005-03-29 17:44:52 +0000 | [diff] [blame] | 131 | if (isa<PointerType>((*OI)->getType()) && !isa<ConstantPointerNull>(*OI)) |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 132 | Pointers.insert(*OI); |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 133 | |
Misha Brukman | 85f5e11 | 2004-03-12 16:20:49 +0000 | [diff] [blame] | 134 | if (CS.getInstruction()) CallSites.insert(CS); |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | if (PrintNoAlias || PrintMayAlias || PrintMustAlias || |
| 138 | PrintNoModRef || PrintMod || PrintRef || PrintModRef) |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 139 | cerr << "Function: " << F.getName() << ": " << Pointers.size() |
| 140 | << " pointers, " << CallSites.size() << " call sites\n"; |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 141 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 142 | // iterate over the worklist, and run the full (n^2)/2 disambiguations |
Chris Lattner | 1842a90 | 2003-06-29 00:07:11 +0000 | [diff] [blame] | 143 | for (std::set<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end(); |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 144 | I1 != E; ++I1) { |
| 145 | unsigned I1Size = 0; |
| 146 | const Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType(); |
Duncan Sands | 514ab34 | 2007-11-01 20:53:16 +0000 | [diff] [blame] | 147 | if (I1ElTy->isSized()) I1Size = TD.getTypeStoreSize(I1ElTy); |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 148 | |
| 149 | for (std::set<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2) { |
| 150 | unsigned I2Size = 0; |
| 151 | const Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType(); |
Duncan Sands | 514ab34 | 2007-11-01 20:53:16 +0000 | [diff] [blame] | 152 | if (I2ElTy->isSized()) I2Size = TD.getTypeStoreSize(I2ElTy); |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 153 | |
| 154 | switch (AA.alias(*I1, I1Size, *I2, I2Size)) { |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 155 | case AliasAnalysis::NoAlias: |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 156 | PrintResults("NoAlias", PrintNoAlias, *I1, *I2, F.getParent()); |
| 157 | ++NoAlias; break; |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 158 | case AliasAnalysis::MayAlias: |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 159 | PrintResults("MayAlias", PrintMayAlias, *I1, *I2, F.getParent()); |
| 160 | ++MayAlias; break; |
Chris Lattner | 638b381 | 2003-02-09 20:40:13 +0000 | [diff] [blame] | 161 | case AliasAnalysis::MustAlias: |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 162 | PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent()); |
| 163 | ++MustAlias; break; |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 164 | default: |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 165 | cerr << "Unknown alias query result!\n"; |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 166 | } |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 167 | } |
| 168 | } |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 169 | |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 170 | // Mod/ref alias analysis: compare all pairs of calls and values |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 171 | for (std::set<CallSite>::iterator C = CallSites.begin(), |
Chris Lattner | 0772e78 | 2005-03-26 22:16:44 +0000 | [diff] [blame] | 172 | Ce = CallSites.end(); C != Ce; ++C) { |
| 173 | Instruction *I = C->getInstruction(); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 174 | |
Chris Lattner | 0772e78 | 2005-03-26 22:16:44 +0000 | [diff] [blame] | 175 | for (std::set<Value *>::iterator V = Pointers.begin(), Ve = Pointers.end(); |
| 176 | V != Ve; ++V) { |
| 177 | unsigned Size = 0; |
| 178 | const Type *ElTy = cast<PointerType>((*V)->getType())->getElementType(); |
Duncan Sands | 514ab34 | 2007-11-01 20:53:16 +0000 | [diff] [blame] | 179 | if (ElTy->isSized()) Size = TD.getTypeStoreSize(ElTy); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 181 | switch (AA.getModRefInfo(*C, *V, Size)) { |
| 182 | case AliasAnalysis::NoModRef: |
| 183 | PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); |
| 184 | ++NoModRef; break; |
| 185 | case AliasAnalysis::Mod: |
| 186 | PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent()); |
| 187 | ++Mod; break; |
| 188 | case AliasAnalysis::Ref: |
| 189 | PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent()); |
| 190 | ++Ref; break; |
| 191 | case AliasAnalysis::ModRef: |
| 192 | PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); |
| 193 | ++ModRef; break; |
| 194 | default: |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 195 | cerr << "Unknown alias query result!\n"; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 196 | } |
Chris Lattner | 1ed80b6 | 2004-11-26 21:05:39 +0000 | [diff] [blame] | 197 | } |
Chris Lattner | cb19d67 | 2004-07-17 07:40:34 +0000 | [diff] [blame] | 198 | } |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 199 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 200 | return false; |
| 201 | } |
| 202 | |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 203 | static void PrintPercent(unsigned Num, unsigned Sum) { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 204 | cerr << "(" << Num*100ULL/Sum << "." |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 205 | << ((Num*1000ULL/Sum) % 10) << "%)\n"; |
| 206 | } |
| 207 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 208 | bool AAEval::doFinalization(Module &M) { |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 209 | unsigned AliasSum = NoAlias + MayAlias + MustAlias; |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 210 | cerr << "===== Alias Analysis Evaluator Report =====\n"; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 211 | if (AliasSum == 0) { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 212 | cerr << " Alias Analysis Evaluator Summary: No pointers!\n"; |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 213 | } else { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 214 | cerr << " " << AliasSum << " Total Alias Queries Performed\n"; |
| 215 | cerr << " " << NoAlias << " no alias responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 216 | PrintPercent(NoAlias, AliasSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 217 | cerr << " " << MayAlias << " may alias responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 218 | PrintPercent(MayAlias, AliasSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 219 | cerr << " " << MustAlias << " must alias responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 220 | PrintPercent(MustAlias, AliasSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 221 | cerr << " Alias Analysis Evaluator Pointer Alias Summary: " |
| 222 | << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/" |
| 223 | << MustAlias*100/AliasSum << "%\n"; |
Chris Lattner | 2c1d7cf | 2003-02-08 23:04:50 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 226 | // Display the summary for mod/ref analysis |
| 227 | unsigned ModRefSum = NoModRef + Mod + Ref + ModRef; |
| 228 | if (ModRefSum == 0) { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 229 | cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n"; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 230 | } else { |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 231 | cerr << " " << ModRefSum << " Total ModRef Queries Performed\n"; |
| 232 | cerr << " " << NoModRef << " no mod/ref responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 233 | PrintPercent(NoModRef, ModRefSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 234 | cerr << " " << Mod << " mod responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 235 | PrintPercent(Mod, ModRefSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 236 | cerr << " " << Ref << " ref responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 237 | PrintPercent(Ref, ModRefSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 238 | cerr << " " << ModRef << " mod & ref responses "; |
Chris Lattner | e70492d | 2005-03-26 23:56:33 +0000 | [diff] [blame] | 239 | PrintPercent(ModRef, ModRefSum); |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 240 | cerr << " Alias Analysis Evaluator Mod/Ref Summary: " |
| 241 | << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/" |
| 242 | << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n"; |
Misha Brukman | bc1dbe9 | 2004-03-12 06:15:08 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Chris Lattner | 9798ca5 | 2003-02-06 21:29:49 +0000 | [diff] [blame] | 245 | return false; |
| 246 | } |