Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0.33) Move removal of exception edges to before collecting fixable predecessors #152

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions compiler/optimizer/LocalOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3376,7 +3376,6 @@ int32_t TR_EliminateRedundantGotos::process(TR::TreeTop *startTree, TR::TreeTop
firstNonFenceTree = firstNonFenceTree->getNextRealTreeTop();
}


bool containsTreesOtherThanGoto = false;
if (firstNonFenceTree != lastNonFenceTree &&
!emptyBlock)
Expand Down Expand Up @@ -3440,6 +3439,26 @@ int32_t TR_EliminateRedundantGotos::process(TR::TreeTop *startTree, TR::TreeTop
if (destBlock == block)
continue; // No point trying to "update" predecessors

if (!containsTreesOtherThanGoto && !block->getExceptionSuccessors().empty())
{
// Structure repair doesn't deal well with exception successors in this case.
if (!performTransformation(comp(), "%sRemoving exception successor edges for block_%d\n", optDetailString(), block->getNumber()))
continue; // The exception successors remain, so skip this block

TR::CFGEdgeList &excSuccs = block->getExceptionSuccessors();
while (!excSuccs.empty())
{
if (trace())
{
TR::Block *from = excSuccs.front()->getFrom()->asBlock();
TR::Block *to = excSuccs.front()->getTo()->asBlock();
traceMsg(comp(), "Remove exception edge: block_%d (isValid %d) -> block_%d (isValid %d)\n", from->getNumber(), from->isValid(), to->getNumber(), to->isValid());
}

cfg->removeEdge(excSuccs.front());
}
}

TR::CFGEdgeList fixablePreds(comp()->trMemory()->currentStackRegion());
auto preds = block->getPredecessors();
for (auto inEdge = preds.begin(); inEdge != preds.end(); ++inEdge)
Expand Down Expand Up @@ -3527,19 +3546,6 @@ int32_t TR_EliminateRedundantGotos::process(TR::TreeTop *startTree, TR::TreeTop
//destBlock->setEntry(block->getEntry());
//destBlock->setExit(block->getExit());
}
else
{
if (!block->getExceptionSuccessors().empty())
{
// A block with a goto, only a goto and nothing but the goto needs
// no exception successors (removing them is a good idea in general, but
// structure repair below specifically does not like such nasty nasty
// goto blocks)
//
for (auto edge = block->getExceptionSuccessors().begin(); edge != block->getExceptionSuccessors().end();)
cfg->removeEdge(*(edge++));
}
}

if (emptyBlock &&
!performTransformation(comp(), "%sRemoving empty block_%d with BBStart %p\n", optDetailString(), block->getNumber(), block->getEntry()->getNode()))
Expand Down