2003-02-06 22:29:49 +01:00
|
|
|
//===- AliasAnalysisEvaluator.cpp - Alias Analysis Accuracy Evaluator -----===//
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-02-06 22:29:49 +01:00
|
|
|
|
2016-02-20 04:46:03 +01:00
|
|
|
#include "llvm/Analysis/AliasAnalysisEvaluator.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Constants.h"
|
2015-08-06 04:05:46 +02:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
2014-03-04 11:30:26 +01:00
|
|
|
#include "llvm/IR/InstIterator.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Instructions.h"
|
2017-06-06 13:49:48 +02:00
|
|
|
#include "llvm/IR/Module.h"
|
Sink all InitializePasses.h includes
This file lists every pass in LLVM, and is included by Pass.h, which is
very popular. Every time we add, remove, or rename a pass in LLVM, it
caused lots of recompilation.
I found this fact by looking at this table, which is sorted by the
number of times a file was changed over the last 100,000 git commits
multiplied by the number of object files that depend on it in the
current checkout:
recompiles touches affected_files header
342380 95 3604 llvm/include/llvm/ADT/STLExtras.h
314730 234 1345 llvm/include/llvm/InitializePasses.h
307036 118 2602 llvm/include/llvm/ADT/APInt.h
213049 59 3611 llvm/include/llvm/Support/MathExtras.h
170422 47 3626 llvm/include/llvm/Support/Compiler.h
162225 45 3605 llvm/include/llvm/ADT/Optional.h
158319 63 2513 llvm/include/llvm/ADT/Triple.h
140322 39 3598 llvm/include/llvm/ADT/StringRef.h
137647 59 2333 llvm/include/llvm/Support/Error.h
131619 73 1803 llvm/include/llvm/Support/FileSystem.h
Before this change, touching InitializePasses.h would cause 1345 files
to recompile. After this change, touching it only causes 550 compiles in
an incremental rebuild.
Reviewers: bkramer, asbirlea, bollu, jdoerfert
Differential Revision: https://reviews.llvm.org/D70211
2019-11-13 22:15:01 +01:00
|
|
|
#include "llvm/InitializePasses.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"
|
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> PrintRef("print-ref", cl::ReallyHidden);
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
static cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden);
|
2008-05-13 02:00:25 +02:00
|
|
|
static cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden);
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
static cl::opt<bool> PrintMust("print-must", cl::ReallyHidden);
|
|
|
|
static cl::opt<bool> PrintMustRef("print-mustref", cl::ReallyHidden);
|
|
|
|
static cl::opt<bool> PrintMustMod("print-mustmod", cl::ReallyHidden);
|
|
|
|
static cl::opt<bool> PrintMustModRef("print-mustmodref", cl::ReallyHidden);
|
2003-02-09 21:40:13 +01:00
|
|
|
|
2014-07-24 14:16:19 +02:00
|
|
|
static cl::opt<bool> EvalAAMD("evaluate-aa-metadata", cl::ReallyHidden);
|
2013-03-22 23:34:41 +01:00
|
|
|
|
2018-06-14 21:55:53 +02:00
|
|
|
static void PrintResults(AliasResult AR, bool P, const Value *V1,
|
2009-08-23 07:17:37 +02:00
|
|
|
const Value *V2, const Module *M) {
|
2016-02-20 04:46:03 +01:00
|
|
|
if (PrintAll || P) {
|
2009-08-23 07:17:37 +02:00
|
|
|
std::string o1, o2;
|
|
|
|
{
|
|
|
|
raw_string_ostream os1(o1), os2(o2);
|
2014-01-09 03:29:41 +01:00
|
|
|
V1->printAsOperand(os1, true, M);
|
|
|
|
V2->printAsOperand(os2, true, M);
|
2009-08-23 07:17:37 +02:00
|
|
|
}
|
2018-06-14 21:55:53 +02:00
|
|
|
|
2021-04-13 19:00:12 +02:00
|
|
|
if (o2 < o1) {
|
2009-07-25 02:23:56 +02:00
|
|
|
std::swap(o1, o2);
|
2021-04-13 19:00:12 +02:00
|
|
|
// Change offset sign for the local AR, for printing only.
|
|
|
|
AR.swap();
|
|
|
|
}
|
2018-06-14 21:55:53 +02:00
|
|
|
errs() << " " << AR << ":\t" << o1 << ", " << o2 << "\n";
|
2003-02-09 21:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-14 21:55:53 +02:00
|
|
|
static inline void PrintModRefResults(const char *Msg, bool P, Instruction *I,
|
|
|
|
Value *Ptr, Module *M) {
|
2016-02-20 04:46:03 +01:00
|
|
|
if (PrintAll || P) {
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " " << Msg << ": Ptr: ";
|
2014-01-09 03:29:41 +01:00
|
|
|
Ptr->printAsOperand(errs(), true, M);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << "\t<->" << *I << '\n';
|
2004-07-17 08:43:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-07 06:42:51 +01:00
|
|
|
static inline void PrintModRefResults(const char *Msg, bool P, CallBase *CallA,
|
|
|
|
CallBase *CallB, Module *M) {
|
2016-02-20 04:46:03 +01:00
|
|
|
if (PrintAll || P) {
|
2019-01-07 06:42:51 +01:00
|
|
|
errs() << " " << Msg << ": " << *CallA << " <-> " << *CallB << '\n';
|
2010-08-05 00:56:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-14 21:55:53 +02:00
|
|
|
static inline void PrintLoadStoreResults(AliasResult AR, bool P,
|
|
|
|
const Value *V1, const Value *V2,
|
|
|
|
const Module *M) {
|
2016-02-20 04:46:03 +01:00
|
|
|
if (PrintAll || P) {
|
2018-06-14 21:55:53 +02:00
|
|
|
errs() << " " << AR << ": " << *V1 << " <-> " << *V2 << '\n';
|
2013-03-22 23:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-08 18:46:24 +02:00
|
|
|
static inline bool isInterestingPointer(Value *V) {
|
|
|
|
return V->getType()->isPointerTy()
|
|
|
|
&& !isa<ConstantPointerNull>(V);
|
|
|
|
}
|
|
|
|
|
2016-08-09 02:28:15 +02:00
|
|
|
PreservedAnalyses AAEvaluator::run(Function &F, FunctionAnalysisManager &AM) {
|
2016-03-11 12:05:24 +01:00
|
|
|
runInternal(F, AM.getResult<AAManager>(F));
|
2016-02-20 04:46:03 +01:00
|
|
|
return PreservedAnalyses::all();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AAEvaluator::runInternal(Function &F, AAResults &AA) {
|
2015-08-06 04:05:46 +02:00
|
|
|
const DataLayout &DL = F.getParent()->getDataLayout();
|
2016-02-20 04:46:03 +01:00
|
|
|
|
|
|
|
++FunctionCount;
|
2010-07-07 16:27:09 +02:00
|
|
|
|
|
|
|
SetVector<Value *> Pointers;
|
2019-01-07 06:42:51 +01:00
|
|
|
SmallSetVector<CallBase *, 16> Calls;
|
2013-03-22 23:34:41 +01:00
|
|
|
SetVector<Value *> Loads;
|
|
|
|
SetVector<Value *> Stores;
|
2010-07-07 16:27:09 +02:00
|
|
|
|
Analysis: Remove implicit ilist iterator conversions
Remove implicit ilist iterator conversions from LLVMAnalysis.
I came across something really scary in `llvm::isKnownNotFullPoison()`
which relied on `Instruction::getNextNode()` being completely broken
(not surprising, but scary nevertheless). This function is documented
(and coded to) return `nullptr` when it gets to the sentinel, but with
an `ilist_half_node` as a sentinel, the sentinel check looks into some
other memory and we don't recognize we've hit the end.
Rooting out these scary cases is the reason I'm removing the implicit
conversions before doing anything else with `ilist`; I'm not at all
surprised that clients rely on badness.
I found another scary case -- this time, not relying on badness, just
bad (but I guess getting lucky so far) -- in
`ObjectSizeOffsetEvaluator::compute_()`. Here, we save out the
insertion point, do some things, and then restore it. Previously, we
let the iterator auto-convert to `Instruction*`, and then set it back
using the `Instruction*` version:
Instruction *PrevInsertPoint = Builder.GetInsertPoint();
/* Logic that may change insert point */
if (PrevInsertPoint)
Builder.SetInsertPoint(PrevInsertPoint);
The check for `PrevInsertPoint` doesn't protect correctly against bad
accesses. If the insertion point has been set to the end of a basic
block (i.e., `SetInsertPoint(SomeBB)`), then `GetInsertPoint()` returns
an iterator pointing at the list sentinel. The version of
`SetInsertPoint()` that's getting called will then call
`PrevInsertPoint->getParent()`, which explodes horribly. The only
reason this hasn't blown up is that it's fairly unlikely the builder is
adding to the end of the block; usually, we're adding instructions
somewhere before the terminator.
llvm-svn: 249925
2015-10-10 02:53:03 +02:00
|
|
|
for (auto &I : F.args())
|
|
|
|
if (I.getType()->isPointerTy()) // Add all pointer arguments.
|
|
|
|
Pointers.insert(&I);
|
2003-02-06 22:29:49 +01:00
|
|
|
|
2021-02-06 20:17:09 +01:00
|
|
|
for (Instruction &Inst : instructions(F)) {
|
|
|
|
if (Inst.getType()->isPointerTy()) // Add all pointer instructions.
|
|
|
|
Pointers.insert(&Inst);
|
|
|
|
if (EvalAAMD && isa<LoadInst>(&Inst))
|
|
|
|
Loads.insert(&Inst);
|
|
|
|
if (EvalAAMD && isa<StoreInst>(&Inst))
|
|
|
|
Stores.insert(&Inst);
|
2019-01-07 06:42:51 +01:00
|
|
|
if (auto *Call = dyn_cast<CallBase>(&Inst)) {
|
2020-04-28 05:15:59 +02:00
|
|
|
Value *Callee = Call->getCalledOperand();
|
2010-04-08 18:46:24 +02:00
|
|
|
// Skip actual functions for direct function calls.
|
|
|
|
if (!isa<Function>(Callee) && isInterestingPointer(Callee))
|
|
|
|
Pointers.insert(Callee);
|
|
|
|
// Consider formals.
|
2019-01-07 06:42:51 +01:00
|
|
|
for (Use &DataOp : Call->data_ops())
|
2015-12-23 10:58:46 +01:00
|
|
|
if (isInterestingPointer(DataOp))
|
|
|
|
Pointers.insert(DataOp);
|
2019-01-07 06:42:51 +01:00
|
|
|
Calls.insert(Call);
|
2010-04-08 18:46:24 +02:00
|
|
|
} else {
|
|
|
|
// Consider all operands.
|
2021-02-06 20:17:09 +01:00
|
|
|
for (Use &Op : Inst.operands())
|
|
|
|
if (isInterestingPointer(Op))
|
|
|
|
Pointers.insert(Op);
|
2010-04-08 18:46:24 +02:00
|
|
|
}
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
|
|
|
|
2016-02-20 04:46:03 +01:00
|
|
|
if (PrintAll || PrintNoAlias || PrintMayAlias || PrintPartialAlias ||
|
|
|
|
PrintMustAlias || PrintNoModRef || PrintMod || PrintRef || PrintModRef)
|
2010-07-07 16:27:09 +02:00
|
|
|
errs() << "Function: " << F.getName() << ": " << Pointers.size()
|
2019-01-07 06:42:51 +01:00
|
|
|
<< " pointers, " << Calls.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) {
|
2020-11-17 20:11:09 +01:00
|
|
|
auto I1Size = LocationSize::afterPointer();
|
2011-07-18 06:54:35 +02:00
|
|
|
Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
|
2018-12-23 03:39:58 +01:00
|
|
|
if (I1ElTy->isSized())
|
|
|
|
I1Size = LocationSize::precise(DL.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) {
|
2020-11-17 20:11:09 +01:00
|
|
|
auto I2Size = LocationSize::afterPointer();
|
2018-12-23 03:39:58 +01:00
|
|
|
Type *I2ElTy = cast<PointerType>((*I2)->getType())->getElementType();
|
|
|
|
if (I2ElTy->isSized())
|
|
|
|
I2Size = LocationSize::precise(DL.getTypeStoreSize(I2ElTy));
|
2004-11-26 22:05:39 +01:00
|
|
|
|
2018-06-14 21:55:53 +02:00
|
|
|
AliasResult AR = AA.alias(*I1, I1Size, *I2, I2Size);
|
|
|
|
switch (AR) {
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::NoAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintResults(AR, PrintNoAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++NoAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MayAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintResults(AR, PrintMayAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MayAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::PartialAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintResults(AR, PrintPartialAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++PartialAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MustAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintResults(AR, PrintMustAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MustAliasCount;
|
|
|
|
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
|
|
|
|
2014-07-24 14:16:19 +02:00
|
|
|
if (EvalAAMD) {
|
2013-03-22 23:34:41 +01:00
|
|
|
// iterate over all pairs of load, store
|
2016-06-26 19:27:42 +02:00
|
|
|
for (Value *Load : Loads) {
|
|
|
|
for (Value *Store : Stores) {
|
2018-06-14 21:55:53 +02:00
|
|
|
AliasResult AR = AA.alias(MemoryLocation::get(cast<LoadInst>(Load)),
|
|
|
|
MemoryLocation::get(cast<StoreInst>(Store)));
|
|
|
|
switch (AR) {
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::NoAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintNoAlias, Load, Store, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++NoAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MayAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintMayAlias, Load, Store, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MayAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::PartialAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintPartialAlias, Load, Store, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++PartialAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MustAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintMustAlias, Load, Store, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MustAliasCount;
|
|
|
|
break;
|
2013-03-22 23:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2018-06-14 21:55:53 +02:00
|
|
|
AliasResult AR = AA.alias(MemoryLocation::get(cast<StoreInst>(*I1)),
|
|
|
|
MemoryLocation::get(cast<StoreInst>(*I2)));
|
|
|
|
switch (AR) {
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::NoAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintNoAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++NoAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MayAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintMayAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MayAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::PartialAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintPartialAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++PartialAliasCount;
|
|
|
|
break;
|
2021-03-05 11:58:13 +01:00
|
|
|
case AliasResult::MustAlias:
|
2018-06-14 21:55:53 +02:00
|
|
|
PrintLoadStoreResults(AR, PrintMustAlias, *I1, *I2, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++MustAliasCount;
|
|
|
|
break;
|
2013-03-22 23:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-12 07:15:08 +01:00
|
|
|
// Mod/ref alias analysis: compare all pairs of calls and values
|
2019-01-07 06:42:51 +01:00
|
|
|
for (CallBase *Call : Calls) {
|
2016-06-26 19:27:42 +02:00
|
|
|
for (auto Pointer : Pointers) {
|
2020-11-17 20:11:09 +01:00
|
|
|
auto Size = LocationSize::afterPointer();
|
2016-06-26 19:27:42 +02:00
|
|
|
Type *ElTy = cast<PointerType>(Pointer->getType())->getElementType();
|
2018-12-23 03:39:58 +01:00
|
|
|
if (ElTy->isSized())
|
|
|
|
Size = LocationSize::precise(DL.getTypeStoreSize(ElTy));
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2019-01-07 06:42:51 +01:00
|
|
|
switch (AA.getModRefInfo(Call, Pointer, Size)) {
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::NoModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("NoModRef", PrintNoModRef, Call, Pointer,
|
2016-06-26 19:27:42 +02:00
|
|
|
F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++NoModRefCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::Mod:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Mod", PrintMod, Call, Pointer, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++ModCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::Ref:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Ref", PrintRef, Call, Pointer, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++RefCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::ModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Both ModRef", PrintModRef, Call, Pointer,
|
2016-06-26 19:27:42 +02:00
|
|
|
F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++ModRefCount;
|
|
|
|
break;
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
case ModRefInfo::Must:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Must", PrintMust, Call, Pointer, F.getParent());
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
++MustCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustMod:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Mod (MustAlias)", PrintMustMod, Call, Pointer,
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
F.getParent());
|
|
|
|
++MustModCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Ref (MustAlias)", PrintMustRef, Call, Pointer,
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
F.getParent());
|
|
|
|
++MustRefCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Both ModRef (MustAlias)", PrintMustModRef, Call,
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
Pointer, F.getParent());
|
|
|
|
++MustModRefCount;
|
|
|
|
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
|
2019-01-07 06:42:51 +01:00
|
|
|
for (CallBase *CallA : Calls) {
|
|
|
|
for (CallBase *CallB : Calls) {
|
|
|
|
if (CallA == CallB)
|
2010-08-05 00:56:29 +02:00
|
|
|
continue;
|
2019-01-07 06:42:51 +01:00
|
|
|
switch (AA.getModRefInfo(CallA, CallB)) {
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::NoModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("NoModRef", PrintNoModRef, CallA, CallB,
|
|
|
|
F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++NoModRefCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::Mod:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Mod", PrintMod, CallA, CallB, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++ModCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::Ref:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Ref", PrintRef, CallA, CallB, F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++RefCount;
|
|
|
|
break;
|
2017-12-07 23:41:34 +01:00
|
|
|
case ModRefInfo::ModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Both ModRef", PrintModRef, CallA, CallB,
|
|
|
|
F.getParent());
|
2015-06-17 09:21:41 +02:00
|
|
|
++ModRefCount;
|
|
|
|
break;
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
case ModRefInfo::Must:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Must", PrintMust, CallA, CallB, F.getParent());
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
++MustCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustMod:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Mod (MustAlias)", PrintMustMod, CallA, CallB,
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
F.getParent());
|
|
|
|
++MustModCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Just Ref (MustAlias)", PrintMustRef, CallA, CallB,
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
F.getParent());
|
|
|
|
++MustRefCount;
|
|
|
|
break;
|
|
|
|
case ModRefInfo::MustModRef:
|
2019-01-07 06:42:51 +01:00
|
|
|
PrintModRefResults("Both ModRef (MustAlias)", PrintMustModRef, CallA,
|
|
|
|
CallB, F.getParent());
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
++MustModRefCount;
|
|
|
|
break;
|
2010-08-05 00:56:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-02-06 22:29:49 +01:00
|
|
|
}
|
|
|
|
|
2016-02-20 04:46:03 +01:00
|
|
|
static void PrintPercent(int64_t Num, int64_t Sum) {
|
|
|
|
errs() << "(" << Num * 100LL / Sum << "." << ((Num * 1000LL / Sum) % 10)
|
|
|
|
<< "%)\n";
|
2005-03-27 00:56:33 +01:00
|
|
|
}
|
|
|
|
|
2016-02-20 04:46:03 +01:00
|
|
|
AAEvaluator::~AAEvaluator() {
|
|
|
|
if (FunctionCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int64_t AliasSum =
|
2015-06-17 09:21:41 +02:00
|
|
|
NoAliasCount + MayAliasCount + PartialAliasCount + MustAliasCount;
|
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";
|
2015-06-17 09:21:41 +02:00
|
|
|
errs() << " " << NoAliasCount << " no alias responses ";
|
|
|
|
PrintPercent(NoAliasCount, AliasSum);
|
|
|
|
errs() << " " << MayAliasCount << " may alias responses ";
|
|
|
|
PrintPercent(MayAliasCount, AliasSum);
|
|
|
|
errs() << " " << PartialAliasCount << " partial alias responses ";
|
|
|
|
PrintPercent(PartialAliasCount, AliasSum);
|
|
|
|
errs() << " " << MustAliasCount << " must alias responses ";
|
|
|
|
PrintPercent(MustAliasCount, AliasSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Evaluator Pointer Alias Summary: "
|
2015-06-17 09:21:41 +02:00
|
|
|
<< NoAliasCount * 100 / AliasSum << "%/"
|
|
|
|
<< MayAliasCount * 100 / AliasSum << "%/"
|
|
|
|
<< PartialAliasCount * 100 / AliasSum << "%/"
|
|
|
|
<< MustAliasCount * 100 / AliasSum << "%\n";
|
2004-03-12 07:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the summary for mod/ref analysis
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
int64_t ModRefSum = NoModRefCount + RefCount + ModCount + ModRefCount +
|
|
|
|
MustCount + MustRefCount + MustModCount + MustModRefCount;
|
2004-03-12 07:15:08 +01:00
|
|
|
if (ModRefSum == 0) {
|
2015-06-17 09:21:41 +02: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";
|
2015-06-17 09:21:41 +02:00
|
|
|
errs() << " " << NoModRefCount << " no mod/ref responses ";
|
|
|
|
PrintPercent(NoModRefCount, ModRefSum);
|
|
|
|
errs() << " " << ModCount << " mod responses ";
|
|
|
|
PrintPercent(ModCount, ModRefSum);
|
|
|
|
errs() << " " << RefCount << " ref responses ";
|
|
|
|
PrintPercent(RefCount, ModRefSum);
|
|
|
|
errs() << " " << ModRefCount << " mod & ref responses ";
|
|
|
|
PrintPercent(ModRefCount, ModRefSum);
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
errs() << " " << MustCount << " must responses ";
|
|
|
|
PrintPercent(MustCount, ModRefSum);
|
|
|
|
errs() << " " << MustModCount << " must mod responses ";
|
|
|
|
PrintPercent(MustModCount, ModRefSum);
|
|
|
|
errs() << " " << MustRefCount << " must ref responses ";
|
|
|
|
PrintPercent(MustRefCount, ModRefSum);
|
|
|
|
errs() << " " << MustModRefCount << " must mod & ref responses ";
|
|
|
|
PrintPercent(MustModRefCount, ModRefSum);
|
2009-12-23 23:49:57 +01:00
|
|
|
errs() << " Alias Analysis Evaluator Mod/Ref Summary: "
|
2015-06-17 09:21:41 +02:00
|
|
|
<< NoModRefCount * 100 / ModRefSum << "%/"
|
|
|
|
<< ModCount * 100 / ModRefSum << "%/" << RefCount * 100 / ModRefSum
|
[ModRefInfo] Add must alias info to ModRefInfo.
Summary:
Add an additional bit to ModRefInfo, ModRefInfo::Must, to be cleared for known must aliases.
Shift existing Mod/Ref/ModRef values to include an additional most
significant bit. Update wrappers that modify ModRefInfo values to
reflect the change.
Notes:
* ModRefInfo::Must is almost entirely cleared in the AAResults methods, the remaining changes are trying to preserve it.
* Only some small changes to make custom AA passes set ModRefInfo::Must (BasicAA).
* GlobalsModRef already declares a bit, who's meaning overlaps with the most significant bit in ModRefInfo (MayReadAnyGlobal). No changes to shift the value of MayReadAnyGlobal (see AlignedMap). FunctionInfo.getModRef() ajusts most significant bit so correctness is preserved, but the Must info is lost.
* There are cases where the ModRefInfo::Must is not set, e.g. 2 calls that only read will return ModRefInfo::NoModRef, though they may read from exactly the same location.
Reviewers: dberlin, hfinkel, george.burgess.iv
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D38862
llvm-svn: 321309
2017-12-21 22:41:53 +01:00
|
|
|
<< "%/" << ModRefCount * 100 / ModRefSum << "%/"
|
|
|
|
<< MustCount * 100 / ModRefSum << "%/"
|
|
|
|
<< MustRefCount * 100 / ModRefSum << "%/"
|
|
|
|
<< MustModCount * 100 / ModRefSum << "%/"
|
|
|
|
<< MustModRefCount * 100 / ModRefSum << "%\n";
|
2003-02-09 00:04:50 +01:00
|
|
|
}
|
2016-02-20 04:46:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class AAEvalLegacyPass : public FunctionPass {
|
|
|
|
std::unique_ptr<AAEvaluator> P;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static char ID; // Pass identification, replacement for typeid
|
|
|
|
AAEvalLegacyPass() : FunctionPass(ID) {
|
|
|
|
initializeAAEvalLegacyPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2010-07-07 16:27:09 +02:00
|
|
|
|
2016-02-20 04:46:03 +01:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
|
|
AU.addRequired<AAResultsWrapperPass>();
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool doInitialization(Module &M) override {
|
|
|
|
P.reset(new AAEvaluator());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool runOnFunction(Function &F) override {
|
|
|
|
P->runInternal(F, getAnalysis<AAResultsWrapperPass>().getAAResults());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool doFinalization(Module &M) override {
|
|
|
|
P.reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2003-02-06 22:29:49 +01:00
|
|
|
}
|
2016-02-20 04:46:03 +01:00
|
|
|
|
|
|
|
char AAEvalLegacyPass::ID = 0;
|
|
|
|
INITIALIZE_PASS_BEGIN(AAEvalLegacyPass, "aa-eval",
|
|
|
|
"Exhaustive Alias Analysis Precision Evaluator", false,
|
|
|
|
true)
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
|
|
|
INITIALIZE_PASS_END(AAEvalLegacyPass, "aa-eval",
|
|
|
|
"Exhaustive Alias Analysis Precision Evaluator", false,
|
|
|
|
true)
|
|
|
|
|
|
|
|
FunctionPass *llvm::createAAEvalPass() { return new AAEvalLegacyPass(); }
|