Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0 |
|
#
dbc59007 |
| 16-Sep-2024 |
Heejin Ahn <aheejin@gmail.com> |
[WebAssembly] Fix .functype directives in tests (#108748)
For defined functions, it appears `.functype` directive should be after
the function label. Otherwise binary generation does not seem to wo
[WebAssembly] Fix .functype directives in tests (#108748)
For defined functions, it appears `.functype` directive should be after
the function label. Otherwise binary generation does not seem to work
correctly. Also this fixes a case that the `.functype` directive's name
is incorrect.
show more ...
|
Revision tags: llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
#
78f01f69 |
| 05-Jan-2023 |
Heejin Ahn <aheejin@gmail.com> |
[WebAssembly] Ensure 'end_function' in functions
Local info is supposed to be emitted in the start of every function. When there are locals, `.local` section should be present, and we emit local inf
[WebAssembly] Ensure 'end_function' in functions
Local info is supposed to be emitted in the start of every function. When there are locals, `.local` section should be present, and we emit local info according to the section.
If there is no locals, empty local info should be emitted. This empty local info is emitted whenever a first instruction is emitted within a function without encountering a `.local` section. If there is no instruction, `end_function` pseudo instruction should be present and the empty local info will be emitted when parsing the pseudo instruction.
The following assembly is malformed because the function `test` doesn't have an `end_function` at the end, and the parser doesn't end up emitting the empty local info needed. But currently we don't error out and silently produce an invalid binary. ``` .functype test () -> () test: ```
This patch adds one extra state to the Wasm assembly parser, `FunctionLabel` to detect whether a function label is parsed but not ended properly when the next function starts or the file ends.
It is somewhat tricky to distinguish `FunctionLabel` and `FunctionStart`, because it is not always possible to ensure the state goes from `FunctionLabel` -> `FunctionStart`. `.functype` directive does not seem to be mandated before a function label, in which case we don't know if the label is a function at the time of parsing. But when we do know the label is function, we would like to ensure it ends with an `end_function` properly. Also we would like to error out when it does not.
For example, ``` .functype test() -> () test: ``` We should error out for this because we know `test` is a function and it doesn't end with an `end_function`. This PR fixes this.
``` test: ``` We don't error out for this because there is no info that `test` is a function, so we don't know whether there should be an `end_function` or not.
``` test: .functype test() -> () ``` We error out for this currently already, because we currently switch to `FunctionStart` state when we first see `.functype` directive after its label definition.
Fixes https://github.com/llvm/llvm-project/issues/57427.
Reviewed By: sbc100
Differential Revision: https://reviews.llvm.org/D141103
show more ...
|