[PATCH] D104945: [WebAssembly] Added initial type checker to MC Assembler
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 12:43:35 PDT 2021
aardappel created this revision.
aardappel added reviewers: sbc100, dschuff.
Herald added subscribers: jdoerfert, ecnelises, jfb, arphaman, sunfish, hiraditya, jgravelle-google, mgorny.
aardappel requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
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.
https://reviews.llvm.org/D104945
Files:
lld/test/wasm/Inputs/call-ret32.s
lld/test/wasm/Inputs/ctor-lib.s
lld/test/wasm/Inputs/ctor-setup-call-def.s
lld/test/wasm/Inputs/ctor-setup.s
lld/test/wasm/Inputs/ctor-start.s
lld/test/wasm/Inputs/hello.s
lld/test/wasm/Inputs/import-attributes.s
lld/test/wasm/Inputs/sig_mismatch.s
lld/test/wasm/Inputs/undefined-globals.s
lld/test/wasm/bsymbolic.s
lld/test/wasm/comdat-sections.s
lld/test/wasm/ctor_return_value.s
lld/test/wasm/debuginfo-undefined-global.s
lld/test/wasm/demangle.s
lld/test/wasm/early-exit-for-bad-paths.s
lld/test/wasm/entry-signature.s
lld/test/wasm/export-all.s
lld/test/wasm/export-optional.s
lld/test/wasm/gc-imports.s
lld/test/wasm/import-attribute-mismatch.s
lld/test/wasm/map-file.s
lld/test/wasm/multivalue-return-func-types.s
lld/test/wasm/mutable-globals.s
lld/test/wasm/name-section-mangling.s
lld/test/wasm/relocatable-comdat.s
lld/test/wasm/relocation-bad-tls.s
lld/test/wasm/shared.s
lld/test/wasm/shared64.s
lld/test/wasm/signature-mismatch-relocatable.s
lld/test/wasm/undefined-data.s
lld/test/wasm/undefined-weak-call.s
lld/test/wasm/unresolved-symbols.s
lld/test/wasm/weak-and-strong-undef.s
lld/test/wasm/weak-symbols.s
lld/test/wasm/weak-undefined-pic.s
lld/test/wasm/weak-undefined.s
llvm/include/llvm/CodeGen/MachineModuleInfo.h
llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/CodeGen/MachineModuleInfoImpls.cpp
llvm/lib/MC/MCTargetOptions.cpp
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/CMakeLists.txt
llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.h
llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
llvm/lib/Target/WebAssembly/WebAssembly.h
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrFormats.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyMCLowerPrePass.cpp
llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.h
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/test/CodeGen/WebAssembly/exception.ll
llvm/test/CodeGen/WebAssembly/global-get.ll
llvm/test/CodeGen/WebAssembly/i128-returned.ll
llvm/test/CodeGen/WebAssembly/indirect-import.ll
llvm/test/CodeGen/WebAssembly/load-store-pic.ll
llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
llvm/test/CodeGen/WebAssembly/lower-global-dtors.ll
llvm/test/CodeGen/WebAssembly/userstack.ll
llvm/test/MC/WebAssembly/alias-offset.s
llvm/test/MC/WebAssembly/annotations.s
llvm/test/MC/WebAssembly/assembler-binary.ll
llvm/test/MC/WebAssembly/atomics-encodings.s
llvm/test/MC/WebAssembly/bad-fixup-expr.s
llvm/test/MC/WebAssembly/basic-assembly.s
llvm/test/MC/WebAssembly/bulk-memory-encodings.s
llvm/test/MC/WebAssembly/data-section-combined.s
llvm/test/MC/WebAssembly/globals.s
llvm/test/MC/WebAssembly/import-module.s
llvm/test/MC/WebAssembly/null-output.s
llvm/test/MC/WebAssembly/objdump.s
llvm/test/MC/WebAssembly/reference-types.s
llvm/test/MC/WebAssembly/reloc-pic.s
llvm/test/MC/WebAssembly/reloc-pic64.s
llvm/test/MC/WebAssembly/simd-encodings.s
llvm/test/MC/WebAssembly/tail-call-encodings.s
llvm/test/MC/WebAssembly/tls.s
llvm/test/MC/WebAssembly/type-index.s
llvm/test/MC/WebAssembly/wasm64.s
llvm/test/MC/WebAssembly/weak-alias.s
llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104945.354584.patch
Type: text/x-patch
Size: 104212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210625/17d92402/attachment.bin>
More information about the llvm-commits
mailing list