GP-4582 Make sure newBlockMultiGoto preserves any self edge

This commit is contained in:
caheckman 2024-06-11 19:09:46 +00:00
parent e6112ce481
commit 464e33cf08
3 changed files with 38 additions and 16 deletions

View file

@ -1674,13 +1674,20 @@ BlockMultiGoto *BlockGraph::newBlockMultiGoto(FlowBlock *bl,int4 outedge)
}
else {
ret = new BlockMultiGoto(bl);
int4 origSizeOut = bl->sizeOut();
vector<FlowBlock *> nodes;
nodes.push_back(bl);
identifyInternal(ret,nodes);
addBlock(ret);
ret->addEdge(targetbl);
if (targetbl != bl) // If the target is itself, edge is already removed by identifyInternal
removeEdge(ret,targetbl);
if (targetbl != bl) {
if (ret->sizeOut() != origSizeOut) { // If there are less out edges after identifyInternal
// it must have collapsed a self edge (switch out edges are already deduped)
ret->forceOutputNum(ret->sizeOut()+1); // preserve the self edge (it is not the goto edge)
}
removeEdge(ret,targetbl); // Remove the edge to the goto target
}
// else -- the goto edge is a self edge and will get removed by identifyInternal
if (isdefaultedge)
ret->setDefaultGoto();
}