Commit Graph

10 Commits

Author SHA1 Message Date
Lei Zhang
80c94a4fa8 Change the interfaces of in-memory representation to use pointers.
Previously we use vectors of objects and move semantics to handle
ownership. That approach has the flaw that inserting an object into
the middle of a vector, which may trigger a vector reallocation,
can invalidate some addresses taken from instructions.

Now the in-memory representation internally uses vector of unique
pointers to handle ownership. Since objects are explicitly heap-
allocated now, pointers to them won't be invalidated by vector
resizing anymore.
2016-08-10 12:11:33 -04:00
David Neto
e712f826b6 Hide implementations of BasicBlock::dominates,postdominates 2016-08-05 16:55:21 -04:00
David Neto
3bf4dc102f Add BasicBlock methods: dominates postdominates 2016-08-05 15:14:18 -04:00
David Neto
c978b72477 Fix infinite loop in dominance calculation.
Ensure the dominance calculation visits all nodes in the CFG.
The successor list of the pseudo-entry node is augmented with
a single node in each cycle that otherwise would not be visited.
Similarly, the predecssors list of the pseduo-exit node is augmented
with the a single node in each cycle that otherwise would not
be visited.

Pulls DepthFirstSearch out so it's accessible outside of the dominator
calculation.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/279
2016-07-28 16:40:55 -04:00
Umar Arshad
886dd352d5 Fix several violations of the style guide 2016-06-27 10:45:46 -04:00
David Neto
5065227748 Use pseudo entry and pseudo exit blocks for dominance.
For dominance calculations we use an "augmented" CFG
where we always add a pseudo-entry node that is the predecessor
in the augmented CFG to any nodes that have no predecessors in the
regular CFG.  Similarly, we add a pseudo-exit node that is the
predecessor in the augmented CFG that is a successor to any
node that has no successors in the regular CFG.

Pseudo entry and exit blocks live in the Function object.

Fixes a subtle problem where we were implicitly creating
the block_details for the pseudo-exit node since it didn't
appear in the idoms map, and yet we referenced it.  In such a case the
contents of the block details could be garbage, or zero-initialized.
That sometimes caused incorrect calculation of immediate dominators
and post-dominators.  For example, on a debug build where the details
could be zero-initialized, the dominator of an unreachable block would
be given as the pseudo-exit node.  Bizarre.

Also, enforce the rule that you must have an OpFunctionEnd to close off
the last function.
2016-06-24 17:08:20 -04:00
Umar Arshad
f61db0bcc6 Validator structured flow checks: back-edge, constructs
Skip structured control flow chekcs for non-shader capability.

Fix infinite loop in dominator algorithm when there's an
unreachable block.
2016-06-22 11:51:19 -04:00
Lei Zhang
10dba91781 Use SPIR-V headers from the KhronosGroup/SPIRV-Headers repo. 2016-06-10 08:48:37 -04:00
Umar Arshad
e3dcaf5610 Refactor depth first traversal to be more generic
Refactor the way the post order vector is created. This new method
will allow for the extraction of backedges and create the post order
vector in one pass.
2016-06-10 06:39:42 -04:00
Umar Arshad
90a4252aae Split validate_types file into multiple classes
Creates separate files for the ValidationState, Function and
BasicBlock classes.
2016-06-08 14:40:33 -04:00