Class CFGTranslationPhaseThree
java.lang.Object
org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseThree
Class that performs phase three of the translation process. In particular, the following
 degenerate cases of basic blocks are removed:
 
- Empty regular basic blocks: These blocks will be removed and their predecessors linked directly to the successor.
- Conditional basic blocks that have the same basic block as the 'then' and 'else' successor: The conditional basic block will be removed in this case.
- Two consecutive, non-empty, regular basic blocks where the second block has exactly one predecessor (namely the other of the two blocks): In this case, the two blocks are merged.
- Some basic blocks might not be reachable from the entryBlock. These basic blocks are removed, and the list of predecessors (in the doubly-linked structure of basic blocks) are adapted correctly.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static interfaceA simple wrapper object that holds a basic block and allows to set one of its successors.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected static BlockImplcomputeNeighborhoodOfEmptyBlock(RegularBlockImpl start, Set<RegularBlockImpl> emptyBlocks, Set<CFGTranslationPhaseThree.PredecessorHolder> predecessors) Compute the set of empty regular basic blocksemptyBlocks, starting atstartand going both forward and backwards.protected static voidcomputeNeighborhoodOfEmptyBlockBackwards(RegularBlockImpl start, Set<RegularBlockImpl> emptyBlocks, Set<CFGTranslationPhaseThree.PredecessorHolder> predecessors) Compute the set of empty regular basic blocksemptyBlocks, starting atstartand looking only backwards in the control flow graph.protected static CFGTranslationPhaseThree.PredecessorHoldergetPredecessorHolder(BlockImpl pred, BlockImpl cur) Return a predecessor holder that can be used to set the successor ofpredin the place where previously the edge pointed tocur.protected static voidSimplify the CFG by merging consecutive single-successor blocks.static ControlFlowGraphprocess(ControlFlowGraph cfg) Perform phase three on the control flow graphcfg.protected static CFGTranslationPhaseThree.PredecessorHolderReturns aCFGTranslationPhaseThree.PredecessorHolderthat sets the successor of a single successor blocks.
- 
Constructor Details- 
CFGTranslationPhaseThreepublic CFGTranslationPhaseThree()
 
- 
- 
Method Details- 
processPerform phase three on the control flow graphcfg.- Parameters:
- cfg- the control flow graph. Ownership is transfered to this method and the caller is not allowed to read or modify- cfgafter the call to- processany more.
- Returns:
- the resulting control flow graph
 
- 
mergeConsecutiveBlocksSimplify the CFG by merging consecutive single-successor blocks.- Parameters:
- cfg- the control flow graph
 
- 
computeNeighborhoodOfEmptyBlockprotected static BlockImpl computeNeighborhoodOfEmptyBlock(RegularBlockImpl start, Set<RegularBlockImpl> emptyBlocks, Set<CFGTranslationPhaseThree.PredecessorHolder> predecessors) Compute the set of empty regular basic blocksemptyBlocks, starting atstartand going both forward and backwards. Furthermore, compute the predecessors of these empty blocks (predecessors), and their single successor (return value).- Parameters:
- start- the starting point of the search (an empty, regular basic block)
- emptyBlocks- a set to be filled by this method with all empty basic blocks found (including- start).
- predecessors- a set to be filled by this method with all predecessors
- Returns:
- the single successor of the set of the empty basic blocks
 
- 
computeNeighborhoodOfEmptyBlockBackwardsprotected static void computeNeighborhoodOfEmptyBlockBackwards(RegularBlockImpl start, Set<RegularBlockImpl> emptyBlocks, Set<CFGTranslationPhaseThree.PredecessorHolder> predecessors) Compute the set of empty regular basic blocksemptyBlocks, starting atstartand looking only backwards in the control flow graph. Furthermore, compute the predecessors of these empty blocks (predecessors).- Parameters:
- start- the starting point of the search (an empty, regular basic block)
- emptyBlocks- a set to be filled by this method with all empty basic blocks found (including- start).
- predecessors- a set to be filled by this method with all predecessors
 
- 
getPredecessorHolderprotected static CFGTranslationPhaseThree.PredecessorHolder getPredecessorHolder(BlockImpl pred, BlockImpl cur) Return a predecessor holder that can be used to set the successor ofpredin the place where previously the edge pointed tocur. Additionally, the predecessor holder also takes care of unlinking (i.e., removing thepredfromcur'spredecessors).- Parameters:
- pred- a block whose successor should be set
- cur- the previous successor of- pred
- Returns:
- a predecessor holder to set the successor of pred
 
- 
singleSuccessorHolderprotected static CFGTranslationPhaseThree.PredecessorHolder singleSuccessorHolder(SingleSuccessorBlockImpl s, BlockImpl old) Returns aCFGTranslationPhaseThree.PredecessorHolderthat sets the successor of a single successor blocks.- Returns:
- a CFGTranslationPhaseThree.PredecessorHolderthat sets the successor of a single successor blocks
 
 
-