[all-commits] [llvm/llvm-project] 9647a6: [WebAssembly] Added initial type checker to MC Ass...

Wouter van Oortmerssen via All-commits all-commits at lists.llvm.org
Fri Jul 9 14:08:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9647a6f719ee4b1c23eea7aef368c1dcd5317949
      https://github.com/llvm/llvm-project/commit/9647a6f719ee4b1c23eea7aef368c1dcd5317949
  Author: Wouter van Oortmerssen <aardappel at gmail.com>
  Date:   2021-07-09 (Fri, 09 Jul 2021)

  Changed paths:
    M lld/test/wasm/Inputs/call-ret32.s
    M lld/test/wasm/Inputs/ctor-lib.s
    M lld/test/wasm/Inputs/ctor-setup-call-def.s
    M lld/test/wasm/Inputs/ctor-setup.s
    M lld/test/wasm/Inputs/ctor-start.s
    M lld/test/wasm/Inputs/hello.s
    M lld/test/wasm/Inputs/import-attributes.s
    M lld/test/wasm/Inputs/sig_mismatch.s
    M lld/test/wasm/Inputs/undefined-globals.s
    M lld/test/wasm/bsymbolic.s
    M lld/test/wasm/comdat-sections.s
    M lld/test/wasm/ctor_return_value.s
    M lld/test/wasm/debuginfo-undefined-global.s
    M lld/test/wasm/demangle.s
    M lld/test/wasm/early-exit-for-bad-paths.s
    M lld/test/wasm/entry-signature.s
    M lld/test/wasm/export-all.s
    M lld/test/wasm/export-optional.s
    M lld/test/wasm/gc-imports.s
    M lld/test/wasm/import-attribute-mismatch.s
    M lld/test/wasm/map-file.s
    M lld/test/wasm/multivalue-return-func-types.s
    M lld/test/wasm/mutable-globals.s
    M lld/test/wasm/name-section-mangling.s
    M lld/test/wasm/relocatable-comdat.s
    M lld/test/wasm/relocation-bad-tls.s
    M lld/test/wasm/shared.s
    M lld/test/wasm/shared64.s
    M lld/test/wasm/signature-mismatch-relocatable.s
    M lld/test/wasm/undefined-data.s
    M lld/test/wasm/undefined-weak-call.s
    M lld/test/wasm/unresolved-symbols.s
    M lld/test/wasm/weak-and-strong-undef.s
    M lld/test/wasm/weak-symbols.s
    M lld/test/wasm/weak-undefined-pic.s
    M lld/test/wasm/weak-undefined.s
    M llvm/include/llvm/CodeGen/MachineModuleInfo.h
    M llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
    M llvm/include/llvm/MC/MCTargetOptions.h
    M llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
    M llvm/lib/CodeGen/MachineModuleInfoImpls.cpp
    M llvm/lib/MC/MCTargetOptions.cpp
    M llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
    M llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
    M llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
    A llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
    A llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.h
    M llvm/lib/Target/WebAssembly/CMakeLists.txt
    M llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.h
    M llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
    M llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
    M llvm/lib/Target/WebAssembly/WebAssembly.h
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
    M llvm/lib/Target/WebAssembly/WebAssemblyInstrFormats.td
    M llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
    M llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
    M llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
    A llvm/lib/Target/WebAssembly/WebAssemblyMCLowerPrePass.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.h
    M llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
    M llvm/test/CodeGen/WebAssembly/exception.ll
    M llvm/test/CodeGen/WebAssembly/global-get.ll
    M llvm/test/CodeGen/WebAssembly/i128-returned.ll
    M llvm/test/CodeGen/WebAssembly/indirect-import.ll
    M llvm/test/CodeGen/WebAssembly/load-store-pic.ll
    M llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
    M llvm/test/CodeGen/WebAssembly/lower-global-dtors.ll
    M llvm/test/CodeGen/WebAssembly/userstack.ll
    M llvm/test/MC/WebAssembly/alias-offset.s
    M llvm/test/MC/WebAssembly/annotations.s
    M llvm/test/MC/WebAssembly/assembler-binary.ll
    M llvm/test/MC/WebAssembly/atomics-encodings.s
    M llvm/test/MC/WebAssembly/bad-fixup-expr.s
    M llvm/test/MC/WebAssembly/basic-assembly.s
    M llvm/test/MC/WebAssembly/bulk-memory-encodings.s
    M llvm/test/MC/WebAssembly/data-section-combined.s
    M llvm/test/MC/WebAssembly/globals.s
    M llvm/test/MC/WebAssembly/import-module.s
    M llvm/test/MC/WebAssembly/null-output.s
    M llvm/test/MC/WebAssembly/objdump.s
    M llvm/test/MC/WebAssembly/reference-types.s
    M llvm/test/MC/WebAssembly/reloc-pic.s
    M llvm/test/MC/WebAssembly/reloc-pic64.s
    M llvm/test/MC/WebAssembly/simd-encodings.s
    M llvm/test/MC/WebAssembly/tail-call-encodings.s
    M llvm/test/MC/WebAssembly/tls.s
    M llvm/test/MC/WebAssembly/type-index.s
    M llvm/test/MC/WebAssembly/wasm64.s
    M llvm/test/MC/WebAssembly/weak-alias.s
    M llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/AsmParser/BUILD.gn
    M llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn

  Log Message:
  -----------
  [WebAssembly] Added initial type checker to MC Assembler

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




More information about the All-commits mailing list