summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dataflow/graph.h3
-rw-r--r--test/passes/souperify.txt26
-rw-r--r--test/passes/souperify.wast17
3 files changed, 46 insertions, 0 deletions
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h
index 873c4f218..41b145ee9 100644
--- a/src/dataflow/graph.h
+++ b/src/dataflow/graph.h
@@ -278,6 +278,9 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
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 000000000..657f6e523
--- /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 000000000..97227ed53
--- /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)
+ )
+ )
+ )
+ )
+ )
+)