[PATCH] D147504: [WebAssembly] `AsmTypeCheck` support to br instr

Congcong Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 9 11:58:14 PDT 2023


HerrCai0907 marked 8 inline comments as done.
HerrCai0907 added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp:448-449
                                                        " missing .tagtype");
-    // catch instruction pushes values whose types are specified in the tag's
-    // "params" part
+    // if nest structure is good, last BrStack is operand stack in try instr;
+    Stack = BrStack.back().getEnterStack();
+    // catch instruction pushes values whose types are specified in the
----------------
HerrCai0907 wrote:
> aheejin wrote:
> > I don't think we should restore try's `EnterStack` here? In a `catch` body, the only input params are the caught values, not the `try`'s input types.
> The semantic of catch instructions in `try [T1->T2] catch [T3]` is [T2 -> T3]. 
> If we don't restore the stack, we will get a incorrect stack after end_try.
> For example
> ```
> .tagtype TAG f32
> i32.const 1
> try i32
>     f32.const 1.0
>     throw TAG
>     // here ok because unreachable
>     drop
> catch TAG
>     i32.trunc_f32_s
> end_try
> // here type stack is [i32, i32] but without restore we will get error
```
block [T1] 
    xxxxx
end_block
try [T1->T2]
    instr1*
catch [T3]
    instr2*
end_try
```
after instr1*, the type stack should [T2] and without restore we push T3. After instr2, we will get [T2, T2] which is not incorrect


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147504/new/

https://reviews.llvm.org/D147504



More information about the llvm-commits mailing list