Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HansKristian-Work/dxil-spirv.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-07-15 16:24:18 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-07-15 16:24:18 +0300
commitd8acedfdd7b79c2cae6aa01b16927a488c0db41b (patch)
tree5f1a45e8a86ba9b7d90dd339193a4c5d4b296946
parent873d0a2b582fc9aef970d188e04a23d9fab28c1d (diff)
Don't introduce cycles when retargeting branches.
Domination is not enough.
-rw-r--r--cfg_structurizer.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/cfg_structurizer.cpp b/cfg_structurizer.cpp
index 7432735..2ff4b5a 100644
--- a/cfg_structurizer.cpp
+++ b/cfg_structurizer.cpp
@@ -4255,7 +4255,17 @@ void CFGStructurizer::traverse_dominated_blocks_and_rewrite_branch(const CFGNode
{
// Don't introduce a cycle.
// We only retarget branches when we have "escape-like" edges.
- if (!to->dominates(candidate))
+ bool introduces_cycle;
+
+ if (to->forward_post_visit_order == candidate->forward_post_visit_order && to != candidate)
+ {
+ // Can happen when resolving ladders. We cannot use reachability query, do it slow way.
+ introduces_cycle = candidate->can_backtrace_to(to);
+ }
+ else
+ introduces_cycle = query_reachability(*to, *candidate);
+
+ if (!introduces_cycle)
{
// If we already have a branch to "to", need to branch there via an intermediate node.
// This way, we can distinguish between a normal branch and a rewritten branch.