Polly 20.0.0git
|
Helper class to annotate newly generated SCoPs with metadata. More...
#include <IRBuilder.h>
Public Member Functions | |
ScopAnnotator () | |
~ScopAnnotator () | |
void | buildAliasScopes (Scop &S) |
Build all alias scopes for the given SCoP. | |
void | pushLoop (llvm::Loop *L, bool IsParallel) |
Add a new loop L which is parallel if IsParallel is true. | |
void | popLoop (bool isParallel) |
Remove the last added loop. | |
void | annotate (llvm::Instruction *I) |
Annotate the new instruction I for all parallel loops. | |
void | annotateLoopLatch (llvm::BranchInst *B, llvm::Loop *L, bool IsParallel, bool IsLoopVectorizerDisabled) const |
Annotate the loop latch B wrt. L . | |
void | addAlternativeAliasBases (llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::AssertingVH< llvm::Value > > &NewMap) |
Add alternative alias based pointers. | |
void | resetAlternativeAliasBases () |
Delete the set of alternative alias bases. | |
BandAttr *& | getStagingAttrEnv () |
BandAttr * | getActiveAttrEnv () const |
Public Attributes | |
llvm::SmallVector< BandAttr *, 8 > | LoopAttrEnv |
Stack for surrounding BandAttr annotations. | |
Private Attributes | |
llvm::ScalarEvolution * | SE |
The ScalarEvolution analysis we use to find base pointers. | |
llvm::SmallVector< llvm::Loop *, 8 > | ActiveLoops |
All loops currently under construction. | |
llvm::SmallVector< llvm::MDNode *, 8 > | ParallelLoops |
Access groups for the parallel loops currently under construction. | |
llvm::MDNode * | AliasScopeDomain |
The alias scope domain for the current SCoP. | |
llvm::MapVector< llvm::AssertingVH< llvm::Value >, llvm::MDNode * > | AliasScopeMap |
A map from base pointers to its alias scope. | |
llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::MDNode * > | OtherAliasScopeListMap |
A map from base pointers to an alias scope list of other pointers. | |
llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::AssertingVH< llvm::Value > > | AlternativeAliasBases |
Helper class to annotate newly generated SCoPs with metadata.
The annotations are twofold: 1) Loops are stored in a stack-like structure in the order they are constructed and the LoopID metadata node is added to the backedge. Contained memory instructions and loop headers are annotated according to all parallel surrounding loops. 2) The new SCoP is assumed alias free (either due to the result of AliasAnalysis queries or runtime alias checks). We annotate therefore all memory instruction with alias scopes to indicate that fact to later optimizations. These alias scopes live in a new alias domain only used in this SCoP. Each base pointer has its own alias scope and is annotated to not alias with any access to different base pointers.
Definition at line 44 of file IRBuilder.h.
ScopAnnotator::ScopAnnotator | ( | ) |
Definition at line 49 of file IRBuilder.cpp.
References LoopAttrEnv.
ScopAnnotator::~ScopAnnotator | ( | ) |
Definition at line 54 of file IRBuilder.cpp.
References assert, getStagingAttrEnv(), and LoopAttrEnv.
|
inline |
Add alternative alias based pointers.
When annotating instructions with alias scope metadata, the right metadata is identified through the base pointer of the memory access. In some cases (e.g. OpenMP code generation), the base pointer of the memory accesses is not the original base pointer, but was changed when passing the original base pointer over a function boundary. This function allows to provide a map that maps from these new base pointers to the original base pointers to allow the ScopAnnotator to still find the right alias scop annotations.
NewMap | A map from new base pointers to original base pointers. |
Definition at line 76 of file IRBuilder.h.
References AlternativeAliasBases.
Referenced by polly::IslNodeBuilder::createForParallel(), and polly::IslNodeBuilder::preloadInvariantEquivClass().
void ScopAnnotator::annotate | ( | llvm::Instruction * | I | ) |
Annotate the new instruction I
for all parallel loops.
Definition at line 211 of file IRBuilder.cpp.
References AliasScopeDomain, AliasScopeMap, AlternativeAliasBases, assert, findBasePtr(), getMemAccInstPointerOperand(), OtherAliasScopeListMap, ParallelLoops, SE, and polly::Value.
Referenced by polly::IRInserter::InsertHelper().
void ScopAnnotator::annotateLoopLatch | ( | llvm::BranchInst * | B, |
llvm::Loop * | L, | ||
bool | IsParallel, | ||
bool | IsLoopVectorizerDisabled | ||
) | const |
Annotate the loop latch B
wrt. L
.
Definition at line 131 of file IRBuilder.cpp.
References B(), Ctx, getActiveAttrEnv(), IsLoopVectorizerDisabled(), ParallelLoops, and SE.
Referenced by polly::createLoop().
void ScopAnnotator::buildAliasScopes | ( | Scop & | S | ) |
Build all alias scopes for the given SCoP.
Definition at line 59 of file IRBuilder.cpp.
References AliasScopeDomain, AliasScopeMap, polly::Array, assert, Ctx, getID(), MaxArraysInAliasScops, OtherAliasScopeListMap, and SE.
Referenced by generateCode().
|
inline |
Definition at line 88 of file IRBuilder.h.
References LoopAttrEnv.
Referenced by annotateLoopLatch().
|
inline |
Definition at line 87 of file IRBuilder.h.
References LoopAttrEnv.
Referenced by polly::IslNodeBuilder::createMark(), popLoop(), and ~ScopAnnotator().
void ScopAnnotator::popLoop | ( | bool | isParallel | ) |
Remove the last added loop.
Definition at line 117 of file IRBuilder.cpp.
References ActiveLoops, assert, getStagingAttrEnv(), LoopAttrEnv, and ParallelLoops.
Referenced by polly::IslNodeBuilder::createForSequential().
void ScopAnnotator::pushLoop | ( | llvm::Loop * | L, |
bool | IsParallel | ||
) |
Add a new loop L
which is parallel if IsParallel
is true.
Definition at line 104 of file IRBuilder.cpp.
References ActiveLoops, Ctx, LoopAttrEnv, ParallelLoops, and SE.
Referenced by polly::createLoop().
|
inline |
Delete the set of alternative alias bases.
Definition at line 83 of file IRBuilder.h.
References AlternativeAliasBases.
Referenced by polly::IslNodeBuilder::createForParallel().
|
private |
All loops currently under construction.
Definition at line 97 of file IRBuilder.h.
Referenced by popLoop(), and pushLoop().
|
private |
The alias scope domain for the current SCoP.
Definition at line 103 of file IRBuilder.h.
Referenced by annotate(), and buildAliasScopes().
|
private |
A map from base pointers to its alias scope.
Definition at line 106 of file IRBuilder.h.
Referenced by annotate(), and buildAliasScopes().
|
private |
Definition at line 113 of file IRBuilder.h.
Referenced by addAlternativeAliasBases(), annotate(), and resetAlternativeAliasBases().
llvm::SmallVector<BandAttr *, 8> polly::ScopAnnotator::LoopAttrEnv |
Stack for surrounding BandAttr annotations.
Definition at line 86 of file IRBuilder.h.
Referenced by getActiveAttrEnv(), getStagingAttrEnv(), popLoop(), pushLoop(), ScopAnnotator(), and ~ScopAnnotator().
|
private |
A map from base pointers to an alias scope list of other pointers.
Definition at line 110 of file IRBuilder.h.
Referenced by annotate(), and buildAliasScopes().
|
private |
Access groups for the parallel loops currently under construction.
Definition at line 100 of file IRBuilder.h.
Referenced by annotate(), annotateLoopLatch(), popLoop(), and pushLoop().
|
private |
The ScalarEvolution analysis we use to find base pointers.
Definition at line 94 of file IRBuilder.h.
Referenced by annotate(), annotateLoopLatch(), buildAliasScopes(), and pushLoop().