mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
R600: Replace legacy debug code in AMDILCFGStructurizer.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -8,11 +8,12 @@
|
|||||||
/// \file
|
/// \file
|
||||||
//==-----------------------------------------------------------------------===//
|
//==-----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#define DEBUGME 0
|
|
||||||
#define DEBUG_TYPE "structcfg"
|
#define DEBUG_TYPE "structcfg"
|
||||||
|
|
||||||
#include "AMDGPU.h"
|
#include "AMDGPU.h"
|
||||||
#include "AMDGPUInstrInfo.h"
|
#include "AMDGPUInstrInfo.h"
|
||||||
|
#include "llvm/Support/Debug.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/SCCIterator.h"
|
#include "llvm/ADT/SCCIterator.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
@@ -62,22 +63,22 @@ STATISTIC(numClonedInstr, "CFGStructurizer cloned instructions");
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
namespace {
|
namespace {
|
||||||
#define SHOWNEWINSTR(i) \
|
#define SHOWNEWINSTR(i) \
|
||||||
if (DEBUGME) errs() << "New instr: " << *i << "\n"
|
DEBUG(dbgs() << "New instr: " << *i << "\n");
|
||||||
|
|
||||||
#define SHOWNEWBLK(b, msg) \
|
#define SHOWNEWBLK(b, msg) \
|
||||||
if (DEBUGME) { \
|
DEBUG( \
|
||||||
errs() << msg << "BB" << b->getNumber() << "size " << b->size(); \
|
dbgs() << msg << "BB" << b->getNumber() << "size " << b->size(); \
|
||||||
errs() << "\n"; \
|
dbgs() << "\n"; \
|
||||||
}
|
);
|
||||||
|
|
||||||
#define SHOWBLK_DETAIL(b, msg) \
|
#define SHOWBLK_DETAIL(b, msg) \
|
||||||
if (DEBUGME) { \
|
DEBUG( \
|
||||||
if (b) { \
|
if (b) { \
|
||||||
errs() << msg << "BB" << b->getNumber() << "size " << b->size(); \
|
dbgs() << msg << "BB" << b->getNumber() << "size " << b->size(); \
|
||||||
b->print(errs()); \
|
b->print(dbgs()); \
|
||||||
errs() << "\n"; \
|
dbgs() << "\n"; \
|
||||||
} \
|
} \
|
||||||
}
|
);
|
||||||
|
|
||||||
#define INVALIDSCCNUM -1
|
#define INVALIDSCCNUM -1
|
||||||
#define INVALIDREGNUM 0
|
#define INVALIDREGNUM 0
|
||||||
@@ -332,21 +333,27 @@ bool CFGStructurizer<PassT>::prepare(FuncT &func, PassT &pass,
|
|||||||
|
|
||||||
//FIXME: if not reducible flow graph, make it so ???
|
//FIXME: if not reducible flow graph, make it so ???
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "AMDGPUCFGStructurizer::prepare\n";
|
dbgs() << "AMDGPUCFGStructurizer::prepare\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
loopInfo = CFGTraits::getLoopInfo(pass);
|
loopInfo = CFGTraits::getLoopInfo(pass);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "LoopInfo:\n";
|
dbgs() << "LoopInfo:\n";
|
||||||
PrintLoopinfo(*loopInfo, errs());
|
PrintLoopinfo(*loopInfo, dbgs());
|
||||||
}
|
);
|
||||||
|
|
||||||
orderBlocks();
|
orderBlocks();
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Ordered blocks:\n";
|
for (typename SmallVectorImpl<BlockT *>::const_iterator
|
||||||
printOrderedBlocks(errs());
|
iterBlk = orderedBlks.begin(), iterBlkEnd = orderedBlks.end();
|
||||||
}
|
iterBlk != iterBlkEnd;
|
||||||
|
++iterBlk) {
|
||||||
|
(*iterBlk)->dump();
|
||||||
|
}
|
||||||
|
dbgs() << "Ordered blocks:\n";
|
||||||
|
printOrderedBlocks(dbgs());
|
||||||
|
);
|
||||||
|
|
||||||
SmallVector<BlockT *, DEFAULT_VEC_SLOTS> retBlks;
|
SmallVector<BlockT *, DEFAULT_VEC_SLOTS> retBlks;
|
||||||
|
|
||||||
@@ -396,26 +403,26 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
TRI = tri;
|
TRI = tri;
|
||||||
|
|
||||||
//Assume reducible CFG...
|
//Assume reducible CFG...
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "AMDGPUCFGStructurizer::run\n";
|
dbgs() << "AMDGPUCFGStructurizer::run\n";
|
||||||
func.viewCFG();
|
func.viewCFG();
|
||||||
}
|
);
|
||||||
|
|
||||||
domTree = CFGTraits::getDominatorTree(pass);
|
domTree = CFGTraits::getDominatorTree(pass);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
domTree->print(errs(), (const llvm::Module*)0);
|
domTree->print(dbgs(), (const llvm::Module*)0);
|
||||||
}
|
);
|
||||||
|
|
||||||
postDomTree = CFGTraits::getPostDominatorTree(pass);
|
postDomTree = CFGTraits::getPostDominatorTree(pass);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
postDomTree->print(errs());
|
postDomTree->print(dbgs());
|
||||||
}
|
);
|
||||||
|
|
||||||
loopInfo = CFGTraits::getLoopInfo(pass);
|
loopInfo = CFGTraits::getLoopInfo(pass);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "LoopInfo:\n";
|
dbgs() << "LoopInfo:\n";
|
||||||
PrintLoopinfo(*loopInfo, errs());
|
PrintLoopinfo(*loopInfo, dbgs());
|
||||||
}
|
);
|
||||||
|
|
||||||
orderBlocks();
|
orderBlocks();
|
||||||
#ifdef STRESSTEST
|
#ifdef STRESSTEST
|
||||||
@@ -423,10 +430,10 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
ReverseVector(orderedBlks);
|
ReverseVector(orderedBlks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Ordered blocks:\n";
|
dbgs() << "Ordered blocks:\n";
|
||||||
printOrderedBlocks(errs());
|
printOrderedBlocks(dbgs());
|
||||||
}
|
);
|
||||||
int numIter = 0;
|
int numIter = 0;
|
||||||
bool finish = false;
|
bool finish = false;
|
||||||
BlockT *curBlk;
|
BlockT *curBlk;
|
||||||
@@ -436,10 +443,10 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
++numIter;
|
++numIter;
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "numIter = " << numIter
|
dbgs() << "numIter = " << numIter
|
||||||
<< ", numRemaintedBlk = " << numRemainedBlk << "\n";
|
<< ", numRemaintedBlk = " << numRemainedBlk << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
typename SmallVectorImpl<BlockT *>::const_iterator
|
typename SmallVectorImpl<BlockT *>::const_iterator
|
||||||
iterBlk = orderedBlks.begin();
|
iterBlk = orderedBlks.begin();
|
||||||
@@ -461,10 +468,10 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
sccBeginBlk = curBlk;
|
sccBeginBlk = curBlk;
|
||||||
sccNumIter = 0;
|
sccNumIter = 0;
|
||||||
sccNumBlk = numRemainedBlk; // Init to maximum possible number.
|
sccNumBlk = numRemainedBlk; // Init to maximum possible number.
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "start processing SCC" << getSCCNum(sccBeginBlk);
|
dbgs() << "start processing SCC" << getSCCNum(sccBeginBlk);
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRetiredBlock(curBlk)) {
|
if (!isRetiredBlock(curBlk)) {
|
||||||
@@ -480,21 +487,21 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
++sccNumIter;
|
++sccNumIter;
|
||||||
int sccRemainedNumBlk = countActiveBlock(sccBeginIter, iterBlk);
|
int sccRemainedNumBlk = countActiveBlock(sccBeginIter, iterBlk);
|
||||||
if (sccRemainedNumBlk != 1 && sccRemainedNumBlk >= sccNumBlk) {
|
if (sccRemainedNumBlk != 1 && sccRemainedNumBlk >= sccNumBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Can't reduce SCC " << getSCCNum(curBlk)
|
dbgs() << "Can't reduce SCC " << getSCCNum(curBlk)
|
||||||
<< ", sccNumIter = " << sccNumIter;
|
<< ", sccNumIter = " << sccNumIter;
|
||||||
errs() << "doesn't make any progress\n";
|
dbgs() << "doesn't make any progress\n";
|
||||||
}
|
);
|
||||||
contNextScc = true;
|
contNextScc = true;
|
||||||
} else if (sccRemainedNumBlk != 1 && sccRemainedNumBlk < sccNumBlk) {
|
} else if (sccRemainedNumBlk != 1 && sccRemainedNumBlk < sccNumBlk) {
|
||||||
sccNumBlk = sccRemainedNumBlk;
|
sccNumBlk = sccRemainedNumBlk;
|
||||||
iterBlk = sccBeginIter;
|
iterBlk = sccBeginIter;
|
||||||
contNextScc = false;
|
contNextScc = false;
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "repeat processing SCC" << getSCCNum(curBlk)
|
dbgs() << "repeat processing SCC" << getSCCNum(curBlk)
|
||||||
<< "sccNumIter = " << sccNumIter << "\n";
|
<< "sccNumIter = " << sccNumIter << "\n";
|
||||||
func.viewCFG();
|
func.viewCFG();
|
||||||
}
|
);
|
||||||
} else {
|
} else {
|
||||||
// Finish the current scc.
|
// Finish the current scc.
|
||||||
contNextScc = true;
|
contNextScc = true;
|
||||||
@@ -512,9 +519,9 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
BlockT *entryBlk = FuncGTraits::nodes_begin(&func);
|
BlockT *entryBlk = FuncGTraits::nodes_begin(&func);
|
||||||
if (entryBlk->succ_size() == 0) {
|
if (entryBlk->succ_size() == 0) {
|
||||||
finish = true;
|
finish = true;
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Reduce to one block\n";
|
dbgs() << "Reduce to one block\n";
|
||||||
}
|
);
|
||||||
} else {
|
} else {
|
||||||
int newnumRemainedBlk
|
int newnumRemainedBlk
|
||||||
= countActiveBlock(orderedBlks.begin(), orderedBlks.end());
|
= countActiveBlock(orderedBlks.begin(), orderedBlks.end());
|
||||||
@@ -524,9 +531,9 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
numRemainedBlk = newnumRemainedBlk;
|
numRemainedBlk = newnumRemainedBlk;
|
||||||
} else {
|
} else {
|
||||||
makeProgress = false;
|
makeProgress = false;
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "No progress\n";
|
dbgs() << "No progress\n";
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!finish && makeProgress);
|
} while (!finish && makeProgress);
|
||||||
@@ -539,9 +546,9 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
iterEndMap = blockInfoMap.end(); iterMap != iterEndMap; ++iterMap) {
|
iterEndMap = blockInfoMap.end(); iterMap != iterEndMap; ++iterMap) {
|
||||||
if ((*iterMap).second && (*iterMap).second->isRetired) {
|
if ((*iterMap).second && (*iterMap).second->isRetired) {
|
||||||
assert(((*iterMap).first)->getNumber() != -1);
|
assert(((*iterMap).first)->getNumber() != -1);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Erase BB" << ((*iterMap).first)->getNumber() << "\n";
|
dbgs() << "Erase BB" << ((*iterMap).first)->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
(*iterMap).first->eraseFromParent(); //Remove from the parent Function.
|
(*iterMap).first->eraseFromParent(); //Remove from the parent Function.
|
||||||
}
|
}
|
||||||
delete (*iterMap).second;
|
delete (*iterMap).second;
|
||||||
@@ -555,12 +562,12 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
|
|||||||
}
|
}
|
||||||
loopLandInfoMap.clear();
|
loopLandInfoMap.clear();
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
func.viewCFG();
|
func.viewCFG();
|
||||||
}
|
);
|
||||||
|
|
||||||
if (!finish) {
|
if (!finish) {
|
||||||
assert(!"IRREDUCIBL_CF");
|
llvm_unreachable("IRREDUCIBL_CF");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -609,7 +616,7 @@ template<class PassT> void CFGStructurizer<PassT>::orderBlocks() {
|
|||||||
BlockT *bb = &(*blockIter1);
|
BlockT *bb = &(*blockIter1);
|
||||||
sccNum = getSCCNum(bb);
|
sccNum = getSCCNum(bb);
|
||||||
if (sccNum == INVALIDSCCNUM) {
|
if (sccNum == INVALIDSCCNUM) {
|
||||||
errs() << "unreachable block BB" << bb->getNumber() << "\n";
|
dbgs() << "unreachable block BB" << bb->getNumber() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //orderBlocks
|
} //orderBlocks
|
||||||
@@ -618,18 +625,18 @@ template<class PassT> int CFGStructurizer<PassT>::patternMatch(BlockT *curBlk) {
|
|||||||
int numMatch = 0;
|
int numMatch = 0;
|
||||||
int curMatch;
|
int curMatch;
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Begin patternMatch BB" << curBlk->getNumber() << "\n";
|
dbgs() << "Begin patternMatch BB" << curBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
while ((curMatch = patternMatchGroup(curBlk)) > 0) {
|
while ((curMatch = patternMatchGroup(curBlk)) > 0) {
|
||||||
numMatch += curMatch;
|
numMatch += curMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "End patternMatch BB" << curBlk->getNumber()
|
dbgs() << "End patternMatch BB" << curBlk->getNumber()
|
||||||
<< ", numMatch = " << numMatch << "\n";
|
<< ", numMatch = " << numMatch << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
return numMatch;
|
return numMatch;
|
||||||
} //patternMatch
|
} //patternMatch
|
||||||
@@ -811,9 +818,9 @@ int CFGStructurizer<PassT>::loopbreakPatternMatch(LoopT *loopRep,
|
|||||||
BlockTSmallerVector exitingBlks;
|
BlockTSmallerVector exitingBlks;
|
||||||
loopRep->getExitingBlocks(exitingBlks);
|
loopRep->getExitingBlocks(exitingBlks);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Loop has " << exitingBlks.size() << " exiting blocks\n";
|
dbgs() << "Loop has " << exitingBlks.size() << " exiting blocks\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
if (exitingBlks.size() == 0) {
|
if (exitingBlks.size() == 0) {
|
||||||
setLoopLandBlock(loopRep);
|
setLoopLandBlock(loopRep);
|
||||||
@@ -834,9 +841,9 @@ int CFGStructurizer<PassT>::loopbreakPatternMatch(LoopT *loopRep,
|
|||||||
assert(exitBlkSet.size() > 0);
|
assert(exitBlkSet.size() > 0);
|
||||||
assert(exitBlks.size() == exitingBlks.size());
|
assert(exitBlks.size() == exitingBlks.size());
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Loop has " << exitBlkSet.size() << " exit blocks\n";
|
dbgs() << "Loop has " << exitBlkSet.size() << " exit blocks\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
// Find exitLandBlk.
|
// Find exitLandBlk.
|
||||||
BlockT *exitLandBlk = NULL;
|
BlockT *exitLandBlk = NULL;
|
||||||
@@ -861,19 +868,19 @@ int CFGStructurizer<PassT>::loopbreakPatternMatch(LoopT *loopRep,
|
|||||||
BlockT *exitBlk = *iter;
|
BlockT *exitBlk = *iter;
|
||||||
|
|
||||||
PathToKind pathKind = singlePathTo(exitBlk, exitLandBlk, true);
|
PathToKind pathKind = singlePathTo(exitBlk, exitLandBlk, true);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "BB" << exitBlk->getNumber()
|
dbgs() << "BB" << exitBlk->getNumber()
|
||||||
<< " to BB" << exitLandBlk->getNumber() << " PathToKind="
|
<< " to BB" << exitLandBlk->getNumber() << " PathToKind="
|
||||||
<< pathKind << "\n";
|
<< pathKind << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
allInPath = allInPath && (pathKind == SinglePath_InPath);
|
allInPath = allInPath && (pathKind == SinglePath_InPath);
|
||||||
allNotInPath = allNotInPath && (pathKind == SinglePath_NotInPath);
|
allNotInPath = allNotInPath && (pathKind == SinglePath_NotInPath);
|
||||||
|
|
||||||
if (!allInPath && !allNotInPath) {
|
if (!allInPath && !allNotInPath) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "singlePath check fail\n";
|
dbgs() << "singlePath check fail\n";
|
||||||
}
|
);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} // check all exit blocks
|
} // check all exit blocks
|
||||||
@@ -891,19 +898,19 @@ int CFGStructurizer<PassT>::loopbreakPatternMatch(LoopT *loopRep,
|
|||||||
loopRep,
|
loopRep,
|
||||||
exitBlkSet,
|
exitBlkSet,
|
||||||
exitLandBlk)) != NULL) {
|
exitLandBlk)) != NULL) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "relocateLoopcontBlock success\n";
|
dbgs() << "relocateLoopcontBlock success\n";
|
||||||
}
|
);
|
||||||
} else if ((exitLandBlk = addLoopEndbranchBlock(loopRep,
|
} else if ((exitLandBlk = addLoopEndbranchBlock(loopRep,
|
||||||
exitingBlks,
|
exitingBlks,
|
||||||
exitBlks)) != NULL) {
|
exitBlks)) != NULL) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "insertEndbranchBlock success\n";
|
dbgs() << "insertEndbranchBlock success\n";
|
||||||
}
|
);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "loop exit fail\n";
|
dbgs() << "loop exit fail\n";
|
||||||
}
|
);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1017,11 +1024,11 @@ bool CFGStructurizer<PassT>::isSameloopDetachedContbreak(BlockT *src1Blk,
|
|||||||
if (loopRep != NULL && loopRep == loopInfo->getLoopFor(src2Blk)) {
|
if (loopRep != NULL && loopRep == loopInfo->getLoopFor(src2Blk)) {
|
||||||
LoopLandInfo *&theEntry = loopLandInfoMap[loopRep];
|
LoopLandInfo *&theEntry = loopLandInfoMap[loopRep];
|
||||||
if (theEntry != NULL) {
|
if (theEntry != NULL) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "isLoopContBreakBlock yes src1 = BB"
|
dbgs() << "isLoopContBreakBlock yes src1 = BB"
|
||||||
<< src1Blk->getNumber()
|
<< src1Blk->getNumber()
|
||||||
<< " src2 = BB" << src2Blk->getNumber() << "\n";
|
<< " src2 = BB" << src2Blk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1035,9 +1042,9 @@ int CFGStructurizer<PassT>::handleJumpintoIf(BlockT *headBlk,
|
|||||||
BlockT *falseBlk) {
|
BlockT *falseBlk) {
|
||||||
int num = handleJumpintoIfImp(headBlk, trueBlk, falseBlk);
|
int num = handleJumpintoIfImp(headBlk, trueBlk, falseBlk);
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "handleJumpintoIf swap trueBlk and FalseBlk" << "\n";
|
dbgs() << "handleJumpintoIf swap trueBlk and FalseBlk" << "\n";
|
||||||
}
|
);
|
||||||
num = handleJumpintoIfImp(headBlk, falseBlk, trueBlk);
|
num = handleJumpintoIfImp(headBlk, falseBlk, trueBlk);
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
@@ -1053,22 +1060,22 @@ int CFGStructurizer<PassT>::handleJumpintoIfImp(BlockT *headBlk,
|
|||||||
//trueBlk could be the common post dominator
|
//trueBlk could be the common post dominator
|
||||||
downBlk = trueBlk;
|
downBlk = trueBlk;
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "handleJumpintoIfImp head = BB" << headBlk->getNumber()
|
dbgs() << "handleJumpintoIfImp head = BB" << headBlk->getNumber()
|
||||||
<< " true = BB" << trueBlk->getNumber()
|
<< " true = BB" << trueBlk->getNumber()
|
||||||
<< ", numSucc=" << trueBlk->succ_size()
|
<< ", numSucc=" << trueBlk->succ_size()
|
||||||
<< " false = BB" << falseBlk->getNumber() << "\n";
|
<< " false = BB" << falseBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
while (downBlk) {
|
while (downBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "check down = BB" << downBlk->getNumber();
|
dbgs() << "check down = BB" << downBlk->getNumber();
|
||||||
}
|
);
|
||||||
|
|
||||||
if (singlePathTo(falseBlk, downBlk) == SinglePath_InPath) {
|
if (singlePathTo(falseBlk, downBlk) == SinglePath_InPath) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << " working\n";
|
dbgs() << " working\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
num += cloneOnSideEntryTo(headBlk, trueBlk, downBlk);
|
num += cloneOnSideEntryTo(headBlk, trueBlk, downBlk);
|
||||||
num += cloneOnSideEntryTo(headBlk, falseBlk, downBlk);
|
num += cloneOnSideEntryTo(headBlk, falseBlk, downBlk);
|
||||||
@@ -1081,9 +1088,9 @@ int CFGStructurizer<PassT>::handleJumpintoIfImp(BlockT *headBlk,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << " not working\n";
|
dbgs() << " not working\n";
|
||||||
}
|
);
|
||||||
downBlk = (downBlk->succ_size() == 1) ? (*downBlk->succ_begin()) : NULL;
|
downBlk = (downBlk->succ_size() == 1) ? (*downBlk->succ_begin()) : NULL;
|
||||||
} // walk down the postDomTree
|
} // walk down the postDomTree
|
||||||
|
|
||||||
@@ -1096,43 +1103,43 @@ void CFGStructurizer<PassT>::showImproveSimpleJumpintoIf(BlockT *headBlk,
|
|||||||
BlockT *falseBlk,
|
BlockT *falseBlk,
|
||||||
BlockT *landBlk,
|
BlockT *landBlk,
|
||||||
bool detail) {
|
bool detail) {
|
||||||
errs() << "head = BB" << headBlk->getNumber()
|
dbgs() << "head = BB" << headBlk->getNumber()
|
||||||
<< " size = " << headBlk->size();
|
<< " size = " << headBlk->size();
|
||||||
if (detail) {
|
if (detail) {
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
headBlk->print(errs());
|
headBlk->print(dbgs());
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trueBlk) {
|
if (trueBlk) {
|
||||||
errs() << ", true = BB" << trueBlk->getNumber() << " size = "
|
dbgs() << ", true = BB" << trueBlk->getNumber() << " size = "
|
||||||
<< trueBlk->size() << " numPred = " << trueBlk->pred_size();
|
<< trueBlk->size() << " numPred = " << trueBlk->pred_size();
|
||||||
if (detail) {
|
if (detail) {
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
trueBlk->print(errs());
|
trueBlk->print(dbgs());
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (falseBlk) {
|
if (falseBlk) {
|
||||||
errs() << ", false = BB" << falseBlk->getNumber() << " size = "
|
dbgs() << ", false = BB" << falseBlk->getNumber() << " size = "
|
||||||
<< falseBlk->size() << " numPred = " << falseBlk->pred_size();
|
<< falseBlk->size() << " numPred = " << falseBlk->pred_size();
|
||||||
if (detail) {
|
if (detail) {
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
falseBlk->print(errs());
|
falseBlk->print(dbgs());
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (landBlk) {
|
if (landBlk) {
|
||||||
errs() << ", land = BB" << landBlk->getNumber() << " size = "
|
dbgs() << ", land = BB" << landBlk->getNumber() << " size = "
|
||||||
<< landBlk->size() << " numPred = " << landBlk->pred_size();
|
<< landBlk->size() << " numPred = " << landBlk->pred_size();
|
||||||
if (detail) {
|
if (detail) {
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
landBlk->print(errs());
|
landBlk->print(dbgs());
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
} //showImproveSimpleJumpintoIf
|
} //showImproveSimpleJumpintoIf
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -1169,10 +1176,10 @@ int CFGStructurizer<PassT>::improveSimpleJumpintoIf(BlockT *headBlk,
|
|||||||
migrateFalse = true;
|
migrateFalse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "before improveSimpleJumpintoIf: ";
|
dbgs() << "before improveSimpleJumpintoIf: ";
|
||||||
showImproveSimpleJumpintoIf(headBlk, trueBlk, falseBlk, landBlk, 0);
|
showImproveSimpleJumpintoIf(headBlk, trueBlk, falseBlk, landBlk, 0);
|
||||||
}
|
);
|
||||||
|
|
||||||
// org: headBlk => if () {trueBlk} else {falseBlk} => landBlk
|
// org: headBlk => if () {trueBlk} else {falseBlk} => landBlk
|
||||||
//
|
//
|
||||||
@@ -1269,10 +1276,10 @@ int CFGStructurizer<PassT>::improveSimpleJumpintoIf(BlockT *headBlk,
|
|||||||
}
|
}
|
||||||
} //for
|
} //for
|
||||||
}
|
}
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "result from improveSimpleJumpintoIf: ";
|
dbgs() << "result from improveSimpleJumpintoIf: ";
|
||||||
showImproveSimpleJumpintoIf(headBlk, trueBlk, falseBlk, landBlk, 0);
|
showImproveSimpleJumpintoIf(headBlk, trueBlk, falseBlk, landBlk, 0);
|
||||||
}
|
);
|
||||||
|
|
||||||
// update landBlk
|
// update landBlk
|
||||||
*plandBlk = landBlk;
|
*plandBlk = landBlk;
|
||||||
@@ -1286,10 +1293,10 @@ void CFGStructurizer<PassT>::handleLoopbreak(BlockT *exitingBlk,
|
|||||||
BlockT *exitBlk,
|
BlockT *exitBlk,
|
||||||
LoopT *exitLoop,
|
LoopT *exitLoop,
|
||||||
BlockT *landBlk) {
|
BlockT *landBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Trying to break loop-depth = " << getLoopDepth(exitLoop)
|
dbgs() << "Trying to break loop-depth = " << getLoopDepth(exitLoop)
|
||||||
<< " from loop-depth = " << getLoopDepth(exitingLoop) << "\n";
|
<< " from loop-depth = " << getLoopDepth(exitingLoop) << "\n";
|
||||||
}
|
);
|
||||||
const TargetRegisterClass * I32RC = TRI->getCFGStructurizerRegClass(MVT::i32);
|
const TargetRegisterClass * I32RC = TRI->getCFGStructurizerRegClass(MVT::i32);
|
||||||
|
|
||||||
RegiT initReg = INVALIDREGNUM;
|
RegiT initReg = INVALIDREGNUM;
|
||||||
@@ -1314,14 +1321,14 @@ void CFGStructurizer<PassT>::handleLoopcontBlock(BlockT *contingBlk,
|
|||||||
LoopT *contingLoop,
|
LoopT *contingLoop,
|
||||||
BlockT *contBlk,
|
BlockT *contBlk,
|
||||||
LoopT *contLoop) {
|
LoopT *contLoop) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "loopcontPattern cont = BB" << contingBlk->getNumber()
|
dbgs() << "loopcontPattern cont = BB" << contingBlk->getNumber()
|
||||||
<< " header = BB" << contBlk->getNumber() << "\n";
|
<< " header = BB" << contBlk->getNumber() << "\n";
|
||||||
|
|
||||||
errs() << "Trying to continue loop-depth = "
|
dbgs() << "Trying to continue loop-depth = "
|
||||||
<< getLoopDepth(contLoop)
|
<< getLoopDepth(contLoop)
|
||||||
<< " from loop-depth = " << getLoopDepth(contingLoop) << "\n";
|
<< " from loop-depth = " << getLoopDepth(contingLoop) << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
RegiT initReg = INVALIDREGNUM;
|
RegiT initReg = INVALIDREGNUM;
|
||||||
const TargetRegisterClass * I32RC = TRI->getCFGStructurizerRegClass(MVT::i32);
|
const TargetRegisterClass * I32RC = TRI->getCFGStructurizerRegClass(MVT::i32);
|
||||||
@@ -1343,10 +1350,10 @@ void CFGStructurizer<PassT>::handleLoopcontBlock(BlockT *contingBlk,
|
|||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
void CFGStructurizer<PassT>::mergeSerialBlock(BlockT *dstBlk, BlockT *srcBlk) {
|
void CFGStructurizer<PassT>::mergeSerialBlock(BlockT *dstBlk, BlockT *srcBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "serialPattern BB" << dstBlk->getNumber()
|
dbgs() << "serialPattern BB" << dstBlk->getNumber()
|
||||||
<< " <= BB" << srcBlk->getNumber() << "\n";
|
<< " <= BB" << srcBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
dstBlk->splice(dstBlk->end(), srcBlk, srcBlk->begin(), srcBlk->end());
|
dstBlk->splice(dstBlk->end(), srcBlk, srcBlk->begin(), srcBlk->end());
|
||||||
|
|
||||||
dstBlk->removeSuccessor(srcBlk);
|
dstBlk->removeSuccessor(srcBlk);
|
||||||
@@ -1362,26 +1369,26 @@ void CFGStructurizer<PassT>::mergeIfthenelseBlock(InstrT *branchInstr,
|
|||||||
BlockT *trueBlk,
|
BlockT *trueBlk,
|
||||||
BlockT *falseBlk,
|
BlockT *falseBlk,
|
||||||
BlockT *landBlk) {
|
BlockT *landBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "ifPattern BB" << curBlk->getNumber();
|
dbgs() << "ifPattern BB" << curBlk->getNumber();
|
||||||
errs() << "{ ";
|
dbgs() << "{ ";
|
||||||
if (trueBlk) {
|
if (trueBlk) {
|
||||||
errs() << "BB" << trueBlk->getNumber();
|
dbgs() << "BB" << trueBlk->getNumber();
|
||||||
}
|
}
|
||||||
errs() << " } else ";
|
dbgs() << " } else ";
|
||||||
errs() << "{ ";
|
dbgs() << "{ ";
|
||||||
if (falseBlk) {
|
if (falseBlk) {
|
||||||
errs() << "BB" << falseBlk->getNumber();
|
dbgs() << "BB" << falseBlk->getNumber();
|
||||||
}
|
}
|
||||||
errs() << " }\n ";
|
dbgs() << " }\n ";
|
||||||
errs() << "landBlock: ";
|
dbgs() << "landBlock: ";
|
||||||
if (landBlk == NULL) {
|
if (landBlk == NULL) {
|
||||||
errs() << "NULL";
|
dbgs() << "NULL";
|
||||||
} else {
|
} else {
|
||||||
errs() << "BB" << landBlk->getNumber();
|
dbgs() << "BB" << landBlk->getNumber();
|
||||||
}
|
}
|
||||||
errs() << "\n";
|
dbgs() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
int oldOpcode = branchInstr->getOpcode();
|
int oldOpcode = branchInstr->getOpcode();
|
||||||
DebugLoc branchDL = branchInstr->getDebugLoc();
|
DebugLoc branchDL = branchInstr->getDebugLoc();
|
||||||
@@ -1435,10 +1442,10 @@ void CFGStructurizer<PassT>::mergeLooplandBlock(BlockT *dstBlk,
|
|||||||
LoopLandInfo *loopLand) {
|
LoopLandInfo *loopLand) {
|
||||||
BlockT *landBlk = loopLand->landBlk;
|
BlockT *landBlk = loopLand->landBlk;
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "loopPattern header = BB" << dstBlk->getNumber()
|
dbgs() << "loopPattern header = BB" << dstBlk->getNumber()
|
||||||
<< " land = BB" << landBlk->getNumber() << "\n";
|
<< " land = BB" << landBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
// Loop contInitRegs are init at the beginning of the loop.
|
// Loop contInitRegs are init at the beginning of the loop.
|
||||||
for (typename std::set<RegiT>::const_iterator iter =
|
for (typename std::set<RegiT>::const_iterator iter =
|
||||||
@@ -1521,7 +1528,7 @@ void CFGStructurizer<PassT>::reversePredicateSetter(typename BlockT::iterator I)
|
|||||||
static_cast<MachineInstr *>(I)->getOperand(2).setImm(OPCODE_IS_ZERO);
|
static_cast<MachineInstr *>(I)->getOperand(2).setImm(OPCODE_IS_ZERO);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
assert(0 && "PRED_X Opcode invalid!");
|
llvm_unreachable("PRED_X Opcode invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1532,11 +1539,11 @@ void CFGStructurizer<PassT>::mergeLoopbreakBlock(BlockT *exitingBlk,
|
|||||||
BlockT *exitBlk,
|
BlockT *exitBlk,
|
||||||
BlockT *exitLandBlk,
|
BlockT *exitLandBlk,
|
||||||
RegiT setReg) {
|
RegiT setReg) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "loopbreakPattern exiting = BB" << exitingBlk->getNumber()
|
dbgs() << "loopbreakPattern exiting = BB" << exitingBlk->getNumber()
|
||||||
<< " exit = BB" << exitBlk->getNumber()
|
<< " exit = BB" << exitBlk->getNumber()
|
||||||
<< " land = BB" << exitLandBlk->getNumber() << "\n";
|
<< " land = BB" << exitLandBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
InstrT *branchInstr = CFGTraits::getLoopendBlockBranchInstr(exitingBlk);
|
InstrT *branchInstr = CFGTraits::getLoopendBlockBranchInstr(exitingBlk);
|
||||||
assert(branchInstr && CFGTraits::isCondBranch(branchInstr));
|
assert(branchInstr && CFGTraits::isCondBranch(branchInstr));
|
||||||
@@ -1596,11 +1603,11 @@ template<class PassT>
|
|||||||
void CFGStructurizer<PassT>::settleLoopcontBlock(BlockT *contingBlk,
|
void CFGStructurizer<PassT>::settleLoopcontBlock(BlockT *contingBlk,
|
||||||
BlockT *contBlk,
|
BlockT *contBlk,
|
||||||
RegiT setReg) {
|
RegiT setReg) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "settleLoopcontBlock conting = BB"
|
dbgs() << "settleLoopcontBlock conting = BB"
|
||||||
<< contingBlk->getNumber()
|
<< contingBlk->getNumber()
|
||||||
<< ", cont = BB" << contBlk->getNumber() << "\n";
|
<< ", cont = BB" << contBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
InstrT *branchInstr = CFGTraits::getLoopendBlockBranchInstr(contingBlk);
|
InstrT *branchInstr = CFGTraits::getLoopendBlockBranchInstr(contingBlk);
|
||||||
if (branchInstr) {
|
if (branchInstr) {
|
||||||
@@ -1711,10 +1718,10 @@ CFGStructurizer<PassT>::relocateLoopcontBlock(LoopT *parentLoopRep,
|
|||||||
contInstr->eraseFromParent();
|
contInstr->eraseFromParent();
|
||||||
}
|
}
|
||||||
endBlk->addSuccessor(newBlk);
|
endBlk->addSuccessor(newBlk);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Add new continue Block to BB"
|
dbgs() << "Add new continue Block to BB"
|
||||||
<< endBlk->getNumber() << " successors\n";
|
<< endBlk->getNumber() << " successors\n";
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBlk;
|
return newBlk;
|
||||||
@@ -1927,10 +1934,10 @@ CFGStructurizer<PassT>::cloneBlockForPredecessor(BlockT *curBlk,
|
|||||||
|
|
||||||
numClonedInstr += curBlk->size();
|
numClonedInstr += curBlk->size();
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Cloned block: " << "BB"
|
dbgs() << "Cloned block: " << "BB"
|
||||||
<< curBlk->getNumber() << "size " << curBlk->size() << "\n";
|
<< curBlk->getNumber() << "size " << curBlk->size() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
SHOWNEWBLK(cloneBlk, "result of Cloned block: ");
|
SHOWNEWBLK(cloneBlk, "result of Cloned block: ");
|
||||||
|
|
||||||
@@ -1966,29 +1973,29 @@ void CFGStructurizer<PassT>::migrateInstruction(BlockT *srcBlk,
|
|||||||
//look for the input branchinstr, not the AMDGPU branchinstr
|
//look for the input branchinstr, not the AMDGPU branchinstr
|
||||||
InstrT *branchInstr = CFGTraits::getNormalBlockBranchInstr(srcBlk);
|
InstrT *branchInstr = CFGTraits::getNormalBlockBranchInstr(srcBlk);
|
||||||
if (branchInstr == NULL) {
|
if (branchInstr == NULL) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "migrateInstruction don't see branch instr\n" ;
|
dbgs() << "migrateInstruction don't see branch instr\n" ;
|
||||||
}
|
);
|
||||||
spliceEnd = srcBlk->end();
|
spliceEnd = srcBlk->end();
|
||||||
} else {
|
} else {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "migrateInstruction see branch instr\n" ;
|
dbgs() << "migrateInstruction see branch instr\n" ;
|
||||||
branchInstr->dump();
|
branchInstr->dump();
|
||||||
}
|
);
|
||||||
spliceEnd = CFGTraits::getInstrPos(srcBlk, branchInstr);
|
spliceEnd = CFGTraits::getInstrPos(srcBlk, branchInstr);
|
||||||
}
|
}
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "migrateInstruction before splice dstSize = " << dstBlk->size()
|
dbgs() << "migrateInstruction before splice dstSize = " << dstBlk->size()
|
||||||
<< "srcSize = " << srcBlk->size() << "\n";
|
<< "srcSize = " << srcBlk->size() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
//splice insert before insertPos
|
//splice insert before insertPos
|
||||||
dstBlk->splice(insertPos, srcBlk, srcBlk->begin(), spliceEnd);
|
dstBlk->splice(insertPos, srcBlk, srcBlk->begin(), spliceEnd);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "migrateInstruction after splice dstSize = " << dstBlk->size()
|
dbgs() << "migrateInstruction after splice dstSize = " << dstBlk->size()
|
||||||
<< "srcSize = " << srcBlk->size() << "\n";
|
<< "srcSize = " << srcBlk->size() << "\n";
|
||||||
}
|
);
|
||||||
} //migrateInstruction
|
} //migrateInstruction
|
||||||
|
|
||||||
// normalizeInfiniteLoopExit change
|
// normalizeInfiniteLoopExit change
|
||||||
@@ -2016,7 +2023,7 @@ CFGStructurizer<PassT>::normalizeInfiniteLoopExit(LoopT* LoopRep) {
|
|||||||
funcRep->push_back(dummyExitBlk); //insert to function
|
funcRep->push_back(dummyExitBlk); //insert to function
|
||||||
SHOWNEWBLK(dummyExitBlk, "DummyExitBlock to normalize infiniteLoop: ");
|
SHOWNEWBLK(dummyExitBlk, "DummyExitBlock to normalize infiniteLoop: ");
|
||||||
|
|
||||||
if (DEBUGME) errs() << "Old branch instr: " << *branchInstr << "\n";
|
DEBUG(dbgs() << "Old branch instr: " << *branchInstr << "\n";);
|
||||||
|
|
||||||
typename BlockT::iterator insertPos =
|
typename BlockT::iterator insertPos =
|
||||||
CFGTraits::getInstrPos(loopLatch, branchInstr);
|
CFGTraits::getInstrPos(loopLatch, branchInstr);
|
||||||
@@ -2047,10 +2054,10 @@ void CFGStructurizer<PassT>::removeUnconditionalBranch(BlockT *srcBlk) {
|
|||||||
// test_fc_do_while_or.c need to fix the upstream on this to remove the loop.
|
// test_fc_do_while_or.c need to fix the upstream on this to remove the loop.
|
||||||
while ((branchInstr = CFGTraits::getLoopendBlockBranchInstr(srcBlk))
|
while ((branchInstr = CFGTraits::getLoopendBlockBranchInstr(srcBlk))
|
||||||
&& CFGTraits::isUncondBranch(branchInstr)) {
|
&& CFGTraits::isUncondBranch(branchInstr)) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Removing unconditional branch instruction" ;
|
dbgs() << "Removing unconditional branch instruction" ;
|
||||||
branchInstr->dump();
|
branchInstr->dump();
|
||||||
}
|
);
|
||||||
branchInstr->eraseFromParent();
|
branchInstr->eraseFromParent();
|
||||||
}
|
}
|
||||||
} //removeUnconditionalBranch
|
} //removeUnconditionalBranch
|
||||||
@@ -2064,10 +2071,10 @@ void CFGStructurizer<PassT>::removeRedundantConditionalBranch(BlockT *srcBlk) {
|
|||||||
if (blk1 == blk2) {
|
if (blk1 == blk2) {
|
||||||
InstrT *branchInstr = CFGTraits::getNormalBlockBranchInstr(srcBlk);
|
InstrT *branchInstr = CFGTraits::getNormalBlockBranchInstr(srcBlk);
|
||||||
assert(branchInstr && CFGTraits::isCondBranch(branchInstr));
|
assert(branchInstr && CFGTraits::isCondBranch(branchInstr));
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Removing unneeded conditional branch instruction" ;
|
dbgs() << "Removing unneeded conditional branch instruction" ;
|
||||||
branchInstr->dump();
|
branchInstr->dump();
|
||||||
}
|
);
|
||||||
branchInstr->eraseFromParent();
|
branchInstr->eraseFromParent();
|
||||||
SHOWNEWBLK(blk1, "Removing redundant successor");
|
SHOWNEWBLK(blk1, "Removing redundant successor");
|
||||||
srcBlk->removeSuccessor(blk1);
|
srcBlk->removeSuccessor(blk1);
|
||||||
@@ -2091,10 +2098,10 @@ void CFGStructurizer<PassT>::addDummyExitBlock(SmallVectorImpl<BlockT *>
|
|||||||
curInstr->eraseFromParent();
|
curInstr->eraseFromParent();
|
||||||
}
|
}
|
||||||
curBlk->addSuccessor(dummyExitBlk);
|
curBlk->addSuccessor(dummyExitBlk);
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Add dummyExitBlock to BB" << curBlk->getNumber()
|
dbgs() << "Add dummyExitBlock to BB" << curBlk->getNumber()
|
||||||
<< " successors\n";
|
<< " successors\n";
|
||||||
}
|
);
|
||||||
} //for
|
} //for
|
||||||
|
|
||||||
SHOWNEWBLK(dummyExitBlk, "DummyExitBlock: ");
|
SHOWNEWBLK(dummyExitBlk, "DummyExitBlock: ");
|
||||||
@@ -2126,9 +2133,9 @@ int CFGStructurizer<PassT>::getSCCNum(BlockT *srcBlk) {
|
|||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
void CFGStructurizer<PassT>::retireBlock(BlockT *dstBlk, BlockT *srcBlk) {
|
void CFGStructurizer<PassT>::retireBlock(BlockT *dstBlk, BlockT *srcBlk) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Retiring BB" << srcBlk->getNumber() << "\n";
|
dbgs() << "Retiring BB" << srcBlk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
|
|
||||||
BlockInfo *&srcBlkInfo = blockInfoMap[srcBlk];
|
BlockInfo *&srcBlkInfo = blockInfoMap[srcBlk];
|
||||||
|
|
||||||
@@ -2245,11 +2252,11 @@ void CFGStructurizer<PassT>::setLoopLandBlock(LoopT *loopRep, BlockT *blk) {
|
|||||||
|
|
||||||
theEntry->landBlk = blk;
|
theEntry->landBlk = blk;
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "setLoopLandBlock loop-header = BB"
|
dbgs() << "setLoopLandBlock loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " landing-block = BB" << blk->getNumber() << "\n";
|
<< " landing-block = BB" << blk->getNumber() << "\n";
|
||||||
}
|
);
|
||||||
} // setLoopLandBlock
|
} // setLoopLandBlock
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2262,11 +2269,11 @@ void CFGStructurizer<PassT>::addLoopBreakOnReg(LoopT *loopRep, RegiT regNum) {
|
|||||||
|
|
||||||
theEntry->breakOnRegs.insert(regNum);
|
theEntry->breakOnRegs.insert(regNum);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "addLoopBreakOnReg loop-header = BB"
|
dbgs() << "addLoopBreakOnReg loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " regNum = " << regNum << "\n";
|
<< " regNum = " << regNum << "\n";
|
||||||
}
|
);
|
||||||
} // addLoopBreakOnReg
|
} // addLoopBreakOnReg
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2278,11 +2285,11 @@ void CFGStructurizer<PassT>::addLoopContOnReg(LoopT *loopRep, RegiT regNum) {
|
|||||||
}
|
}
|
||||||
theEntry->contOnRegs.insert(regNum);
|
theEntry->contOnRegs.insert(regNum);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "addLoopContOnReg loop-header = BB"
|
dbgs() << "addLoopContOnReg loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " regNum = " << regNum << "\n";
|
<< " regNum = " << regNum << "\n";
|
||||||
}
|
);
|
||||||
} // addLoopContOnReg
|
} // addLoopContOnReg
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2294,11 +2301,11 @@ void CFGStructurizer<PassT>::addLoopBreakInitReg(LoopT *loopRep, RegiT regNum) {
|
|||||||
}
|
}
|
||||||
theEntry->breakInitRegs.insert(regNum);
|
theEntry->breakInitRegs.insert(regNum);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "addLoopBreakInitReg loop-header = BB"
|
dbgs() << "addLoopBreakInitReg loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " regNum = " << regNum << "\n";
|
<< " regNum = " << regNum << "\n";
|
||||||
}
|
);
|
||||||
} // addLoopBreakInitReg
|
} // addLoopBreakInitReg
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2310,11 +2317,11 @@ void CFGStructurizer<PassT>::addLoopContInitReg(LoopT *loopRep, RegiT regNum) {
|
|||||||
}
|
}
|
||||||
theEntry->contInitRegs.insert(regNum);
|
theEntry->contInitRegs.insert(regNum);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "addLoopContInitReg loop-header = BB"
|
dbgs() << "addLoopContInitReg loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " regNum = " << regNum << "\n";
|
<< " regNum = " << regNum << "\n";
|
||||||
}
|
);
|
||||||
} // addLoopContInitReg
|
} // addLoopContInitReg
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2327,11 +2334,11 @@ void CFGStructurizer<PassT>::addLoopEndbranchInitReg(LoopT *loopRep,
|
|||||||
}
|
}
|
||||||
theEntry->endbranchInitRegs.insert(regNum);
|
theEntry->endbranchInitRegs.insert(regNum);
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "addLoopEndbranchInitReg loop-header = BB"
|
dbgs() << "addLoopEndbranchInitReg loop-header = BB"
|
||||||
<< loopRep->getHeader()->getNumber()
|
<< loopRep->getHeader()->getNumber()
|
||||||
<< " regNum = " << regNum << "\n";
|
<< " regNum = " << regNum << "\n";
|
||||||
}
|
);
|
||||||
} // addLoopEndbranchInitReg
|
} // addLoopEndbranchInitReg
|
||||||
|
|
||||||
template<class PassT>
|
template<class PassT>
|
||||||
@@ -2437,14 +2444,14 @@ CFGStructurizer<PassT>::findNearestCommonPostDom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "Common post dominator for exit blocks is ";
|
dbgs() << "Common post dominator for exit blocks is ";
|
||||||
if (commonDom) {
|
if (commonDom) {
|
||||||
errs() << "BB" << commonDom->getNumber() << "\n";
|
dbgs() << "BB" << commonDom->getNumber() << "\n";
|
||||||
} else {
|
} else {
|
||||||
errs() << "NULL\n";
|
dbgs() << "NULL\n";
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
return commonDom;
|
return commonDom;
|
||||||
} //findNearestCommonPostDom
|
} //findNearestCommonPostDom
|
||||||
@@ -2591,7 +2598,7 @@ struct CFGStructTraits<AMDGPUCFGStructurizer> {
|
|||||||
case AMDGPU::BRANCH_COND_i32:
|
case AMDGPU::BRANCH_COND_i32:
|
||||||
case AMDGPU::BRANCH_COND_f32: return AMDGPU::IF_LOGICALNZ_f32;
|
case AMDGPU::BRANCH_COND_f32: return AMDGPU::IF_LOGICALNZ_f32;
|
||||||
default:
|
default:
|
||||||
assert(0 && "internal error");
|
llvm_unreachable("internal error");
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2603,7 +2610,7 @@ struct CFGStructTraits<AMDGPUCFGStructurizer> {
|
|||||||
case AMDGPU::BRANCH_COND_i32:
|
case AMDGPU::BRANCH_COND_i32:
|
||||||
case AMDGPU::BRANCH_COND_f32: return AMDGPU::IF_LOGICALZ_f32;
|
case AMDGPU::BRANCH_COND_f32: return AMDGPU::IF_LOGICALZ_f32;
|
||||||
default:
|
default:
|
||||||
assert(0 && "internal error");
|
llvm_unreachable("internal error");
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2613,7 +2620,7 @@ struct CFGStructTraits<AMDGPUCFGStructurizer> {
|
|||||||
case AMDGPU::JUMP_COND:
|
case AMDGPU::JUMP_COND:
|
||||||
case AMDGPU::JUMP: return AMDGPU::CONTINUE_LOGICALNZ_i32;
|
case AMDGPU::JUMP: return AMDGPU::CONTINUE_LOGICALNZ_i32;
|
||||||
default:
|
default:
|
||||||
assert(0 && "internal error");
|
llvm_unreachable("internal error");
|
||||||
};
|
};
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2623,7 +2630,7 @@ struct CFGStructTraits<AMDGPUCFGStructurizer> {
|
|||||||
case AMDGPU::JUMP_COND:
|
case AMDGPU::JUMP_COND:
|
||||||
case AMDGPU::JUMP: return AMDGPU::CONTINUE_LOGICALZ_i32;
|
case AMDGPU::JUMP: return AMDGPU::CONTINUE_LOGICALZ_i32;
|
||||||
default:
|
default:
|
||||||
assert(0 && "internal error");
|
llvm_unreachable("internal error");
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -2753,10 +2760,10 @@ struct CFGStructTraits<AMDGPUCFGStructurizer> {
|
|||||||
if (instr) {
|
if (instr) {
|
||||||
assert(isReturn);
|
assert(isReturn);
|
||||||
} else if (isReturn) {
|
} else if (isReturn) {
|
||||||
if (DEBUGME) {
|
DEBUG(
|
||||||
errs() << "BB" << blk->getNumber()
|
dbgs() << "BB" << blk->getNumber()
|
||||||
<<" is return block without RETURN instr\n";
|
<<" is return block without RETURN instr\n";
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isReturn;
|
return isReturn;
|
||||||
|
Reference in New Issue
Block a user