[llvm] [WebAssembly] Allow AsmTypeCheck detect multiple errors in function (PR #109705)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 12:55:28 PDT 2024
aheejin wrote:
> > This is what Wabt and Binaryen wast parsers do as well.
>
> Binaryen's text parser bails out at the first error, although it doesn't do any type checking.
Yeah sorry I should've been clearer.
Test parsing bails out at the first error. For example
```wast
(func $test
(drop
(i32.add
(i32.const 0)
)
)
(drop
(i32.sub
(i32.const 0)
(f32.const 0.0)
)
)
)
```
This will error out at `i32.add` saying
```console
Fatal: 4:7: error: popping from empty stack
```
But as long as the number of stack values are correct, parsing is done and the validator reports multiple errors. For example the program is
```wast
(func $test
(drop
(i32.add
(i32.const 0)
(f32.const 0.0)
)
)
(drop
(i32.sub
(i32.const 0)
(f32.const 0.0)
)
)
)
```
```console
[wasm-validator error in function test] i32 != f32: binary child types must be equal, on
(i32.add
(i32.const 0)
(f32.const 0)
)
[wasm-validator error in function test] i32 != f32: binary child types must be equal, on
(i32.sub
(i32.const 0)
(f32.const 0)
)
Fatal: error validating input
```
---
In case of Wabt it continues in both cases.
Wat file:
```wat
(module
(func
i32.const 0
i32.add
drop
i32.const 0
f32.const 0.0
i32.sub
drop
))
```
Error:
```console
test.txt:7:5: error: type mismatch in i32.add, expected [i32, i32] but got [i32]
i32.add
^^^^^^^
test.txt:11:5: error: type mismatch in i32.sub, expected [i32, i32] but got [i32, f32]
i32.sub
^^^^^^^
```
Wat file:
```wat
(module
(func
i32.const 0
f32.const 0.0
i32.add
drop
i32.const 0
f32.const 0.0
i32.sub
drop
))
```
Error:
```console
test.txt:7:5: error: type mismatch in i32.add, expected [i32, i32] but got [i32, f32]
i32.add
^^^^^^^
test.txt:11:5: error: type mismatch in i32.sub, expected [i32, i32] but got [i32, f32]
i32.sub
^^^^^^^
```
https://github.com/llvm/llvm-project/pull/109705
More information about the llvm-commits
mailing list