2003-02-06 22:29:49 +01:00
|
|
|
//===- AliasAnalysisEvaluator.cpp - Alias Analysis Accuracy Evaluator -----===//
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-02-06 22:29:49 +01:00
|
|
|
//
|
|
|
|
// This file implements a simple N^2 alias analysis accuracy evaluator.
|
|
|
|
// Basically, for each function in the program, it simply queries to see how the
|
|
|
|
// alias analysis implementation answers alias queries between each pair of
|
|
|
|
// pointers in the function.
|
|
|
|
//
|
|
|
|
// This is inspired and adapted from code by: Naveen Neelakantam, Francesco
|
|
|
|
// Spadini, and Wojciech Stryjewski.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/Analysis/Passes.h"
|
|
|
|
#include "llvm/ADT/SetVector.h"
|
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
|
|
|
#include "llvm/Assembly/Writer.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Constants.h"
|
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
2004-03-12 07:15:08 +01:00
|
|
|
#include "llvm/Pass.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-12-23 20:21:19 +01:00
|
|
|
#include "llvm/Support/Debug.h"
|
2004-03-12 07:15:08 +01:00
|
|
|
#include "llvm/Support/InstIterator.h"
|
2009-07-25 02:23:56 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2003-12-10 16:33:59 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
static cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
|
2004-07-17 08:28:49 +02:00
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
static cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden);
|
|
|
|
static cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden);
|
2010-12-10 20:52:40 +01:00
|
|
|
static cl::opt<bool> PrintPartialAlias("print-partial-aliases", cl::ReallyHidden);
|
2008-05-13 02:00:25 +02:00
|
|
|
static cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden);
|
2004-03-12 07:15:08 +01:00
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
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);
|
2003-02-09 21:40:13 +01:00
|
|
|
|
2013-03-22 23:34:41 +01:00
|
|
|
static cl::opt<bool> EvalTBAA("evaluate-tbaa", cl::ReallyHidden);
|
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
namespace {
|
2010-07-07 16:27:09 +02:00
|
|
|
class AAEval : public FunctionPass {
|
2010-12-10 20:52:40 +01:00
|
|
|
unsigned NoAlias, MayAlias, PartialAlias, MustAlias;
|
2004-03-12 07:15:08 +01:00
|
|
|
unsigned NoModRef, Mod, Ref, ModRef;
|
2003-02-06 22:29:49 +01:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
public:
|
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2010-10-19 19:21:58 +02:00
|
|
|
AAEval() : FunctionPass(ID) {
|
|
|
|
initializeAAEvalPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2007-05-01 23:15:47 +02:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
2003-02-06 22:29:49 +01:00
|
|
|
AU.addRequired<AliasAnalysis>();
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
bool doInitialization(Module &M) {
|
2010-12-10 20:52:40 +01:00
|
|
|
NoAlias = MayAlias = PartialAlias = MustAlias = 0;
|
2004-03-12 07:15:08 +01:00
|
|
|
NoModRef = Mod = Ref = ModRef = 0;
|
2004-07-17 08:28:49 +02:00
|
|
|
|
|
|
|
if (PrintAll) {
|
2010-12-10 20:52:40 +01:00
|
|
|
PrintNoAlias = PrintMayAlias = true;
|
|
|
|
PrintPartialAlias = PrintMustAlias = true;
|
2004-07-17 08:28:49 +02:00
|
|
|
PrintNoModRef = PrintMod = PrintRef = PrintModRef = true;
|
|
|
|
}
|
2005-04-21 23:13:18 +02:00
|
|
|
return false;
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
bool runOnFunction(Function &F);
|
|
|
|
bool doFinalization(Module &M);
|
2003-02-06 22:29:49 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
char AAEval::ID = 0;
|
2010-10-12 21:48:12 +02:00
|
|
|
INITIALIZE_PASS_BEGIN(AAEval, "aa-eval",
|
|
|
|
"Exhaustive Alias Analysis Precision Evaluator", false, true)
|
|
|
|
INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
|
|
|
|
INITIALIZE_PASS_END(AAEval, "aa-eval",
|
2010-10-08 00:25:06 +02:00
|
|
|
"Exhaustive Alias Analysis Precision Evaluator", false, true)
|
2008-05-13 02:00:25 +02:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
|
2005-01-08 23:01:16 +01:00
|
|
|
|
2009-08-23 07:17:37 +02:00
|
|
|
static void PrintResults(const char *Msg, bool P, const Value *V1,
|
|
|
|
const Value *V2, const Module *M) {
|
2003-02-09 21:40:13 +01:00
|
|
|
if (P) {
|
2009-08-23 07:17:37 +02:00
|
|
|
std::string o1, o2;
|
|
|
|
{
|
|
|
|
raw_string_ostream os1(o1), os2(o2);
|
|
|
|
WriteAsOperand(os1, V1, true, M);
|
|
|
|
WriteAsOperand(os2, V2, true, M);
|
|
|
|
}
|
|
|
|
|
2008-02-28 09:38:45 +01:00
|
|
|
if (o2 < o1)
|
2009-07-25 02:23:56 +02:00
|
|
|
std::swap(o1, o2);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << Msg << ":\t"
|
2009-07-25 02:23:56 +02:00
|
|
|
<< o1 << ", "
|
|
|
|
<< o2 << "\n";
|
2003-02-09 21:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-21 23:13:18 +02:00
|
|
|
static inline void
|
2004-07-17 08:43:20 +02:00
|
|
|
PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr,
|
|
|
|
Module *M) {
|
|
|
|
if (P) {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << Msg << ": Ptr: ";
|
|
|
|
WriteAsOperand(errs(), Ptr, true, M);
|
|
|
|
errs() << "\t<->" << *I << '\n';
|
2004-07-17 08:43:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-05 00:56:29 +02:00
|
|
|
static inline void
|
|
|
|
PrintModRefResults(const char *Msg, bool P, CallSite CSA, CallSite CSB,
|
|
|
|
Module *M) {
|
|
|
|
if (P) {
|
|
|
|
errs() << " " << Msg << ": " << *CSA.getInstruction()
|
|
|
|
<< " <-> " << *CSB.getInstruction() << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 23:34:41 +01:00
|
|
|
static inline void
|
|
|
|
PrintLoadStoreResults(const char *Msg, bool P, const Value *V1,
|
|
|
|
const Value *V2, const Module *M) {
|
|
|
|
if (P) {
|
|
|
|
errs() << " " << Msg << ": " << *V1
|
|
|
|
<< " <-> " << *V2 << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-08 18:46:24 +02:00
|
|
|
static inline bool isInterestingPointer(Value *V) {
|
|
|
|
return V->getType()->isPointerTy()
|
|
|
|
&& !isa<ConstantPointerNull>(V);
|
|
|
|
}
|
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
bool AAEval::runOnFunction(Function &F) {
|
|
|
|
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
|
|
|
|
|
|
|
SetVector<Value *> Pointers;
|
|
|
|
SetVector<CallSite> CallSites;
|
2013-03-22 23:34:41 +01:00
|
|
|
SetVector<Value *> Loads;
|
|
|
|
SetVector<Value *> Stores;
|
2010-07-07 16:27:09 +02:00
|
|
|
|
2005-03-15 05:54:21 +01:00
|
|
|
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I)
|
2010-04-08 18:46:24 +02:00
|
|
|
if (I->getType()->isPointerTy()) // Add all pointer arguments.
|
2003-06-29 02:07:11 +02:00
|
|
|
Pointers.insert(I);
|
2003-02-06 22:29:49 +01:00
|
|
|
|
2003-06-29 02:07:11 +02:00
|
|
|
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
2010-04-08 18:46:24 +02:00
|
|
|
if (I->getType()->isPointerTy()) // Add all pointer instructions.
|
2004-04-27 17:13:33 +02:00
|
|
|
Pointers.insert(&*I);
|
2013-03-22 23:34:41 +01:00
|
|
|
if (EvalTBAA && isa<LoadInst>(&*I))
|
|
|
|
Loads.insert(&*I);
|
|
|
|
if (EvalTBAA && isa<StoreInst>(&*I))
|
|
|
|
Stores.insert(&*I);
|
2005-03-17 21:25:04 +01:00
|
|
|
Instruction &Inst = *I;
|
2010-07-28 17:31:37 +02:00
|
|
|
if (CallSite CS = cast<Value>(&Inst)) {
|
2010-04-08 18:46:24 +02:00
|
|
|
Value *Callee = CS.getCalledValue();
|
|
|
|
// Skip actual functions for direct function calls.
|
|
|
|
if (!isa<Function>(Callee) && isInterestingPointer(Callee))
|
|
|
|
Pointers.insert(Callee);
|
|
|
|
// Consider formals.
|
|
|
|
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
|
|
|
AI != AE; ++AI)
|
|
|
|
if (isInterestingPointer(*AI))
|
|
|
|
Pointers.insert(*AI);
|
2010-07-28 17:31:37 +02:00
|
|
|
CallSites.insert(CS);
|
2010-04-08 18:46:24 +02:00
|
|
|
} else {
|
|
|
|
// Consider all operands.
|
|
|
|
for (Instruction::op_iterator OI = Inst.op_begin(), OE = Inst.op_end();
|
|
|
|
OI != OE; ++OI)
|
|
|
|
if (isInterestingPointer(*OI))
|
|
|
|
Pointers.insert(*OI);
|
|
|
|
}
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
|
|
|
|
2010-12-10 20:52:40 +01:00
|
|
|
if (PrintNoAlias || PrintMayAlias || PrintPartialAlias || PrintMustAlias ||
|
2010-07-07 16:27:09 +02:00
|
|
|
PrintNoModRef || PrintMod || PrintRef || PrintModRef)
|
|
|
|
errs() << "Function: " << F.getName() << ": " << Pointers.size()
|
|
|
|
<< " pointers, " << CallSites.size() << " call sites\n";
|
2003-02-09 21:40:13 +01:00
|
|
|
|
2003-02-06 22:29:49 +01:00
|
|
|
// iterate over the worklist, and run the full (n^2)/2 disambiguations
|
2009-08-26 16:32:17 +02:00
|
|
|
for (SetVector<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
|
2004-11-26 22:05:39 +01:00
|
|
|
I1 != E; ++I1) {
|
2010-10-20 00:54:46 +02:00
|
|
|
uint64_t I1Size = AliasAnalysis::UnknownSize;
|
2011-07-18 06:54:35 +02:00
|
|
|
Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
|
2010-07-07 16:27:09 +02:00
|
|
|
if (I1ElTy->isSized()) I1Size = AA.getTypeStoreSize(I1ElTy);
|
2004-11-26 22:05:39 +01:00
|
|
|
|
2009-08-26 16:32:17 +02:00
|
|
|
for (SetVector<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2) {
|
2010-10-20 00:54:46 +02:00
|
|
|
uint64_t I2Size = AliasAnalysis::UnknownSize;
|
2011-07-18 06:54:35 +02:00
|
|
|
Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType();
|
2010-07-07 16:27:09 +02:00
|
|
|
if (I2ElTy->isSized()) I2Size = AA.getTypeStoreSize(I2ElTy);
|
2004-11-26 22:05:39 +01:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
switch (AA.alias(*I1, I1Size, *I2, I2Size)) {
|
2003-02-09 21:40:13 +01:00
|
|
|
case AliasAnalysis::NoAlias:
|
2010-07-07 16:27:09 +02:00
|
|
|
PrintResults("NoAlias", PrintNoAlias, *I1, *I2, F.getParent());
|
2004-03-12 07:15:08 +01:00
|
|
|
++NoAlias; break;
|
2003-02-09 21:40:13 +01:00
|
|
|
case AliasAnalysis::MayAlias:
|
2010-07-07 16:27:09 +02:00
|
|
|
PrintResults("MayAlias", PrintMayAlias, *I1, *I2, F.getParent());
|
2004-03-12 07:15:08 +01:00
|
|
|
++MayAlias; break;
|
2010-12-10 20:52:40 +01:00
|
|
|
case AliasAnalysis::PartialAlias:
|
|
|
|
PrintResults("PartialAlias", PrintPartialAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++PartialAlias; break;
|
2003-02-09 21:40:13 +01:00
|
|
|
case AliasAnalysis::MustAlias:
|
2010-07-07 16:27:09 +02:00
|
|
|
PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent());
|
2004-03-12 07:15:08 +01:00
|
|
|
++MustAlias; break;
|
2003-02-06 22:29:49 +01:00
|
|
|
}
|
2004-11-26 22:05:39 +01:00
|
|
|
}
|
|
|
|
}
|
2003-02-06 22:29:49 +01:00
|
|
|
|
2013-03-22 23:34:41 +01:00
|
|
|
if (EvalTBAA) {
|
|
|
|
// iterate over all pairs of load, store
|
|
|
|
for (SetVector<Value *>::iterator I1 = Loads.begin(), E = Loads.end();
|
|
|
|
I1 != E; ++I1) {
|
|
|
|
for (SetVector<Value *>::iterator I2 = Stores.begin(), E2 = Stores.end();
|
|
|
|
I2 != E2; ++I2) {
|
|
|
|
switch (AA.alias(AA.getLocation(cast<LoadInst>(*I1)),
|
|
|
|
AA.getLocation(cast<StoreInst>(*I2)))) {
|
|
|
|
case AliasAnalysis::NoAlias:
|
|
|
|
PrintLoadStoreResults("NoAlias", PrintNoAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++NoAlias; break;
|
|
|
|
case AliasAnalysis::MayAlias:
|
|
|
|
PrintLoadStoreResults("MayAlias", PrintMayAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++MayAlias; break;
|
|
|
|
case AliasAnalysis::PartialAlias:
|
|
|
|
PrintLoadStoreResults("PartialAlias", PrintPartialAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++PartialAlias; break;
|
|
|
|
case AliasAnalysis::MustAlias:
|
|
|
|
PrintLoadStoreResults("MustAlias", PrintMustAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++MustAlias; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// iterate over all pairs of store, store
|
|
|
|
for (SetVector<Value *>::iterator I1 = Stores.begin(), E = Stores.end();
|
|
|
|
I1 != E; ++I1) {
|
|
|
|
for (SetVector<Value *>::iterator I2 = Stores.begin(); I2 != I1; ++I2) {
|
|
|
|
switch (AA.alias(AA.getLocation(cast<StoreInst>(*I1)),
|
|
|
|
AA.getLocation(cast<StoreInst>(*I2)))) {
|
|
|
|
case AliasAnalysis::NoAlias:
|
|
|
|
PrintLoadStoreResults("NoAlias", PrintNoAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++NoAlias; break;
|
|
|
|
case AliasAnalysis::MayAlias:
|
|
|
|
PrintLoadStoreResults("MayAlias", PrintMayAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++MayAlias; break;
|
|
|
|
case AliasAnalysis::PartialAlias:
|
|
|
|
PrintLoadStoreResults("PartialAlias", PrintPartialAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++PartialAlias; break;
|
|
|
|
case AliasAnalysis::MustAlias:
|
|
|
|
PrintLoadStoreResults("MustAlias", PrintMustAlias, *I1, *I2,
|
|
|
|
F.getParent());
|
|
|
|
++MustAlias; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-12 07:15:08 +01:00
|
|
|
// Mod/ref alias analysis: compare all pairs of calls and values
|
2009-08-26 16:32:17 +02:00
|
|
|
for (SetVector<CallSite>::iterator C = CallSites.begin(),
|
2005-03-26 23:16:44 +01:00
|
|
|
Ce = CallSites.end(); C != Ce; ++C) {
|
|
|
|
Instruction *I = C->getInstruction();
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2009-08-26 16:32:17 +02:00
|
|
|
for (SetVector<Value *>::iterator V = Pointers.begin(), Ve = Pointers.end();
|
2005-03-26 23:16:44 +01:00
|
|
|
V != Ve; ++V) {
|
2010-10-20 00:54:46 +02:00
|
|
|
uint64_t Size = AliasAnalysis::UnknownSize;
|
2011-07-18 06:54:35 +02:00
|
|
|
Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
|
2010-07-07 16:27:09 +02:00
|
|
|
if (ElTy->isSized()) Size = AA.getTypeStoreSize(ElTy);
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
switch (AA.getModRefInfo(*C, *V, Size)) {
|
2004-11-26 22:05:39 +01:00
|
|
|
case AliasAnalysis::NoModRef:
|
2010-07-07 16:27:09 +02:00
|
|
|
PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent());
|
2004-11-26 22:05:39 +01:00
|
|
|
++NoModRef; break;
|
|
|
|
case AliasAnalysis::Mod:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Just Mod", PrintMod, I, *V, F.getParent());
|
2004-11-26 22:05:39 +01:00
|
|
|
++Mod; break;
|
|
|
|
case AliasAnalysis::Ref:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Just Ref", PrintRef, I, *V, F.getParent());
|
2004-11-26 22:05:39 +01:00
|
|
|
++Ref; break;
|
|
|
|
case AliasAnalysis::ModRef:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Both ModRef", PrintModRef, I, *V, F.getParent());
|
2004-11-26 22:05:39 +01:00
|
|
|
++ModRef; break;
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
2004-11-26 22:05:39 +01:00
|
|
|
}
|
2004-07-17 09:40:34 +02:00
|
|
|
}
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2010-08-05 00:56:29 +02:00
|
|
|
// Mod/ref alias analysis: compare all pairs of calls
|
|
|
|
for (SetVector<CallSite>::iterator C = CallSites.begin(),
|
|
|
|
Ce = CallSites.end(); C != Ce; ++C) {
|
|
|
|
for (SetVector<CallSite>::iterator D = CallSites.begin(); D != Ce; ++D) {
|
|
|
|
if (D == C)
|
|
|
|
continue;
|
|
|
|
switch (AA.getModRefInfo(*C, *D)) {
|
|
|
|
case AliasAnalysis::NoModRef:
|
|
|
|
PrintModRefResults("NoModRef", PrintNoModRef, *C, *D, F.getParent());
|
|
|
|
++NoModRef; break;
|
|
|
|
case AliasAnalysis::Mod:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Just Mod", PrintMod, *C, *D, F.getParent());
|
2010-08-05 00:56:29 +02:00
|
|
|
++Mod; break;
|
|
|
|
case AliasAnalysis::Ref:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Just Ref", PrintRef, *C, *D, F.getParent());
|
2010-08-05 00:56:29 +02:00
|
|
|
++Ref; break;
|
|
|
|
case AliasAnalysis::ModRef:
|
2010-08-05 01:37:55 +02:00
|
|
|
PrintModRefResults("Both ModRef", PrintModRef, *C, *D, F.getParent());
|
2010-08-05 00:56:29 +02:00
|
|
|
++ModRef; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
return false;
|
2003-02-06 22:29:49 +01:00
|
|
|
}
|
|
|
|
|
2005-03-27 00:56:33 +01:00
|
|
|
static void PrintPercent(unsigned Num, unsigned Sum) {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << "(" << Num*100ULL/Sum << "."
|
2009-07-25 02:23:56 +02:00
|
|
|
<< ((Num*1000ULL/Sum) % 10) << "%)\n";
|
2005-03-27 00:56:33 +01:00
|
|
|
}
|
|
|
|
|
2010-07-07 16:27:09 +02:00
|
|
|
bool AAEval::doFinalization(Module &M) {
|
2010-12-10 20:52:40 +01:00
|
|
|
unsigned AliasSum = NoAlias + MayAlias + PartialAlias + MustAlias;
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << "===== Alias Analysis Evaluator Report =====\n";
|
2004-03-12 07:15:08 +01:00
|
|
|
if (AliasSum == 0) {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Evaluator Summary: No pointers!\n";
|
2005-04-21 23:13:18 +02:00
|
|
|
} else {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << AliasSum << " Total Alias Queries Performed\n";
|
|
|
|
errs() << " " << NoAlias << " no alias responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(NoAlias, AliasSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << MayAlias << " may alias responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(MayAlias, AliasSum);
|
2010-12-10 20:52:40 +01:00
|
|
|
errs() << " " << PartialAlias << " partial alias responses ";
|
|
|
|
PrintPercent(PartialAlias, AliasSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << MustAlias << " must alias responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(MustAlias, AliasSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Evaluator Pointer Alias Summary: "
|
2009-07-25 02:23:56 +02:00
|
|
|
<< NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/"
|
2010-12-10 20:52:40 +01:00
|
|
|
<< PartialAlias*100/AliasSum << "%/"
|
2009-07-25 02:23:56 +02:00
|
|
|
<< MustAlias*100/AliasSum << "%\n";
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the summary for mod/ref analysis
|
|
|
|
unsigned ModRefSum = NoModRef + Mod + Ref + ModRef;
|
|
|
|
if (ModRefSum == 0) {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
|
2004-03-12 07:15:08 +01:00
|
|
|
} else {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << ModRefSum << " Total ModRef Queries Performed\n";
|
|
|
|
errs() << " " << NoModRef << " no mod/ref responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(NoModRef, ModRefSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << Mod << " mod responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(Mod, ModRefSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << Ref << " ref responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(Ref, ModRefSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << ModRef << " mod & ref responses ";
|
2005-03-27 00:56:33 +01:00
|
|
|
PrintPercent(ModRef, ModRefSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Evaluator Mod/Ref Summary: "
|
2009-07-25 02:23:56 +02:00
|
|
|
<< NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/"
|
|
|
|
<< Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n";
|
2003-02-09 00:04:50 +01:00
|
|
|
}
|
2010-07-07 16:27:09 +02:00
|
|
|
|
|
|
|
return false;
|
2003-02-06 22:29:49 +01:00
|
|
|
}
|