diff options
-rw-r--r-- | src/passes/Outlining.cpp | 3 | ||||
-rw-r--r-- | test/lit/passes/outlining.wast | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/passes/Outlining.cpp b/src/passes/Outlining.cpp index 433889d37..345b3f9a2 100644 --- a/src/passes/Outlining.cpp +++ b/src/passes/Outlining.cpp @@ -103,6 +103,9 @@ struct ReconstructStringifyWalker } else if (reason.getElseStart()) { ASSERT_OK(existingBuilder.visitElse()); DBG(desc = "Else Start at "); + } else if (auto curr = reason.getLoopStart()) { + ASSERT_OK(existingBuilder.visitLoopStart(curr->loop)); + DBG(desc = "Loop Start at "); } else if (reason.getEnd()) { ASSERT_OK(existingBuilder.visitEnd()); // Outlining performs an unnested walk of the Wasm module, visiting diff --git a/test/lit/passes/outlining.wast b/test/lit/passes/outlining.wast index 98cb5a316..1c5ec06bd 100644 --- a/test/lit/passes/outlining.wast +++ b/test/lit/passes/outlining.wast @@ -726,3 +726,40 @@ ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: ) + +;; Outline a loop +;; TODO: Ideally, a loop (like any control flow) repeated within a program can +;; be outlined by itself. Right now this is not possible since a control flow +;; is represented by a single symbol and only sequences of symbols >= 2 are +;; candidates for outlining. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $outline$ (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop-in + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $a (type $0) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + (func $a + (drop + (i32.const 0) + ) + (loop (nop)) + ) + ;; CHECK: (func $b (type $0) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + (func $b + (drop + (i32.const 0) + ) + (loop (nop)) + ) +) |