2003-02-06 21:29:49 +00:00
|
|
|
//===- AliasAnalysisEvaluator.cpp - Alias Analysis Accuracy Evaluator -----===//
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-02-06 21:29:49 +00: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2005-03-29 17:44:52 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
2003-02-06 21:29:49 +00:00
|
|
|
#include "llvm/Function.h"
|
2004-07-29 17:30:56 +00:00
|
|
|
#include "llvm/Instructions.h"
|
2004-03-12 06:15:08 +00:00
|
|
|
#include "llvm/Pass.h"
|
2005-01-08 22:01:16 +00:00
|
|
|
#include "llvm/Analysis/Passes.h"
|
2004-03-12 06:15:08 +00:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2003-02-09 20:40:13 +00:00
|
|
|
#include "llvm/Assembly/Writer.h"
|
2004-11-26 21:05:39 +00:00
|
|
|
#include "llvm/Target/TargetData.h"
|
2004-03-12 06:15:08 +00:00
|
|
|
#include "llvm/Support/InstIterator.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2007-02-05 23:42:17 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2006-11-28 22:46:12 +00:00
|
|
|
#include "llvm/Support/Streams.h"
|
2003-06-29 00:07:11 +00:00
|
|
|
#include <set>
|
2008-02-28 08:38:45 +00:00
|
|
|
#include <sstream>
|
2003-12-10 15:33:59 +00:00
|
|
|
using namespace llvm;
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
namespace {
|
2004-07-17 06:28:49 +00:00
|
|
|
cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
|
|
|
|
|
2004-03-12 06:15:08 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
2003-02-09 20:40:13 +00:00
|
|
|
|
2007-02-05 23:42:17 +00:00
|
|
|
class VISIBILITY_HIDDEN AAEval : public FunctionPass {
|
2004-03-12 06:15:08 +00:00
|
|
|
unsigned NoAlias, MayAlias, MustAlias;
|
|
|
|
unsigned NoModRef, Mod, Ref, ModRef;
|
2003-02-06 21:29:49 +00:00
|
|
|
|
|
|
|
public:
|
2007-05-06 13:37:16 +00:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2008-03-19 21:56:59 +00:00
|
|
|
AAEval() : FunctionPass((intptr_t)&ID) {}
|
2007-05-01 21:15:47 +00:00
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.addRequired<AliasAnalysis>();
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2005-04-21 21:13:18 +00:00
|
|
|
|
|
|
|
bool doInitialization(Module &M) {
|
|
|
|
NoAlias = MayAlias = MustAlias = 0;
|
2004-03-12 06:15:08 +00:00
|
|
|
NoModRef = Mod = Ref = ModRef = 0;
|
2004-07-17 06:28:49 +00:00
|
|
|
|
|
|
|
if (PrintAll) {
|
|
|
|
PrintNoAlias = PrintMayAlias = PrintMustAlias = true;
|
|
|
|
PrintNoModRef = PrintMod = PrintRef = PrintModRef = true;
|
|
|
|
}
|
2005-04-21 21:13:18 +00:00
|
|
|
return false;
|
2004-03-12 06:15:08 +00:00
|
|
|
}
|
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
bool runOnFunction(Function &F);
|
|
|
|
bool doFinalization(Module &M);
|
|
|
|
};
|
|
|
|
|
2007-05-03 01:11:54 +00:00
|
|
|
char AAEval::ID = 0;
|
2006-08-27 22:42:52 +00:00
|
|
|
RegisterPass<AAEval>
|
2008-03-20 02:25:21 +00:00
|
|
|
X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
|
2003-02-06 21:29:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-08 22:01:16 +00:00
|
|
|
FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
|
|
|
|
|
2008-02-28 08:38:45 +00:00
|
|
|
static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2,
|
|
|
|
const Module *M) {
|
2003-02-09 20:40:13 +00:00
|
|
|
if (P) {
|
2008-02-28 08:38:45 +00:00
|
|
|
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";
|
2003-02-09 20:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-21 21:13:18 +00:00
|
|
|
static inline void
|
2004-07-17 06:43:20 +00:00
|
|
|
PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr,
|
|
|
|
Module *M) {
|
|
|
|
if (P) {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << Msg << ": Ptr: ";
|
2006-12-07 20:28:15 +00:00
|
|
|
WriteAsOperand(*cerr.stream(), Ptr, true, M);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "\t<->" << *I;
|
2004-07-17 06:43:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
bool AAEval::runOnFunction(Function &F) {
|
|
|
|
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
2004-11-26 21:05:39 +00:00
|
|
|
|
|
|
|
const TargetData &TD = AA.getTargetData();
|
2005-04-21 21:13:18 +00:00
|
|
|
|
2003-06-29 00:07:11 +00:00
|
|
|
std::set<Value *> Pointers;
|
2004-03-12 06:15:08 +00:00
|
|
|
std::set<CallSite> CallSites;
|
2003-02-06 21:29:49 +00:00
|
|
|
|
2005-03-15 04:54:21 +00:00
|
|
|
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I)
|
2003-02-06 21:29:49 +00:00
|
|
|
if (isa<PointerType>(I->getType())) // Add all pointer arguments
|
2003-06-29 00:07:11 +00:00
|
|
|
Pointers.insert(I);
|
2003-02-06 21:29:49 +00:00
|
|
|
|
2003-06-29 00:07:11 +00:00
|
|
|
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
2004-04-27 15:13:33 +00:00
|
|
|
if (isa<PointerType>(I->getType())) // Add all pointer instructions
|
|
|
|
Pointers.insert(&*I);
|
2005-03-17 20:25:04 +00:00
|
|
|
Instruction &Inst = *I;
|
|
|
|
User::op_iterator OI = Inst.op_begin();
|
|
|
|
if ((isa<InvokeInst>(Inst) || isa<CallInst>(Inst)) &&
|
|
|
|
isa<Function>(Inst.getOperand(0)))
|
|
|
|
++OI; // Skip actual functions for direct function calls.
|
|
|
|
for (; OI != Inst.op_end(); ++OI)
|
2005-03-29 17:44:52 +00:00
|
|
|
if (isa<PointerType>((*OI)->getType()) && !isa<ConstantPointerNull>(*OI))
|
2003-06-29 00:07:11 +00:00
|
|
|
Pointers.insert(*OI);
|
2003-02-06 21:29:49 +00:00
|
|
|
|
2004-04-27 15:13:33 +00:00
|
|
|
CallSite CS = CallSite::get(&*I);
|
2004-03-12 16:20:49 +00:00
|
|
|
if (CS.getInstruction()) CallSites.insert(CS);
|
2004-03-12 06:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PrintNoAlias || PrintMayAlias || PrintMustAlias ||
|
|
|
|
PrintNoModRef || PrintMod || PrintRef || PrintModRef)
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "Function: " << F.getName() << ": " << Pointers.size()
|
|
|
|
<< " pointers, " << CallSites.size() << " call sites\n";
|
2003-02-09 20:40:13 +00:00
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
// iterate over the worklist, and run the full (n^2)/2 disambiguations
|
2003-06-29 00:07:11 +00:00
|
|
|
for (std::set<Value *>::iterator I1 = Pointers.begin(), E = Pointers.end();
|
2004-11-26 21:05:39 +00:00
|
|
|
I1 != E; ++I1) {
|
|
|
|
unsigned I1Size = 0;
|
|
|
|
const Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
|
Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment. This gives a primitive type for
which getTypeSize differed from getABITypeSize. For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).
This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition). Instead there is:
(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type. For a primitive type, this is the minimum number
of bits. For an i36 this is 36 bits. For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.
(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it). For an
i36 this is 40 bits, for an x86 long double it is 80 bits. This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes). There doesn't seem to be anything
corresponding to this in gcc.
(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment. For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS. This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes). This is
TYPE_SIZE in gcc.
Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize. This means that the size of an array
is the length times the getABITypeSize. It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize. Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case. So alloca's and mallocs should use getABITypeSize. Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.
Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.
In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases). I will get around to auditing these too at some point,
but I could do with some help.
Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize. I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers. If someone wants to pack these types more
tightly they can always use a packed struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
|
|
|
if (I1ElTy->isSized()) I1Size = TD.getTypeStoreSize(I1ElTy);
|
2004-11-26 21:05:39 +00:00
|
|
|
|
|
|
|
for (std::set<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2) {
|
|
|
|
unsigned I2Size = 0;
|
|
|
|
const Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType();
|
Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment. This gives a primitive type for
which getTypeSize differed from getABITypeSize. For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).
This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition). Instead there is:
(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type. For a primitive type, this is the minimum number
of bits. For an i36 this is 36 bits. For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.
(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it). For an
i36 this is 40 bits, for an x86 long double it is 80 bits. This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes). There doesn't seem to be anything
corresponding to this in gcc.
(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment. For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS. This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes). This is
TYPE_SIZE in gcc.
Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize. This means that the size of an array
is the length times the getABITypeSize. It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize. Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case. So alloca's and mallocs should use getABITypeSize. Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.
Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.
In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases). I will get around to auditing these too at some point,
but I could do with some help.
Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize. I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers. If someone wants to pack these types more
tightly they can always use a packed struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
|
|
|
if (I2ElTy->isSized()) I2Size = TD.getTypeStoreSize(I2ElTy);
|
2004-11-26 21:05:39 +00:00
|
|
|
|
|
|
|
switch (AA.alias(*I1, I1Size, *I2, I2Size)) {
|
2003-02-09 20:40:13 +00:00
|
|
|
case AliasAnalysis::NoAlias:
|
2004-03-12 06:15:08 +00:00
|
|
|
PrintResults("NoAlias", PrintNoAlias, *I1, *I2, F.getParent());
|
|
|
|
++NoAlias; break;
|
2003-02-09 20:40:13 +00:00
|
|
|
case AliasAnalysis::MayAlias:
|
2004-03-12 06:15:08 +00:00
|
|
|
PrintResults("MayAlias", PrintMayAlias, *I1, *I2, F.getParent());
|
|
|
|
++MayAlias; break;
|
2003-02-09 20:40:13 +00:00
|
|
|
case AliasAnalysis::MustAlias:
|
2004-03-12 06:15:08 +00:00
|
|
|
PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent());
|
|
|
|
++MustAlias; break;
|
2003-02-06 21:29:49 +00:00
|
|
|
default:
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "Unknown alias query result!\n";
|
2003-02-06 21:29:49 +00:00
|
|
|
}
|
2004-11-26 21:05:39 +00:00
|
|
|
}
|
|
|
|
}
|
2003-02-06 21:29:49 +00:00
|
|
|
|
2004-03-12 06:15:08 +00:00
|
|
|
// Mod/ref alias analysis: compare all pairs of calls and values
|
2005-04-21 21:13:18 +00:00
|
|
|
for (std::set<CallSite>::iterator C = CallSites.begin(),
|
2005-03-26 22:16:44 +00:00
|
|
|
Ce = CallSites.end(); C != Ce; ++C) {
|
|
|
|
Instruction *I = C->getInstruction();
|
2005-04-21 21:13:18 +00:00
|
|
|
|
2005-03-26 22:16:44 +00:00
|
|
|
for (std::set<Value *>::iterator V = Pointers.begin(), Ve = Pointers.end();
|
|
|
|
V != Ve; ++V) {
|
|
|
|
unsigned Size = 0;
|
|
|
|
const Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
|
Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment. This gives a primitive type for
which getTypeSize differed from getABITypeSize. For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).
This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition). Instead there is:
(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type. For a primitive type, this is the minimum number
of bits. For an i36 this is 36 bits. For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.
(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it). For an
i36 this is 40 bits, for an x86 long double it is 80 bits. This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes). There doesn't seem to be anything
corresponding to this in gcc.
(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment. For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS. This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes). This is
TYPE_SIZE in gcc.
Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize. This means that the size of an array
is the length times the getABITypeSize. It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize. Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case. So alloca's and mallocs should use getABITypeSize. Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.
Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.
In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases). I will get around to auditing these too at some point,
but I could do with some help.
Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize. I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers. If someone wants to pack these types more
tightly they can always use a packed struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
|
|
|
if (ElTy->isSized()) Size = TD.getTypeStoreSize(ElTy);
|
2005-04-21 21:13:18 +00:00
|
|
|
|
2004-11-26 21:05:39 +00:00
|
|
|
switch (AA.getModRefInfo(*C, *V, Size)) {
|
|
|
|
case AliasAnalysis::NoModRef:
|
|
|
|
PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent());
|
|
|
|
++NoModRef; break;
|
|
|
|
case AliasAnalysis::Mod:
|
|
|
|
PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent());
|
|
|
|
++Mod; break;
|
|
|
|
case AliasAnalysis::Ref:
|
|
|
|
PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent());
|
|
|
|
++Ref; break;
|
|
|
|
case AliasAnalysis::ModRef:
|
|
|
|
PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent());
|
|
|
|
++ModRef; break;
|
|
|
|
default:
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "Unknown alias query result!\n";
|
2004-03-12 06:15:08 +00:00
|
|
|
}
|
2004-11-26 21:05:39 +00:00
|
|
|
}
|
2004-07-17 07:40:34 +00:00
|
|
|
}
|
2005-04-21 21:13:18 +00:00
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-03-26 23:56:33 +00:00
|
|
|
static void PrintPercent(unsigned Num, unsigned Sum) {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "(" << Num*100ULL/Sum << "."
|
2005-03-26 23:56:33 +00:00
|
|
|
<< ((Num*1000ULL/Sum) % 10) << "%)\n";
|
|
|
|
}
|
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
bool AAEval::doFinalization(Module &M) {
|
2004-03-12 06:15:08 +00:00
|
|
|
unsigned AliasSum = NoAlias + MayAlias + MustAlias;
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << "===== Alias Analysis Evaluator Report =====\n";
|
2004-03-12 06:15:08 +00:00
|
|
|
if (AliasSum == 0) {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " Alias Analysis Evaluator Summary: No pointers!\n";
|
2005-04-21 21:13:18 +00:00
|
|
|
} else {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << AliasSum << " Total Alias Queries Performed\n";
|
|
|
|
cerr << " " << NoAlias << " no alias responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(NoAlias, AliasSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << MayAlias << " may alias responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(MayAlias, AliasSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << MustAlias << " must alias responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(MustAlias, AliasSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " Alias Analysis Evaluator Pointer Alias Summary: "
|
|
|
|
<< NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/"
|
|
|
|
<< MustAlias*100/AliasSum << "%\n";
|
2004-03-12 06:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the summary for mod/ref analysis
|
|
|
|
unsigned ModRefSum = NoModRef + Mod + Ref + ModRef;
|
|
|
|
if (ModRefSum == 0) {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
|
2004-03-12 06:15:08 +00:00
|
|
|
} else {
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << ModRefSum << " Total ModRef Queries Performed\n";
|
|
|
|
cerr << " " << NoModRef << " no mod/ref responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(NoModRef, ModRefSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << Mod << " mod responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(Mod, ModRefSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << Ref << " ref responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(Ref, ModRefSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " " << ModRef << " mod & ref responses ";
|
2005-03-26 23:56:33 +00:00
|
|
|
PrintPercent(ModRef, ModRefSum);
|
2006-12-07 01:30:32 +00:00
|
|
|
cerr << " Alias Analysis Evaluator Mod/Ref Summary: "
|
|
|
|
<< NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/"
|
|
|
|
<< Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n";
|
2003-02-08 23:04:50 +00:00
|
|
|
}
|
|
|
|
|
2003-02-06 21:29:49 +00:00
|
|
|
return false;
|
|
|
|
}
|