From 8a88ba280b2847d4d25d0859a87529e2132ebab8 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 13 Dec 2024 13:23:42 -0800 Subject: Support control flow inputs in IRBuilder (#7149) Since multivalue was standardized, WebAssembly has supported not only multiple results but also an arbitrary number of inputs on control flow structures, but until now Binaryen did not support control flow input. Binaryen IR still has no way to represent control flow input, so lower it away using scratch locals in IRBuilder. Since both the text and binary parsers use IRBuilder, this gives us full support for parsing control flow inputs. The lowering scheme is mostly simple. A local.set writing the control flow inputs to a scratch local is inserted immediately before the control flow structure begins and a local.get retrieving those inputs is inserted inside the control flow structure before the rest of its body. The only complications come from ifs, in which the inputs must be retrieved at the beginning of both arms, and from loops, where branches to the beginning of the loop must be transformed so their values are written to the scratch local along the way. Resolves #6407. --- test/lit/binary/bad-multivalue-if.test | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 test/lit/binary/bad-multivalue-if.test (limited to 'test/lit/binary/bad-multivalue-if.test') diff --git a/test/lit/binary/bad-multivalue-if.test b/test/lit/binary/bad-multivalue-if.test deleted file mode 100644 index 8fe206012..000000000 --- a/test/lit/binary/bad-multivalue-if.test +++ /dev/null @@ -1,22 +0,0 @@ -;; Test that we error properly on an if with a bad multivalue (inputs). - -;; File contents: -;; -;; (module -;; (func $test -;; i32.const 0 -;; i32.const 1 -;; (if (param i32) -;; (then -;; drop -;; ) -;; (else -;; drop -;; ) -;; ) -;; ) -;; ) - -;; RUN: not wasm-opt -all %s.wasm 2>&1 | filecheck %s - -;; CHECK: control flow inputs are not supported yet -- cgit v1.2.3