-
Notifications
You must be signed in to change notification settings - Fork 396
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
BenefitInliner: Add structural analysis by using given CFG and add _hasBackEdges flag when generating CFG #7268
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,18 +44,32 @@ TR_Dominators::TR_Dominators(TR::Compilation *c, bool post) : | |
_info(c->getFlowGraph()->getNextNodeNumber()+1, BBInfo(_region), _region), | ||
_dfNumbers(c->getFlowGraph()->getNextNodeNumber()+1, 0, _region), | ||
_dominators(c->getFlowGraph()->getNextNodeNumber()+1, static_cast<TR::Block *>(NULL), _region) | ||
{ | ||
construct(c->getFlowGraph(), post); | ||
} | ||
|
||
TR_Dominators::TR_Dominators(TR::Compilation *c, TR::CFG* cfg, bool acceptUnreachableBlocks, bool post) : | ||
_region(c->trMemory()->heapMemoryRegion()), | ||
_compilation(c), | ||
_info(cfg->getNextNodeNumber()+1, BBInfo(_region), _region), | ||
_dfNumbers(cfg->getNextNodeNumber()+1, 0, _region), | ||
_dominators(cfg->getNextNodeNumber()+1, static_cast<TR::Block *>(NULL), _region) | ||
{ | ||
construct(cfg, post, acceptUnreachableBlocks); | ||
} | ||
|
||
void TR_Dominators::construct(TR::CFG* cfg, bool post, bool acceptUnreachableBlocks) | ||
{ | ||
LexicalTimer tlex("TR_Dominators::TR_Dominators", _compilation->phaseTimer()); | ||
|
||
_postDominators = post; | ||
_isValid = true; | ||
_hasUnreachableBlocks = false; | ||
_topDfNum = 0; | ||
_visitCount = c->incOrResetVisitCount(); | ||
_visitCount = _compilation->incOrResetVisitCount(); | ||
_trace = comp()->getOption(TR_TraceDominators); | ||
|
||
TR::CFG *cfg = c->getFlowGraph(); | ||
|
||
_cfg = c->getFlowGraph(); | ||
_cfg = cfg; | ||
_numNodes = cfg->getNumberOfNodes()+1; | ||
|
||
if (trace()) | ||
|
@@ -80,7 +94,7 @@ TR_Dominators::TR_Dominators(TR::Compilation *c, bool post) : | |
_dominators[dominated->getNumber()] = dominator; | ||
if (trace()) | ||
traceMsg(comp(), " %sDominator of block_%d is block_%d\n", _postDominators ? "post-" : "", | ||
dominated->getNumber(), dominator->getNumber()); | ||
dominated->getNumber(), dominator->getNumber()); | ||
} | ||
|
||
// The exit block may not be reachable from the entry node. In this case just | ||
|
@@ -110,15 +124,22 @@ TR_Dominators::TR_Dominators(TR::Compilation *c, bool post) : | |
traceMsg(comp(), "Some blocks are not reachable from exit. Post-dominator info is invalid.\n"); | ||
return; | ||
} | ||
if (!acceptUnreachableBlocks) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that the name It might be better to have the name describe the input, e.g. what do you think of |
||
{ | ||
_hasUnreachableBlocks = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please stick with |
||
if (trace()) | ||
traceMsg(comp(), "Unreachable block in the CFG %d %d\n", _topDfNum, _numNodes-1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this message mention that the dominators are therefore invalid, like in the postdominator case? |
||
return; | ||
} | ||
else | ||
TR_ASSERT(false, "Unreachable block in the CFG %d %d", _topDfNum, _numNodes-1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind adding a |
||
} | ||
|
||
#if DEBUG | ||
for (auto block = toBlock(cfg->getFirstNode()); block; block = toBlock(block->getNext())) | ||
{ | ||
{ | ||
TR_ASSERT(_dfNumbers[block->getNumber()] >= 0, "Unreachable block in the CFG"); | ||
} | ||
} | ||
#endif | ||
|
||
if (trace()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,11 +53,14 @@ class TR_Dominators | |
TR_ALLOC(TR_Memory::Dominators) | ||
|
||
TR_Dominators(TR::Compilation *, bool post = false); | ||
TR_Dominators(TR::Compilation *, TR::CFG* cfg, bool acceptUnreachableBlocks = true, bool post = false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does |
||
TR::Block *getDominator(TR::Block *); | ||
int dominates(TR::Block *block, TR::Block *other); | ||
|
||
TR::Compilation * comp() { return _compilation; } | ||
bool trace() { return _trace; } | ||
bool isValid() { return _isValid; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a comment to
|
||
bool hasUnreachableBlocks() { return _hasUnreachableBlocks; } | ||
|
||
protected: | ||
|
||
|
@@ -113,6 +116,8 @@ class TR_Dominators | |
int32_t parent; | ||
}; | ||
|
||
void construct(TR::CFG* cfg, bool post, bool acceptUnreachableBlocks = true); | ||
|
||
BBInfo& getInfo(int32_t index) {return _info[index];} | ||
int32_t blockNumber(int32_t index) {return _info[index]._block->getNumber();} | ||
|
||
|
@@ -133,6 +138,7 @@ class TR_Dominators | |
int32_t _numNodes; | ||
int32_t _topDfNum; | ||
vcount_t _visitCount; | ||
bool _hasUnreachableBlocks; | ||
|
||
protected: | ||
TR::CFG * _cfg; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This state isn't meaningfully set or used in this PR - I assume it's used in eclipse-openj9/openj9#17813
Does this need to be on the CFG? Or could it be kept somewhere else instead? e.g. next to a CFG pointer in the code that cares about it. I'm just worried that it will easily get out of date. In fact, with the fixed initial value (false), it will immediately be out of date for many CFGs. (And that would still be the case if the fixed initial value were true instead.)