This is the last functional patch affecting the representation of DDG. Here we try to simplify the DDG to reduce the number of nodes and edges by iteratively merging pairs of nodes that satisfy the following conditions, until no such pair can be identified. A pair of nodes consisting of a and b can be merged if:
- the only edge from a is a def-use edge to b and
- the only edge to b is a def-use edge from a and
- there is no cyclic edge from b to a and
- all instructions in a and b belong to the same basic block and
- both a and b are simple (single or multi instruction) nodes.
These criteria allow us to fold many uninteresting def-use edges that commonly exist in the graph while avoiding the risk of introducing dependencies that didn't exist before. For example consider a graph G defined as: { (a)->(b), (b)->(c), (a)->(d) }
The edge in between (b) and (c) can be folded to give us { (a)->(bc), (a)->(d) }
Note that folding any of the other edges is not legal. For example if the edge between (a) and (b) is folded, then a new (incorrect) dependence between (b) and (d) is introduced due to the dependency between (a) and (d).
clang-format: please reformat the code