diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h index 873c4f21818..41b145ee9ac 100644 --- a/src/dataflow/graph.h +++ b/src/dataflow/graph.h @@ -278,6 +278,9 @@ struct Graph : public UnifiedExpressionVisitor { return &bad; } Node* doVisitLoop(Loop* curr) { + auto* oldParent = parent; + expressionParentMap[curr] = oldParent; + parent = curr; // As in Souper's LLVM extractor, we avoid loop phis, as we don't want // our traces to represent a value that differs across loop iterations. // For example, diff --git a/test/passes/souperify.txt b/test/passes/souperify.txt new file mode 100644 index 00000000000..657f6e52353 --- /dev/null +++ b/test/passes/souperify.txt @@ -0,0 +1,26 @@ + +; function: if-loop-test + +; start LHS (in if-loop-test) +%0 = sub 0:i32, 0:i32 +%1 = ne 0:i32, 0:i32 +pc %1 1:i1 +infer %0 + +(module + (type $FUNCSIG$v (func)) + (func $if-loop-test (; 0 ;) (type $FUNCSIG$v) + (local $0 i32) + (if + (i32.const 0) + (loop $label$0 + (local.set $0 + (i32.sub + (i32.const 0) + (i32.const 0) + ) + ) + ) + ) + ) +) diff --git a/test/passes/souperify.wast b/test/passes/souperify.wast new file mode 100644 index 00000000000..97227ed5343 --- /dev/null +++ b/test/passes/souperify.wast @@ -0,0 +1,17 @@ +(module + ;; This tests if we can create dataflow graph correctly in the presence of + ;; loops. + (func $if-loop-test (local $0 i32) + (if + (i32.const 0) + (loop $label$0 + (local.set $0 + (i32.sub + (i32.const 0) + (i32.const 0) + ) + ) + ) + ) + ) +)