mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
538b137e0b
This to protect against non-sensical instruction sequences being assembled, which would either cause asserts/crashes further down, or a Wasm module being output that doesn't validate. Unlike a validator, this type checker is able to give type-errors as part of the parsing process, which makes the assembler much friendlier to be used by humans writing manual input. Because the MC system is single pass (instructions aren't even stored in MC format, they are directly output) the type checker has to be single pass as well, which means that from now on .globaltype and .functype decls must come before their use. An extra pass is added to Codegen to collect information for this purpose, since AsmPrinter is normally single pass / streaming as well, and would otherwise generate this information on the fly. A `-no-type-check` flag was added to llvm-mc (and any other tools that take asm input) that surpresses type errors, as a quick escape hatch for tests that were not intended to be type correct. This is a first version of the type checker that ignores control flow, i.e. it checks that types are correct along the linear path, but not the branch path. This will still catch most errors. Branch checking could be added in the future. Differential Revision: https://reviews.llvm.org/D104945
27 lines
837 B
ArmAsm
27 lines
837 B
ArmAsm
# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s
|
|
# RUN: llvm-objdump --triple=wasm32-unknown-unknown -d %t.o | FileCheck %s
|
|
|
|
test0:
|
|
.functype test0 (i32, i64) -> (f32)
|
|
.local f32, f64, v128, v128
|
|
local.get 2
|
|
end_function
|
|
|
|
test1:
|
|
.functype test1 (i32, i64) -> (i64)
|
|
.local i32, i64, funcref
|
|
local.get 3
|
|
end_function
|
|
|
|
|
|
# CHECK-LABEL: CODE:
|
|
# CHECK: # 2 functions in section.
|
|
# CHECK-LABEL: <test0>:
|
|
# CHECK-NEXT: .local f32, f64, v128, v128
|
|
# CHECK-NEXT: 9: 20 02 local.get 2
|
|
# CHECK-NEXT: b: 0b end
|
|
# CHECK-LABEL: <test1>:
|
|
# CHECK-NEXT: .local i32, i64, funcref
|
|
# CHECK-NEXT: 14: 20 03 local.get 3
|
|
# CHECK-NEXT: 16: 0b end
|