2011-04-29 14:27:02 +08:00
|
|
|
//===---------- TempScopInfo.cpp - Extract TempScops ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Collect information about the control flow regions detected by the Scop
|
|
|
|
// detection, such that this information can be translated info its polyhedral
|
|
|
|
// representation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "polly/TempScopInfo.h"
|
|
|
|
#include "polly/LinkAllPasses.h"
|
2013-06-10 21:55:34 +08:00
|
|
|
#include "polly/CodeGen/BlockGenerators.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
#include "polly/Support/GICHelper.h"
|
2011-11-08 23:41:28 +08:00
|
|
|
#include "polly/Support/SCEVValidator.h"
|
2013-05-07 16:11:54 +08:00
|
|
|
#include "polly/Support/ScopHelper.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2011-11-10 06:35:00 +08:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2013-05-07 16:11:54 +08:00
|
|
|
#include "llvm/Analysis/RegionIterator.h"
|
2011-11-10 06:35:00 +08:00
|
|
|
#include "llvm/Analysis/ScalarEvolution.h"
|
2011-11-10 20:44:55 +08:00
|
|
|
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
2013-05-07 16:11:54 +08:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
#define DEBUG_TYPE "polly-analyze-ir"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace polly;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-06-29 15:00:14 +08:00
|
|
|
/// Helper Classes
|
|
|
|
|
|
|
|
void IRAccess::print(raw_ostream &OS) const {
|
|
|
|
if (isRead())
|
|
|
|
OS << "Read ";
|
|
|
|
else
|
|
|
|
OS << "Write ";
|
|
|
|
|
|
|
|
OS << BaseAddress->getName() << '[' << *Offset << "]\n";
|
|
|
|
}
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
void Comparison::print(raw_ostream &OS) const {
|
|
|
|
// Not yet implemented.
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Helper function to print the condition
|
|
|
|
static void printBBCond(raw_ostream &OS, const BBCond &Cond) {
|
|
|
|
assert(!Cond.empty() && "Unexpected empty condition!");
|
|
|
|
Cond[0].print(OS);
|
|
|
|
for (unsigned i = 1, e = Cond.size(); i != e; ++i) {
|
|
|
|
OS << " && ";
|
|
|
|
Cond[i].print(OS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const BBCond &Cond) {
|
|
|
|
printBBCond(OS, Cond);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TempScop implementation
|
2014-02-12 09:55:28 +08:00
|
|
|
TempScop::~TempScop() {}
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
void TempScop::print(raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI) const {
|
2013-02-05 20:27:23 +08:00
|
|
|
OS << "Scop: " << R.getNameStr() << ", Max Loop Depth: " << MaxLoopDepth
|
|
|
|
<< "\n";
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
printDetail(OS, SE, LI, &R, 0);
|
|
|
|
}
|
|
|
|
|
2013-07-03 00:13:07 +08:00
|
|
|
void TempScop::printDetail(raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI,
|
|
|
|
const Region *CurR, unsigned ind) const {
|
2013-06-29 15:00:14 +08:00
|
|
|
|
|
|
|
// FIXME: Print other details rather than memory accesses.
|
|
|
|
typedef Region::const_block_iterator bb_iterator;
|
2013-07-03 00:13:07 +08:00
|
|
|
for (bb_iterator I = CurR->block_begin(), E = CurR->block_end(); I != E;
|
|
|
|
++I) {
|
2013-06-29 15:00:14 +08:00
|
|
|
BasicBlock *CurBlock = *I;
|
|
|
|
|
|
|
|
AccFuncMapType::const_iterator AccSetIt = AccFuncMap.find(CurBlock);
|
|
|
|
|
|
|
|
// Ignore trivial blocks that do not contain any memory access.
|
2013-07-03 00:13:07 +08:00
|
|
|
if (AccSetIt == AccFuncMap.end())
|
|
|
|
continue;
|
2013-06-29 15:00:14 +08:00
|
|
|
|
|
|
|
OS.indent(ind) << "BB: " << CurBlock->getName() << '\n';
|
|
|
|
typedef AccFuncSetType::const_iterator access_iterator;
|
|
|
|
const AccFuncSetType &AccFuncs = AccSetIt->second;
|
|
|
|
|
2013-07-03 00:13:07 +08:00
|
|
|
for (access_iterator AI = AccFuncs.begin(), AE = AccFuncs.end(); AI != AE;
|
|
|
|
++AI)
|
2013-06-29 15:00:14 +08:00
|
|
|
AI->first.print(OS.indent(ind + 2));
|
|
|
|
}
|
|
|
|
}
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2013-07-16 23:20:29 +08:00
|
|
|
bool TempScopInfo::buildScalarDependences(Instruction *Inst, Region *R) {
|
2013-06-10 21:55:34 +08:00
|
|
|
// No need to translate these scalar dependences into polyhedral form, because
|
|
|
|
// synthesizable scalars can be generated by the code generator.
|
|
|
|
if (canSynthesize(Inst, LI, SE, R))
|
2013-07-16 23:20:29 +08:00
|
|
|
return false;
|
2013-06-10 21:55:34 +08:00
|
|
|
|
|
|
|
bool AnyCrossStmtUse = false;
|
|
|
|
BasicBlock *ParentBB = Inst->getParent();
|
|
|
|
|
|
|
|
for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
|
|
|
|
UI != UE; ++UI) {
|
|
|
|
Instruction *U = dyn_cast<Instruction>(*UI);
|
|
|
|
|
|
|
|
// Ignore the strange user
|
|
|
|
if (U == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BasicBlock *UseParent = U->getParent();
|
|
|
|
|
|
|
|
// Ignore the users in the same BB (statement)
|
|
|
|
if (UseParent == ParentBB)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// No need to translate these scalar dependences into polyhedral form,
|
|
|
|
// because synthesizable scalars can be generated by the code generator.
|
|
|
|
if (canSynthesize(U, LI, SE, R))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Now U is used in another statement.
|
|
|
|
AnyCrossStmtUse = true;
|
|
|
|
|
|
|
|
// Do not build a read access that is not in the current SCoP
|
|
|
|
if (!R->contains(UseParent))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
assert(!isa<PHINode>(U) && "Non synthesizable PHINode found in a SCoP!");
|
|
|
|
|
|
|
|
// Use the def instruction as base address of the IRAccess, so that it will
|
|
|
|
// become the the name of the scalar access in the polyhedral form.
|
|
|
|
IRAccess ScalarAccess(IRAccess::SCALARREAD, Inst, ZeroOffset, 1, true);
|
|
|
|
AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, U));
|
|
|
|
}
|
|
|
|
|
2013-07-16 23:20:29 +08:00
|
|
|
return AnyCrossStmtUse;
|
2013-06-10 21:55:34 +08:00
|
|
|
}
|
|
|
|
|
2013-06-10 10:52:30 +08:00
|
|
|
IRAccess TempScopInfo::buildIRAccess(Instruction *Inst, Loop *L, Region *R) {
|
|
|
|
unsigned Size;
|
|
|
|
enum IRAccess::TypeKind Type;
|
|
|
|
|
|
|
|
if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
|
|
|
|
Size = TD->getTypeStoreSize(Load->getType());
|
|
|
|
Type = IRAccess::READ;
|
|
|
|
} else {
|
|
|
|
StoreInst *Store = cast<StoreInst>(Inst);
|
|
|
|
Size = TD->getTypeStoreSize(Store->getValueOperand()->getType());
|
|
|
|
Type = IRAccess::WRITE;
|
|
|
|
}
|
|
|
|
|
2013-06-23 09:29:29 +08:00
|
|
|
const SCEV *AccessFunction = SE->getSCEVAtScope(getPointerOperand(*Inst), L);
|
2013-06-10 10:52:30 +08:00
|
|
|
const SCEVUnknown *BasePointer =
|
|
|
|
dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
|
|
|
|
|
|
|
|
assert(BasePointer && "Could not find base pointer");
|
|
|
|
AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
|
|
|
|
|
|
|
|
bool IsAffine = isAffineExpr(R, AccessFunction, *SE, BasePointer->getValue());
|
|
|
|
|
2013-06-23 09:29:29 +08:00
|
|
|
return IRAccess(Type, BasePointer->getValue(), AccessFunction, Size,
|
|
|
|
IsAffine);
|
2013-06-10 10:52:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-10 06:35:15 +08:00
|
|
|
void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB) {
|
2011-04-29 14:27:02 +08:00
|
|
|
AccFuncSetType Functions;
|
scop detection: properly instantiate SCEVs to the place where they are used
Fix inspired from c2d4a0627e95c34a819b9d4ffb4db62daa78dade.
Given the following code
for (i = 0; i < 10; i++) {
;
}
S: A[i] = 0
When translate the data reference A[i] in statement S using scev, we need to
retrieve the scev of 'i' at the location of 'S'. If we do not do this the
scev that we obtain will be expressed as {0,+,1}_for and will reference loop
iterators that do not surround 'S'. What we really want is the scev to be
instantiated to the value of 'i' after the loop. This value is {10}.
This used to crash in:
int loopDimension = getLoopDepth(Expr->getLoop());
isl_aff *LAff = isl_aff_set_coefficient_si(
isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1);
(gdb) p Expr->dump()
{8,+,8}<nw><%do.body>
(gdb) p getLoopDepth(Expr->getLoop())
$5 = 0
isl_space *Space = isl_space_set_alloc(Ctx, 0, NbLoopSpaces);
isl_local_space *LocalSpace = isl_local_space_from_space(Space);
As we are trying to create a memory access in a stmt that is outside all loops,
LocalSpace has 0 dimensions:
(gdb) p NbLoopSpaces
$12 = 0
(gdb) p Statement.BB->dump()
if.then: ; preds = %do.end
%0 = load float* %add.ptr, align 4
store float %0, float* %q.1.reg2mem, align 4
br label %if.end.single_exit
and so the scev for %add.ptr should be taken at the place where it is used,
i.e., it should be the value on the last iteration of the do.body loop, and not
"{8,+,8}<nw><%do.body>".
llvm-svn: 179148
2013-04-10 12:05:18 +08:00
|
|
|
Loop *L = LI->getLoopFor(&BB);
|
2011-08-18 14:29:25 +08:00
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) {
|
2013-06-10 10:52:30 +08:00
|
|
|
Instruction *Inst = I;
|
|
|
|
if (isa<LoadInst>(Inst) || isa<StoreInst>(Inst))
|
|
|
|
Functions.push_back(std::make_pair(buildIRAccess(Inst, L, &R), Inst));
|
2013-06-10 21:55:34 +08:00
|
|
|
|
2013-07-16 23:20:29 +08:00
|
|
|
if (!isa<StoreInst>(Inst) && buildScalarDependences(Inst, &R)) {
|
|
|
|
// If the Instruction is used outside the statement, we need to build the
|
|
|
|
// write access.
|
|
|
|
IRAccess ScalarAccess(IRAccess::SCALARWRITE, Inst, ZeroOffset, 1, true);
|
|
|
|
Functions.push_back(std::make_pair(ScalarAccess, Inst));
|
|
|
|
}
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Functions.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
AccFuncSetType &Accs = AccFuncMap[&BB];
|
|
|
|
Accs.insert(Accs.end(), Functions.begin(), Functions.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TempScopInfo::buildLoopBounds(TempScop &Scop) {
|
|
|
|
Region &R = Scop.getMaxRegion();
|
|
|
|
unsigned MaxLoopDepth = 0;
|
|
|
|
|
2013-02-05 20:27:23 +08:00
|
|
|
for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
|
|
|
|
++I) {
|
2012-05-05 04:57:29 +08:00
|
|
|
Loop *L = LI->getLoopFor(*I);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
if (!L || !R.contains(L))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (LoopBounds.find(L) != LoopBounds.end())
|
|
|
|
continue;
|
|
|
|
|
2011-11-03 05:37:51 +08:00
|
|
|
const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
|
|
|
|
LoopBounds[L] = BackedgeTakenCount;
|
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
Loop *OL = R.outermostLoopInRegion(L);
|
|
|
|
unsigned LoopDepth = L->getLoopDepth() - OL->getLoopDepth() + 1;
|
|
|
|
|
|
|
|
if (LoopDepth > MaxLoopDepth)
|
|
|
|
MaxLoopDepth = LoopDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scop.MaxLoopDepth = MaxLoopDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TempScopInfo::buildAffineCondition(Value &V, bool inverted,
|
2012-12-30 07:47:38 +08:00
|
|
|
Comparison **Comp) const {
|
2011-04-29 14:27:02 +08:00
|
|
|
if (ConstantInt *C = dyn_cast<ConstantInt>(&V)) {
|
2013-09-10 12:47:19 +08:00
|
|
|
// If this is always true condition, we will create 0 <= 1,
|
|
|
|
// otherwise we will create 0 >= 1.
|
2011-11-10 06:34:44 +08:00
|
|
|
const SCEV *LHS = SE->getConstant(C->getType(), 0);
|
2013-09-10 12:47:19 +08:00
|
|
|
const SCEV *RHS = SE->getConstant(C->getType(), 1);
|
2011-11-10 06:34:44 +08:00
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
if (C->isOne() == inverted)
|
2013-09-10 12:47:19 +08:00
|
|
|
*Comp = new Comparison(LHS, RHS, ICmpInst::ICMP_SLE);
|
2011-04-29 14:27:02 +08:00
|
|
|
else
|
2013-09-10 12:47:19 +08:00
|
|
|
*Comp = new Comparison(LHS, RHS, ICmpInst::ICMP_SGE);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ICmpInst *ICmp = dyn_cast<ICmpInst>(&V);
|
|
|
|
assert(ICmp && "Only ICmpInst of constant as condition supported!");
|
|
|
|
|
scop detection: properly instantiate SCEVs to the place where they are used
Fix inspired from c2d4a0627e95c34a819b9d4ffb4db62daa78dade.
Given the following code
for (i = 0; i < 10; i++) {
;
}
S: A[i] = 0
When translate the data reference A[i] in statement S using scev, we need to
retrieve the scev of 'i' at the location of 'S'. If we do not do this the
scev that we obtain will be expressed as {0,+,1}_for and will reference loop
iterators that do not surround 'S'. What we really want is the scev to be
instantiated to the value of 'i' after the loop. This value is {10}.
This used to crash in:
int loopDimension = getLoopDepth(Expr->getLoop());
isl_aff *LAff = isl_aff_set_coefficient_si(
isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1);
(gdb) p Expr->dump()
{8,+,8}<nw><%do.body>
(gdb) p getLoopDepth(Expr->getLoop())
$5 = 0
isl_space *Space = isl_space_set_alloc(Ctx, 0, NbLoopSpaces);
isl_local_space *LocalSpace = isl_local_space_from_space(Space);
As we are trying to create a memory access in a stmt that is outside all loops,
LocalSpace has 0 dimensions:
(gdb) p NbLoopSpaces
$12 = 0
(gdb) p Statement.BB->dump()
if.then: ; preds = %do.end
%0 = load float* %add.ptr, align 4
store float %0, float* %q.1.reg2mem, align 4
br label %if.end.single_exit
and so the scev for %add.ptr should be taken at the place where it is used,
i.e., it should be the value on the last iteration of the do.body loop, and not
"{8,+,8}<nw><%do.body>".
llvm-svn: 179148
2013-04-10 12:05:18 +08:00
|
|
|
Loop *L = LI->getLoopFor(ICmp->getParent());
|
|
|
|
const SCEV *LHS = SE->getSCEVAtScope(ICmp->getOperand(0), L);
|
|
|
|
const SCEV *RHS = SE->getSCEVAtScope(ICmp->getOperand(1), L);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
ICmpInst::Predicate Pred = ICmp->getPredicate();
|
|
|
|
|
|
|
|
// Invert the predicate if needed.
|
|
|
|
if (inverted)
|
|
|
|
Pred = ICmpInst::getInversePredicate(Pred);
|
|
|
|
|
|
|
|
switch (Pred) {
|
|
|
|
case ICmpInst::ICMP_UGT:
|
|
|
|
case ICmpInst::ICMP_UGE:
|
|
|
|
case ICmpInst::ICMP_ULT:
|
|
|
|
case ICmpInst::ICMP_ULE:
|
|
|
|
// TODO: At the moment we need to see everything as signed. This is an
|
|
|
|
// correctness issue that needs to be solved.
|
2013-06-23 09:29:29 +08:00
|
|
|
// AffLHS->setUnsigned();
|
|
|
|
// AffRHS->setUnsigned();
|
2011-04-29 14:27:02 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-11-10 06:34:44 +08:00
|
|
|
*Comp = new Comparison(LHS, RHS, Pred);
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:26:25 +08:00
|
|
|
void TempScopInfo::buildCondition(BasicBlock *BB, BasicBlock *RegionEntry) {
|
2011-04-29 14:27:02 +08:00
|
|
|
BBCond Cond;
|
|
|
|
|
|
|
|
DomTreeNode *BBNode = DT->getNode(BB), *EntryNode = DT->getNode(RegionEntry);
|
|
|
|
assert(BBNode && EntryNode && "Get null node while building condition!");
|
|
|
|
|
|
|
|
// Walk up the dominance tree until reaching the entry node. Add all
|
|
|
|
// conditions on the path to BB except if BB postdominates the block
|
|
|
|
// containing the condition.
|
|
|
|
while (BBNode != EntryNode) {
|
|
|
|
BasicBlock *CurBB = BBNode->getBlock();
|
|
|
|
BBNode = BBNode->getIDom();
|
|
|
|
assert(BBNode && "BBNode should not reach the root node!");
|
|
|
|
|
|
|
|
if (PDT->dominates(CurBB, BBNode->getBlock()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BranchInst *Br = dyn_cast<BranchInst>(BBNode->getBlock()->getTerminator());
|
|
|
|
assert(Br && "A Valid Scop should only contain branch instruction");
|
|
|
|
|
|
|
|
if (Br->isUnconditional())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Is BB on the ELSE side of the branch?
|
|
|
|
bool inverted = DT->dominates(Br->getSuccessor(1), BB);
|
|
|
|
|
|
|
|
Comparison *Cmp;
|
2012-11-19 20:26:25 +08:00
|
|
|
buildAffineCondition(*(Br->getCondition()), inverted, &Cmp);
|
2011-04-29 14:27:02 +08:00
|
|
|
Cond.push_back(*Cmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Cond.empty())
|
|
|
|
BBConds[BB] = Cond;
|
|
|
|
}
|
|
|
|
|
|
|
|
TempScop *TempScopInfo::buildTempScop(Region &R) {
|
|
|
|
TempScop *TScop = new TempScop(R, LoopBounds, BBConds, AccFuncMap);
|
|
|
|
|
2013-02-05 20:27:23 +08:00
|
|
|
for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
|
|
|
|
++I) {
|
2012-05-05 05:36:08 +08:00
|
|
|
buildAccessFunctions(R, **I);
|
2012-11-19 20:26:25 +08:00
|
|
|
buildCondition(*I, R.getEntry());
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
buildLoopBounds(*TScop);
|
|
|
|
|
|
|
|
return TScop;
|
|
|
|
}
|
|
|
|
|
|
|
|
TempScop *TempScopInfo::getTempScop(const Region *R) const {
|
|
|
|
TempScopMapType::const_iterator at = TempScops.find(R);
|
|
|
|
return at == TempScops.end() ? 0 : at->second;
|
|
|
|
}
|
|
|
|
|
2013-03-23 09:05:07 +08:00
|
|
|
void TempScopInfo::print(raw_ostream &OS, const Module *) const {
|
2011-04-29 14:27:02 +08:00
|
|
|
for (TempScopMapType::const_iterator I = TempScops.begin(),
|
2013-02-05 20:27:23 +08:00
|
|
|
E = TempScops.end();
|
|
|
|
I != E; ++I)
|
2011-04-29 14:27:02 +08:00
|
|
|
I->second->print(OS, SE, LI);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TempScopInfo::runOnFunction(Function &F) {
|
2014-01-14 06:29:56 +08:00
|
|
|
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
2011-04-29 14:27:02 +08:00
|
|
|
PDT = &getAnalysis<PostDominatorTree>();
|
|
|
|
SE = &getAnalysis<ScalarEvolution>();
|
|
|
|
LI = &getAnalysis<LoopInfo>();
|
|
|
|
SD = &getAnalysis<ScopDetection>();
|
|
|
|
AA = &getAnalysis<AliasAnalysis>();
|
2012-10-09 01:26:19 +08:00
|
|
|
TD = &getAnalysis<DataLayout>();
|
2013-06-10 21:55:34 +08:00
|
|
|
ZeroOffset = SE->getConstant(TD->getIntPtrType(F.getContext()), 0);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
for (ScopDetection::iterator I = SD->begin(), E = SD->end(); I != E; ++I) {
|
2013-02-05 20:27:23 +08:00
|
|
|
Region *R = const_cast<Region *>(*I);
|
2011-04-29 14:27:02 +08:00
|
|
|
TempScops.insert(std::make_pair(R, buildTempScop(*R)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TempScopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
2012-10-09 01:26:19 +08:00
|
|
|
AU.addRequired<DataLayout>();
|
2014-01-14 06:29:56 +08:00
|
|
|
AU.addRequiredTransitive<DominatorTreeWrapperPass>();
|
2011-04-29 14:27:02 +08:00
|
|
|
AU.addRequiredTransitive<PostDominatorTree>();
|
|
|
|
AU.addRequiredTransitive<LoopInfo>();
|
|
|
|
AU.addRequiredTransitive<ScalarEvolution>();
|
|
|
|
AU.addRequiredTransitive<ScopDetection>();
|
|
|
|
AU.addRequiredID(IndependentBlocksID);
|
|
|
|
AU.addRequired<AliasAnalysis>();
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:27:23 +08:00
|
|
|
TempScopInfo::~TempScopInfo() { clear(); }
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
void TempScopInfo::clear() {
|
|
|
|
BBConds.clear();
|
|
|
|
LoopBounds.clear();
|
|
|
|
AccFuncMap.clear();
|
|
|
|
DeleteContainerSeconds(TempScops);
|
|
|
|
TempScops.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TempScop information extraction pass implement
|
|
|
|
char TempScopInfo::ID = 0;
|
|
|
|
|
2013-03-23 09:05:07 +08:00
|
|
|
Pass *polly::createTempScopInfoPass() { return new TempScopInfo(); }
|
|
|
|
|
2011-10-08 08:30:40 +08:00
|
|
|
INITIALIZE_PASS_BEGIN(TempScopInfo, "polly-analyze-ir",
|
|
|
|
"Polly - Analyse the LLVM-IR in the detected regions",
|
2013-03-23 09:05:07 +08:00
|
|
|
false, false);
|
|
|
|
INITIALIZE_AG_DEPENDENCY(AliasAnalysis);
|
2014-01-14 06:29:56 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass);
|
2013-03-23 09:05:07 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(LoopInfo);
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(PostDominatorTree);
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(RegionInfo);
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution);
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(DataLayout);
|
2011-10-08 08:30:40 +08:00
|
|
|
INITIALIZE_PASS_END(TempScopInfo, "polly-analyze-ir",
|
|
|
|
"Polly - Analyse the LLVM-IR in the detected regions",
|
|
|
|
false, false)
|