本文整理汇总了C++中tr::Block::getExit方法的典型用法代码示例。如果您正苦于以下问题:C++ Block::getExit方法的具体用法?C++ Block::getExit怎么用?C++ Block::getExit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tr::Block
的用法示例。
在下文中一共展示了Block::getExit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeTreeTopsInBlockStructure
void TR_Latestness::analyzeTreeTopsInBlockStructure(TR_BlockStructure *blockStructure)
{
TR::Block *block = blockStructure->getBlock();
TR::TreeTop *currentTree = block->getExit();
TR::TreeTop *entryTree = block->getEntry();
/////copyFromInto(_regularInfo, _outSetInfo[blockStructure->getNumber()]);
bool notSeenTreeWithChecks = true;
_containsExceptionTreeTop = false;
while (!(currentTree == entryTree))
{
if (notSeenTreeWithChecks)
{
bool currentTreeHasChecks = treeHasChecks(currentTree);
if (currentTreeHasChecks)
{
notSeenTreeWithChecks = false;
_containsExceptionTreeTop = true;
/////compose(_regularInfo, _exceptionInfo);
/////compose(_outSetInfo[blockStructure->getNumber()], _exceptionInfo);
}
}
else
break;
if (!(currentTree == entryTree))
currentTree = currentTree->getPrevTreeTop();
}
}
示例2: insertReturnAsyncChecks
int32_t TR_AsyncCheckInsertion::insertReturnAsyncChecks(TR::Optimization *opt, const char *counterPrefix)
{
TR::Compilation * const comp = opt->comp();
if (opt->trace())
traceMsg(comp, "Inserting return asyncchecks (%s)\n", counterPrefix);
int numAsyncChecksInserted = 0;
for (TR::TreeTop *treeTop = comp->getStartTree();
treeTop;
/* nothing */ )
{
TR::Block *block = treeTop->getNode()->getBlock();
if (block->getLastRealTreeTop()->getNode()->getOpCode().isReturn()
&& performTransformation(comp,
"%sInserting return asynccheck (%s) in block_%d\n",
opt->optDetailString(),
counterPrefix,
block->getNumber()))
{
insertAsyncCheck(block, comp, counterPrefix);
numAsyncChecksInserted++;
}
treeTop = block->getExit()->getNextRealTreeTop();
}
return numAsyncChecksInserted;
}
示例3: getRegDepInfo
void
TR::RegDepCopyRemoval::makeFreshCopy(TR_GlobalRegisterNumber reg)
{
RegDepInfo &dep = getRegDepInfo(reg);
if (!performTransformation(comp(),
"%schange %s in GlRegDeps n%un to an explicit copy of n%un\n",
optDetailString(),
registerName(reg),
_regDeps->getGlobalIndex(),
dep.value->getGlobalIndex()))
return;
// Split the block at fallthrough if necessary to avoid putting copies
// between branches and BBEnd.
TR::Node *curNode = _treetop->getNode();
if (curNode->getOpCodeValue() == TR::BBEnd)
{
TR::Block *curBlock = curNode->getBlock();
if (curBlock->getLastRealTreeTop() != curBlock->getLastNonControlFlowTreeTop())
{
TR::Block *fallthrough = curBlock->getNextBlock();
fallthrough = curBlock->splitEdge(curBlock, fallthrough, comp());
TR_ASSERT(curBlock->getNextBlock() == fallthrough, "bad block placement from splitEdge\n");
fallthrough->setIsExtensionOfPreviousBlock();
_treetop = fallthrough->getExit();
TR::Node *newNode = _treetop->getNode();
newNode->setChild(0, _regDeps);
newNode->setNumChildren(1);
curNode->setNumChildren(0);
if (trace())
traceMsg(comp(), "\tsplit fallthrough edge to insert copy, created block_%d\n", fallthrough->getNumber());
}
}
// Make and insert the copy
TR::Node *copyNode = NULL;
if (dep.value->getOpCode().isLoadConst())
{
// No need to depend on the other register.
// TODO heuristic for whether this is really better than a reg-reg move?
generateRegcopyDebugCounter("const-remat");
copyNode = TR::Node::create(dep.value->getOpCodeValue(), 0);
copyNode->setConstValue(dep.value->getConstValue());
}
else
{
generateRegcopyDebugCounter("fresh-copy");
copyNode = TR::Node::create(TR::PassThrough, 1, dep.value);
copyNode->setCopyToNewVirtualRegister();
}
TR::Node *copyTreetopNode = TR::Node::create(TR::treetop, 1, copyNode);
_treetop->insertBefore(TR::TreeTop::create(comp(), copyTreetopNode));
if (trace())
traceMsg(comp(), "\tcopy is n%un\n", copyNode->getGlobalIndex());
updateSingleRegDep(reg, copyNode);
}
示例4: self
TR::TreeTop *
OMR::TreeTop::getExtendedBlockExitTreeTop()
{
TR_ASSERT(self()->getNode()->getOpCodeValue() == TR::BBStart, "getExitTreeTop, is only valid for a bbStart");
TR::Block * b;
TR::TreeTop * exitTT = self()->getNode()->getBlock()->getExit(), * nextTT;
while ((nextTT = exitTT->getNextTreeTop()) && (b = nextTT->getNode()->getBlock(), b->isExtensionOfPreviousBlock()))
exitTT = b->getExit();
return exitTT;
}
示例5: perform
int32_t TR_LocalLiveRangeReduction::perform()
{
if (TR::Compiler->target.cpu.isZ())
return false;
TR::TreeTop * exitTT, * nextTT;
TR::Block *b;
TR::TreeTop * tt;
//calculate number of TreeTops in each bb (or extended bb)
for (tt = comp()->getStartTree(); tt; tt = nextTT)
{
TR::StackMemoryRegion stackMemoryRegion(*trMemory());
TR::Node *node = tt->getNode();
b = node->getBlock();
exitTT = b->getExit();
_numTreeTops = b->getNumberOfRealTreeTops()+2; //include both BBStart/BBend
//support for extended blocks
while ((nextTT = exitTT->getNextTreeTop()) && (b = nextTT->getNode()->getBlock(), b->isExtensionOfPreviousBlock()))
{
_numTreeTops += b->getNumberOfRealTreeTops()+2;
exitTT = b->getExit();
}
_treesRefInfoArray = (TR_TreeRefInfo**)trMemory()->allocateStackMemory(_numTreeTops*sizeof(TR_TreeRefInfo*));
memset(_treesRefInfoArray, 0, _numTreeTops*sizeof(TR_TreeRefInfo*));
_movedTreesList.deleteAll();
_depPairList.deleteAll();
transformExtendedBlock(tt,exitTT->getNextTreeTop());
}
if (trace())
traceMsg(comp(), "\nEnding LocalLiveRangeReducer\n");
return 2;
}
示例6: moveBlockAfterDest
static void moveBlockAfterDest(TR::CFG *cfg, TR::Block *toMove, TR::Block *dest)
{
TR::Compilation *comp = TR::comp();
// Step1 splice out toMove
TR::Block *toMovePrev = toMove->getPrevBlock();
TR::Block *toMoveSucc = toMove->getNextBlock();
toMovePrev->getExit()->join(toMoveSucc->getEntry());
// Step 2 splice toMove in after dest
TR::Block *destNext = dest->getNextBlock();
dest->getExit()->join(toMove->getEntry());
toMove->getExit()->join(destNext->getEntry());
cfg->addEdge(toMove, destNext);
cfg->addEdge(dest, toMove);
cfg->removeEdge(dest, destNext);
cfg->addEdge(toMovePrev, toMoveSucc);
cfg->removeEdge(toMovePrev, toMove);
cfg->removeEdge(toMove, toMoveSucc);
}
示例7: comp
void
TR_ExpressionsSimplification::invalidateCandidates()
{
_visitCount = comp()->incVisitCount();
if (trace())
{
traceMsg(comp(), "Checking which candidates may be invalidated\n");
ListIterator<TR::TreeTop> treeTops(_candidateTTs);
for (TR::TreeTop *treeTop = treeTops.getFirst(); treeTop; treeTop = treeTops.getNext())
{
traceMsg(comp(), " Candidate treetop: %p node: %p\n", treeTop, treeTop->getNode());
}
}
TR_ScratchList<TR::Block> blocksInLoop(trMemory());
_currentRegion->getBlocks(&blocksInLoop);
ListIterator<TR::Block> blocks(&blocksInLoop);
for (TR::Block *currentBlock = blocks.getFirst(); currentBlock; currentBlock = blocks.getNext())
{
TR::TreeTop *tt = currentBlock->getEntry();
TR::TreeTop *exitTreeTop = currentBlock->getExit();
while (tt != exitTreeTop)
{
TR::Node *currentNode = tt->getNode();
if (trace())
traceMsg(comp(), "Looking at treeTop [%p]\n", currentNode);
removeCandidate(currentNode, tt);
tt = tt->getNextTreeTop();
}
}
removeUnsupportedCandidates();
}
示例8: perform
int32_t TR_CatchBlockRemover::perform()
{
TR::CFG *cfg = comp()->getFlowGraph();
if (cfg == NULL)
{
if (trace())
traceMsg(comp(), "Can't do Catch Block Removal, no CFG\n");
return 0;
}
if (trace())
traceMsg(comp(), "Starting Catch Block Removal\n");
bool thereMayBeRemovableCatchBlocks = false;
{
TR::StackMemoryRegion stackMemoryRegion(*trMemory());
TR::Block *block;
ListIterator<TR::CFGEdge> edgeIterator;
// Go through all blocks that have exception successors and see if any of them
// are not reached. Mark each of these edges with a visit count so they can
// be identified later.
//
vcount_t visitCount = comp()->incOrResetVisitCount();
TR::CFGNode *cfgNode;
for (cfgNode = cfg->getFirstNode(); cfgNode; cfgNode = cfgNode->getNext())
{
if (cfgNode->getExceptionSuccessors().empty())
continue;
block = toBlock(cfgNode);
uint32_t reachedExceptions = 0;
TR::TreeTop *treeTop;
for (treeTop = block->getEntry(); treeTop != block->getExit(); treeTop = treeTop->getNextTreeTop())
{
reachedExceptions |= treeTop->getNode()->exceptionsRaised();
if (treeTop->getNode()->getOpCodeValue() == TR::monexitfence) // for live monitor metadata
reachedExceptions |= TR::Block::CanCatchMonitorExit;
}
if (reachedExceptions & TR::Block::CanCatchUserThrows)
continue;
for (auto edge = block->getExceptionSuccessors().begin(); edge != block->getExceptionSuccessors().end();)
{
TR::CFGEdge * current = *(edge++);
TR::Block *catchBlock = toBlock(current->getTo());
if (catchBlock->isOSRCodeBlock() || catchBlock->isOSRCatchBlock()) continue;
if (!reachedExceptions &&
performTransformation(comp(), "%sRemove redundant exception edge from block_%d at [%p] to catch block_%d at [%p]\n", optDetailString(), block->getNumber(), block, catchBlock->getNumber(), catchBlock))
{
cfg->removeEdge(block, catchBlock);
thereMayBeRemovableCatchBlocks = true;
}
else
{
if (!catchBlock->canCatchExceptions(reachedExceptions))
{
current->setVisitCount(visitCount);
thereMayBeRemovableCatchBlocks = true;
}
}
}
}
bool edgesRemoved = false;
// Now look to see if there are any catch blocks for which all exception
// predecessors have the visit count set. If so, the block is unreachable and
// can be removed.
// If only some of the exception predecessors are marked, these edges are
// left in place to identify the try/catch structure properly.
//
while (thereMayBeRemovableCatchBlocks)
{
thereMayBeRemovableCatchBlocks = false;
for (cfgNode = cfg->getFirstNode(); cfgNode; cfgNode = cfgNode->getNext())
{
if (cfgNode->getExceptionPredecessors().empty())
continue;
auto edgeIt = cfgNode->getExceptionPredecessors().begin();
for (; edgeIt != cfgNode->getExceptionPredecessors().end(); ++edgeIt)
{
if ((*edgeIt)->getVisitCount() != visitCount)
break;
}
if (edgeIt == cfgNode->getExceptionPredecessors().end() && performTransformation(comp(), "%sRemove redundant catch block_%d at [%p]\n", optDetailString(), cfgNode->getNumber(), cfgNode))
{
while (!cfgNode->getExceptionPredecessors().empty())
{
cfg->removeEdge(cfgNode->getExceptionPredecessors().front());
}
edgesRemoved = true;
thereMayBeRemovableCatchBlocks = true;
}
//.........这里部分代码省略.........
示例9: comp
TR::TreeTop *
OMR::Simplifier::simplifyExtendedBlock(TR::TreeTop * treeTop)
{
TR::Block * block = 0;
_containingStructure = NULL;
_blockRemoved = false;
for (; treeTop; treeTop = treeTop->getNextTreeTop())
{
TR::Node * node = treeTop->getNode();
TR_ASSERT(node->getOpCodeValue() == TR::BBStart, "Simplification, expected BBStart treetop");
TR::Block * b = node->getBlock();
if (block && !b->isExtensionOfPreviousBlock())
break;
if (b->isOSRCodeBlock() || b->isOSRCatchBlock())
{
b->setHasBeenVisited();
treeTop = b->getExit();
continue;
}
#ifdef DEBUG
if (block != b)
b->setHasBeenVisited();
#endif
if (!block && _reassociate &&
comp()->getFlowGraph()->getStructure() != NULL // [99391] getStructureOf() only valid if structure isn't invalidated
)
{ // b is first block in the extended block
TR_BlockStructure *blockStructure = b->getStructureOf();
if(blockStructure)
{
TR_Structure *parent = blockStructure->getParent();
while (parent)
{
TR_RegionStructure *region = parent->asRegion();
if (region->isNaturalLoop() /* || region->containsInternalCycles() */)
{
_containingStructure = region;
break;
}
parent = parent->getParent();
}
}
}
block = b;
if (trace())
traceMsg(comp(), "simplifying block_%d\n", block->getNumber());
_performLowerTreeSimplifier=NULL;
_performLowerTreeNode=NULL;
simplify(block);
if(_performLowerTreeSimplifier)
{
_performLowerTreeNode = postWalkLowerTreeSimplifier(_performLowerTreeSimplifier, _performLowerTreeNode, block, (TR::Simplifier *) this);
_performLowerTreeSimplifier->setNode(_performLowerTreeNode);
}
// If the block itself was removed from the CFG during simplification, find
// the next 'legitimate' block to be simplified
//
//if (comp()->getFlowGraph()->getRemovedNodes().find(block))
if(block->nodeIsRemoved())
{
TR::TreeTop * tt = findNextLegalTreeTop(comp(), block);
// in certain cases the removed block might be the last one we haven't
// visited and therefore we won't be able to find a treetop to continue
// in such cases we exit the loop
//
treeTop = tt ? tt->getPrevTreeTop() : 0;
if (!treeTop)
break;
}
else
{
treeTop = block->getExit();
}
}
// now remove any unreachable blocks
//
if (_blockRemoved)
{
// if the next block to be processed has been removed,
// find the next valid block to process
//
if (treeTop)
{
TR::Block *b = treeTop->getNode()->getBlock();
//if (comp()->getFlowGraph()->getRemovedNodes().find(b))
if(b->nodeIsRemoved())
treeTop = findNextLegalTreeTop(comp(), b);
//.........这里部分代码省略.........
示例10: tailSplitBlock
// This function splits a single succeesor block following an guard and is used to
// do the following transform
// block - cold1 block - cold1
// \ / => | |
// nextBlock nextBlock nextBlock' (called tailSplitBlock below)
// | \ /
// ... ...
void TR_VirtualGuardHeadMerger::tailSplitBlock(TR::Block * block, TR::Block * cold1)
{
TR::CFG *cfg = comp()->getFlowGraph();
cfg->setStructure(NULL);
TR_BlockCloner cloner(cfg);
TR::Block *tailSplitBlock = cloner.cloneBlocks(block->getNextBlock(), block->getNextBlock());
tailSplitBlock->setFrequency(cold1->getFrequency());
if (cold1->isCold())
tailSplitBlock->setIsCold();
// physically put the block after cold1 since we want cold1 to fall through
tailSplitBlock->getExit()->join(cold1->getExit()->getNextTreeTop());
cold1->getExit()->join(tailSplitBlock->getEntry());
// remove cold1's goto
TR::TransformUtil::removeTree(comp(), cold1->getExit()->getPrevRealTreeTop());
// copy the exception edges
for (auto e = block->getNextBlock()->getExceptionSuccessors().begin(); e != block->getNextBlock()->getExceptionSuccessors().end(); ++e)
cfg->addExceptionEdge(tailSplitBlock, (*e)->getTo());
cfg->addEdge(cold1, tailSplitBlock);
// lastly fix up the exit of tailSplitBlock
TR::Node *tailSplitEnd = tailSplitBlock->getExit()->getPrevRealTreeTop()->getNode();
if (tailSplitEnd->getOpCode().isGoto())
{
tailSplitEnd->setBranchDestination(block->getNextBlock()->getLastRealTreeTop()->getNode()->getBranchDestination());
cfg->addEdge(tailSplitBlock, block->getNextBlock()->getSuccessors().front()->getTo());
}
else if (tailSplitEnd->getOpCode().isBranch())
{
TR::Block *gotoBlock = TR::Block::createEmptyBlock(tailSplitEnd, comp(), cold1->getFrequency());
if (cold1->isCold())
gotoBlock->setIsCold(true);
gotoBlock->getExit()->join(tailSplitBlock->getExit()->getNextTreeTop());
tailSplitBlock->getExit()->join(gotoBlock->getEntry());
cfg->addNode(gotoBlock);
gotoBlock->append(TR::TreeTop::create(comp(), TR::Node::create(tailSplitEnd, TR::Goto, 0, block->getNextBlock()->getExit()->getNextTreeTop())));
cfg->addEdge(tailSplitBlock, gotoBlock);
cfg->addEdge(tailSplitBlock, tailSplitBlock->getLastRealTreeTop()->getNode()->getBranchDestination()->getEnclosingBlock());
cfg->addEdge(gotoBlock, block->getNextBlock()->getNextBlock());
}
else if (
!tailSplitEnd->getOpCode().isReturn() &&
!tailSplitEnd->getOpCode().isJumpWithMultipleTargets() &&
tailSplitEnd->getOpCodeValue() != TR::athrow &&
!(tailSplitEnd->getNumChildren() >= 1 && tailSplitEnd->getFirstChild()->getOpCodeValue() == TR::athrow)
)
{
tailSplitBlock->append(TR::TreeTop::create(comp(), TR::Node::create(tailSplitEnd, TR::Goto, 0, block->getNextBlock()->getExit()->getNextTreeTop())));
cfg->addEdge(tailSplitBlock, block->getNextBlock()->getNextBlock());
}
else
{
for (auto e = block->getNextBlock()->getSuccessors().begin(); e != block->getNextBlock()->getSuccessors().end(); ++e)
cfg->addEdge(tailSplitBlock, (*e)->getTo());
}
cfg->removeEdge(cold1, block->getNextBlock());
optimizer()->setUseDefInfo(NULL);
optimizer()->setValueNumberInfo(NULL);
}
示例11: if
TR_ExpressionsSimplification::LoopInfo*
TR_ExpressionsSimplification::findLoopInfo(TR_RegionStructure* region)
{
ListIterator<TR::CFGEdge> exitEdges(®ion->getExitEdges());
if (region->getExitEdges().getSize() != 1)
{
if (trace())
traceMsg(comp(), "Region with more than 1 exit edges can't be handled\n");
return 0;
}
TR_StructureSubGraphNode* exitNode = toStructureSubGraphNode(exitEdges.getFirst()->getFrom());
if (!exitNode->getStructure()->asBlock())
{
if (trace())
traceMsg(comp(), "The exit block can't be found\n");
return 0;
}
TR::Block *exitBlock = exitNode->getStructure()->asBlock()->getBlock();
TR::Node *lastTreeInExitBlock = exitBlock->getLastRealTreeTop()->getNode();
if (trace())
{
traceMsg(comp(), "The exit block is %d\n", exitBlock->getNumber());
traceMsg(comp(), "The branch node is %p\n", lastTreeInExitBlock);
}
if (!lastTreeInExitBlock->getOpCode().isBranch())
{
if (trace())
traceMsg(comp(), "The branch node couldn't be found\n");
return 0;
}
if (lastTreeInExitBlock->getNumChildren() < 2)
{
if (trace())
traceMsg(comp(), "The branch node has less than 2 children\n");
return 0;
}
TR::Node *firstChildOfLastTree = lastTreeInExitBlock->getFirstChild();
TR::Node *secondChildOfLastTree = lastTreeInExitBlock->getSecondChild();
if (!firstChildOfLastTree->getOpCode().hasSymbolReference())
{
if (trace())
traceMsg(comp(), "The branch node's first child node %p - its opcode does not have a symbol reference\n", firstChildOfLastTree);
return 0;
}
TR::SymbolReference *firstChildSymRef = firstChildOfLastTree->getSymbolReference();
if (trace())
traceMsg(comp(), "Symbol Reference: %p Symbol: %p\n", firstChildSymRef, firstChildSymRef->getSymbol());
// Locate the induction variable that matches with the exit node symbol
//
TR_InductionVariable *indVar = region->findMatchingIV(firstChildSymRef);
if (!indVar) return 0;
if (!indVar->getIncr()->asIntConst())
{
if (trace())
traceMsg(comp(), "Increment is not a constant\n");
return 0;
}
int32_t increment = indVar->getIncr()->getLowInt();
_visitCount = comp()->incVisitCount();
bool indVarWrittenAndUsedUnexpectedly = false;
if (firstChildOfLastTree->getReferenceCount() > 1)
{
TR::TreeTop *cursorTreeTopInExitBlock = exitBlock->getEntry();
TR::TreeTop *exitTreeTopInExitBlock = exitBlock->getExit();
bool loadSeen = false;
while (cursorTreeTopInExitBlock != exitTreeTopInExitBlock)
{
TR::Node *cursorNode = cursorTreeTopInExitBlock->getNode();
if (checkForLoad(cursorNode, firstChildOfLastTree))
loadSeen = true;
if (!cursorNode->getOpCode().isStore() &&
(cursorNode->getNumChildren() > 0))
cursorNode = cursorNode->getFirstChild();
if (cursorNode->getOpCode().isStore() &&
(cursorNode->getSymbolReference() == firstChildSymRef))
{
indVarWrittenAndUsedUnexpectedly = true;
if ((cursorNode->getFirstChild() == firstChildOfLastTree) ||
!loadSeen)
indVarWrittenAndUsedUnexpectedly = false;
else
//.........这里部分代码省略.........
示例12: simplifyInvariantLoopExpressions
void TR_ExpressionsSimplification::simplifyInvariantLoopExpressions(ListIterator<TR::Block> &blocks)
{
// Need to locate the induction variable of the loop
//
LoopInfo *loopInfo = findLoopInfo(_currentRegion);
if (trace())
{
if (!loopInfo)
{
traceMsg(comp(), "Accurate loop info is not found, cannot carry out summation reduction\n");
}
else
{
traceMsg(comp(), "Accurate loop info has been found, will try to carry out summation reduction\n");
if (loopInfo->getBoundaryNode())
{
traceMsg(comp(), "Variable iterations from node %p has not been handled\n",loopInfo->getBoundaryNode());
}
else
{
traceMsg(comp(), "Natural Loop %p will run %d times\n", _currentRegion, loopInfo->getNumIterations());
}
}
}
// Initialize the list of candidates
//
_candidateTTs = new (trStackMemory()) TR_ScratchList<TR::TreeTop>(trMemory());
for (TR::Block *currentBlock = blocks.getFirst(); currentBlock; currentBlock = blocks.getNext())
{
if (trace())
traceMsg(comp(), "Analyzing block #%d, which must be executed once per iteration\n", currentBlock->getNumber());
// Scan through each node in the block
//
TR::TreeTop *tt = currentBlock->getEntry();
TR::TreeTop *exitTreeTop = currentBlock->getExit();
while (tt != exitTreeTop)
{
TR::Node *currentNode = tt->getNode();
if (trace())
traceMsg(comp(), "Analyzing tree top node %p\n", currentNode);
if (loopInfo)
{
// requires loop info for the number of iterations
setSummationReductionCandidates(currentNode, tt);
}
setStoreMotionCandidates(currentNode, tt);
tt = tt->getNextTreeTop();
}
}
// New code: without using any UDI
// walk through the trees in the loop
// to invalidate the candidates
//
if (!_supportedExpressions)
{
_supportedExpressions = new (trStackMemory()) TR_BitVector(comp()->getNodeCount(), trMemory(), stackAlloc, growable);
}
invalidateCandidates();
ListIterator<TR::TreeTop> treeTops(_candidateTTs);
for (TR::TreeTop *treeTop = treeTops.getFirst(); treeTop; treeTop = treeTops.getNext())
{
if (trace())
traceMsg(comp(), "Candidate TreeTop: %p, Node:%p\n", treeTop, treeTop->getNode());
bool usedCandidate = false;
bool isPreheaderBlockInvalid = false;
if (loopInfo)
{
usedCandidate = tranformSummationReductionCandidate(treeTop, loopInfo, &isPreheaderBlockInvalid);
}
if (isPreheaderBlockInvalid)
{
break;
}
if (!usedCandidate)
{
tranformStoreMotionCandidate(treeTop, &isPreheaderBlockInvalid);
}
if (isPreheaderBlockInvalid)
{
break;
}
}
}
示例13: stackRegion
//.........这里部分代码省略.........
requestOpt(OMR::treeSimplification, true, block);
if (nextTree->getNode()->getOpCodeValue() == TR::Goto
&& prevTree->getNode()->getOpCodeValue() == TR::BBStart
&& !prevTree->getNode()->getBlock()->isExtensionOfPreviousBlock())
{
requestOpt(
OMR::redundantGotoElimination,
prevTree->getNode()->getBlock());
}
}
}
else
{
if (performTransformation(comp(), "%sMove tree : [" POINTER_PRINTF_FORMAT "]([" POINTER_PRINTF_FORMAT "] = %s) to end of block\n", optDetailString(), node, node->getFirstChild(), node->getFirstChild()->getOpCode().getName()))
{
prevTree->join(nextTree);
node->setVisitCount(visitCount);
TR::TreeTop *lastTree = findLastTreetop(block, prevTree);
TR::TreeTop *prevLastTree = lastTree->getPrevTreeTop();
TR::TreeTop *cursorTreeTop = nextTree;
while (cursorTreeTop != lastTree)
{
if (cursorTreeTop->getNode()->getOpCode().isStoreReg() &&
(cursorTreeTop->getNode()->getGlobalRegisterNumber() == iter.currentTree()->getNode()->getGlobalRegisterNumber()))
{
lastTree = cursorTreeTop;
prevLastTree = lastTree->getPrevTreeTop();
break;
}
cursorTreeTop = cursorTreeTop->getNextTreeTop();
}
if (lastTree->getNode()->getOpCodeValue() == TR::BBStart)
{
prevLastTree = lastTree;
lastTree = block->getExit();
}
TR::Node *lastNode = lastTree->getNode();
TR::Node *prevLastNode = prevLastTree->getNode();
if (lastNode->getOpCode().isIf() && !lastNode->getOpCode().isCompBranchOnly() &&
prevLastNode->getOpCode().isStoreReg() &&
((prevLastNode->getFirstChild() == lastNode->getFirstChild()) ||
(prevLastNode->getFirstChild() == lastNode->getSecondChild())))
{
lastTree = prevLastTree;
prevLastTree = lastTree->getPrevTreeTop();
}
prevLastTree->join(iter.currentTree());
iter.currentTree()->join(lastTree);
iter.jumpTo(prevTree);
requestOpt(OMR::treeSimplification, true, block);
}
}
}
}
for (auto it = anchors.begin(); it != anchors.end(); ++it)
{
TR::Node *anchor = it->tree->getNode();
TR::Node *load = anchor->getChild(0);
if (load->getReferenceCount() > 1)
continue;
// We can eliminate the indirect load immediately, but for the moment the
// subtree providing the base object has to be anchored.
TR::Node *heapBase = anchor->getChild(1);
TR::Node::recreate(anchor, TR::treetop);
anchor->setAndIncChild(0, load->getChild(0));
anchor->setChild(1, NULL);
anchor->setNumChildren(1);
if (!heapBase->getOpCode().isLoadConst())
{
it->tree->insertAfter(
TR::TreeTop::create(
comp(),
TR::Node::create(heapBase, TR::treetop, 1, heapBase)));
}
load->recursivelyDecReferenceCount();
heapBase->recursivelyDecReferenceCount();
// A later pass of dead trees can likely move (or even remove) the base
// object expression.
requestOpt(OMR::deadTreesElimination, true, it->block);
}
return 1; // actual cost
}
示例14: if
//.........这里部分代码省略.........
}
else
{
if (node->getOpCode().isCheck() &&
node->getFirstChild()->getOpCode().isCall() &&
node->getFirstChild()->getReferenceCount() == 1 &&
node->getFirstChild()->getSymbolReference()->getSymbol()->isResolvedMethod() &&
node->getFirstChild()->getSymbolReference()->getSymbol()->castToResolvedMethodSymbol()->isSideEffectFree() &&
performTransformation(comp(), "%sRemove dead check of side-effect free call: %p\n", optDetailString(), node))
{
TR::TransformUtil::removeTree(comp(), tt);
removed = true;
}
}
if (removed
&& tt->getNextTreeTop()->getNode()->getOpCodeValue() == TR::Goto
&& tt->getPrevTreeTop()->getNode()->getOpCodeValue() == TR::BBStart
&& !tt->getPrevTreeTop()->getNode()->getBlock()->isExtensionOfPreviousBlock())
{
requestOpt(OMR::redundantGotoElimination, tt->getEnclosingBlock());
}
if (node->getVisitCount() >= visitCount)
continue;
TR::TransformUtil::recursivelySetNodeVisitCount(tt->getNode(), visitCount);
}
// If the last use of an iRegLoad has been removed, then remove the node from
// the BBStart and remove the corresponding dependency node from each of the block's
// predecessors.
//
while (1)
{
bool glRegDepRemoved = false;
for (TR::Block * b = comp()->getStartBlock(); b; b = b->getNextBlock())
{
TR::TreeTop * startTT = b->getEntry();
TR::Node * startNode = startTT->getNode();
if (startNode->getNumChildren() > 0 && !debug("disableEliminationOfGlRegDeps"))
{
TR::Node * glRegDeps = startNode->getFirstChild();
TR_ASSERT(glRegDeps->getOpCodeValue() == TR::GlRegDeps, "expected TR::GlRegDeps");
for (int32_t i = glRegDeps->getNumChildren() - 1; i >= 0; --i)
{
TR::Node * dep = glRegDeps->getChild(i);
if (dep->getReferenceCount() == 1 &&
(!dep->getOpCode().isFloatingPoint() ||
cg()->getSupportsJavaFloatSemantics()) &&
performTransformation(comp(), "%sRemove GlRegDep : %p\n", optDetailString(), glRegDeps->getChild(i)))
{
glRegDeps->removeChild(i);
glRegDepRemoved = true;
TR_GlobalRegisterNumber registerNum = dep->getGlobalRegisterNumber();
for (auto e = b->getPredecessors().begin(); e != b->getPredecessors().end(); ++e)
{
TR::Block * pred = toBlock((*e)->getFrom());
if (pred == comp()->getFlowGraph()->getStart())
continue;
TR::Node * parent = pred->getLastRealTreeTop()->getNode();
if ( parent->getOpCode().isJumpWithMultipleTargets() && parent->getOpCode().hasBranchChildren())
{
for (int32_t j = parent->getCaseIndexUpperBound() - 1; j > 0; --j)
{
TR::Node * caseNode = parent->getChild(j);
TR_ASSERT(caseNode->getOpCode().isCase() || caseNode->getOpCodeValue() == TR::branch,
"having problems navigating a switch");
if (caseNode->getBranchDestination() == startTT &&
caseNode->getNumChildren() > 0 &&
0) // can't do this now that all glRegDeps are hung off the default branch
removeGlRegDep(caseNode, registerNum, pred, this);
}
}
else if (!parent->getOpCode().isReturn() &&
parent->getOpCodeValue() != TR::igoto &&
!( parent->getOpCode().isJumpWithMultipleTargets() && parent->getOpCode().hasBranchChildren()) &&
!(parent->getOpCodeValue()==TR::treetop &&
parent->getFirstChild()->getOpCode().isCall() &&
parent->getFirstChild()->getOpCode().isIndirect()))
{
if (pred->getNextBlock() == b)
parent = pred->getExit()->getNode();
removeGlRegDep(parent, registerNum, pred, this);
}
}
}
}
if (glRegDeps->getNumChildren() == 0)
startNode->removeChild(0);
}
}
if (!glRegDepRemoved)
break;
}
}