mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
[LoopDist] Move pointer-to-partition computation out of RuntimeCheckEmitter, NFC
This starts preparing the class to become a (more) general LoopVersioning utility class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -633,23 +633,14 @@ private:
|
|||||||
class RuntimeCheckEmitter {
|
class RuntimeCheckEmitter {
|
||||||
public:
|
public:
|
||||||
RuntimeCheckEmitter(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
|
RuntimeCheckEmitter(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
|
||||||
DominatorTree *DT)
|
DominatorTree *DT,
|
||||||
: OrigLoop(L), NonDistributedLoop(nullptr), LAI(LAI), LI(LI), DT(DT) {}
|
const SmallVector<int, 8> *PtrToPartition = nullptr)
|
||||||
|
: OrigLoop(L), NonDistributedLoop(nullptr),
|
||||||
/// \brief Given the \p Partitions formed by Loop Distribution, it determines
|
PtrToPartition(PtrToPartition), LAI(LAI), LI(LI), DT(DT) {}
|
||||||
/// in which partition each pointer is used.
|
|
||||||
void partitionPointers(InstPartitionContainer &Partitions) {
|
|
||||||
// Set up partition id in PtrRtChecks. Ptr -> Access -> Intruction ->
|
|
||||||
// Partition.
|
|
||||||
PtrToPartition = Partitions.computePartitionSetForPointers(LAI);
|
|
||||||
|
|
||||||
DEBUG(dbgs() << "\nPointers:\n");
|
|
||||||
DEBUG(LAI.getRuntimePointerCheck()->print(dbgs(), 0, &PtrToPartition));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Returns true if we need memchecks to distribute the loop.
|
/// \brief Returns true if we need memchecks to distribute the loop.
|
||||||
bool needsRuntimeChecks() const {
|
bool needsRuntimeChecks() const {
|
||||||
return LAI.getRuntimePointerCheck()->needsAnyChecking(&PtrToPartition);
|
return LAI.getRuntimePointerCheck()->needsAnyChecking(PtrToPartition);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Performs the CFG manipulation part of versioning the loop including
|
/// \brief Performs the CFG manipulation part of versioning the loop including
|
||||||
@ -660,7 +651,7 @@ public:
|
|||||||
// Add the memcheck in the original preheader (this is empty initially).
|
// Add the memcheck in the original preheader (this is empty initially).
|
||||||
BasicBlock *MemCheckBB = OrigLoop->getLoopPreheader();
|
BasicBlock *MemCheckBB = OrigLoop->getLoopPreheader();
|
||||||
std::tie(FirstCheckInst, MemRuntimeCheck) =
|
std::tie(FirstCheckInst, MemRuntimeCheck) =
|
||||||
LAI.addRuntimeCheck(MemCheckBB->getTerminator(), &PtrToPartition);
|
LAI.addRuntimeCheck(MemCheckBB->getTerminator(), PtrToPartition);
|
||||||
assert(MemRuntimeCheck && "called even though needsAnyChecking = false");
|
assert(MemRuntimeCheck && "called even though needsAnyChecking = false");
|
||||||
|
|
||||||
// Rename the block to make the IR more readable.
|
// Rename the block to make the IR more readable.
|
||||||
@ -733,10 +724,11 @@ private:
|
|||||||
Loop *NonDistributedLoop;
|
Loop *NonDistributedLoop;
|
||||||
|
|
||||||
/// \brief For each memory pointer it contains the partitionId it is used in.
|
/// \brief For each memory pointer it contains the partitionId it is used in.
|
||||||
|
/// If nullptr, no partitioning is used.
|
||||||
///
|
///
|
||||||
/// The I-th entry corresponds to I-th entry in LAI.getRuntimePointerCheck().
|
/// The I-th entry corresponds to I-th entry in LAI.getRuntimePointerCheck().
|
||||||
/// If the pointer is used in multiple partitions the entry is set to -1.
|
/// If the pointer is used in multiple partitions the entry is set to -1.
|
||||||
SmallVector<int, 8> PtrToPartition;
|
const SmallVector<int, 8> *PtrToPartition;
|
||||||
|
|
||||||
/// \brief This maps the instructions from OrigLoop to their counterpart in
|
/// \brief This maps the instructions from OrigLoop to their counterpart in
|
||||||
/// NonDistributedLoop.
|
/// NonDistributedLoop.
|
||||||
@ -929,9 +921,11 @@ private:
|
|||||||
|
|
||||||
// If we need run-time checks to disambiguate pointers are run-time, version
|
// If we need run-time checks to disambiguate pointers are run-time, version
|
||||||
// the loop now.
|
// the loop now.
|
||||||
RuntimeCheckEmitter RtCheckEmitter(LAI, L, LI, DT);
|
auto PtrToPartition = Partitions.computePartitionSetForPointers(LAI);
|
||||||
RtCheckEmitter.partitionPointers(Partitions);
|
RuntimeCheckEmitter RtCheckEmitter(LAI, L, LI, DT, &PtrToPartition);
|
||||||
if (RtCheckEmitter.needsRuntimeChecks()) {
|
if (RtCheckEmitter.needsRuntimeChecks()) {
|
||||||
|
DEBUG(dbgs() << "\nPointers:\n");
|
||||||
|
DEBUG(LAI.getRuntimePointerCheck()->print(dbgs(), 0, &PtrToPartition));
|
||||||
RtCheckEmitter.versionLoop(this);
|
RtCheckEmitter.versionLoop(this);
|
||||||
RtCheckEmitter.addPHINodes(DefsUsedOutside);
|
RtCheckEmitter.addPHINodes(DefsUsedOutside);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user