Issue 107524
Summary [WebAssembly] AsmTypeCheck does not handle block return values of unreachable block end
Labels backend:WebAssembly
Assignees
Reporter aheejin
    `AsmTypeCheck` does not handle block/loop's concrete return values when their end is not reachable, for example,
```s
block i32
br 0
end
```
This is a valid wasm program but does not pass `AsmTypeCheck`.

Currently Wasm backend does not generate `block`/`loop` return types, but one exception is, the ones generated by `WebAssemblyCFGStackify::fixEndsAtEndOfFunction`:
https://github.com/llvm/llvm-project/blob/093b8bfe6b64c916647ae64af8066df22bb6ea65/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp#L1460-L1520

An example program that would generate this case is
```ll
;; test.ll
target triple = "wasm32-unknown-unknown"

define i32 @loop_i32() {
entry:
  br label %header
header:
  br label %header
}
```
which generates
```s
loop i32
br 0
end
```

The reproducing commands:
```console
$ llc test.ll
$ llvm-mc -triple=wasm32-unknown-unknown test.s
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to