[WebAssembly] Target features section
authorThomas Lively <tlively@google.com>
Wed, 20 Mar 2019 20:26:45 +0000 (20:26 +0000)
committerThomas Lively <tlively@google.com>
Wed, 20 Mar 2019 20:26:45 +0000 (20:26 +0000)
commitf6f4f84378ea07e8cb976631dd82079c027d7cf4
treee31f1f14a9922b236f9f15b897610e961b22eb38
parente0941cb32650849aa8a7bba92ae95a359c424266
[WebAssembly] Target features section

Summary:
Implements a new target features section in assembly and object files
that records what features are used, required, and disallowed in
WebAssembly objects. The linker uses this information to ensure that
all objects participating in a link are feature-compatible and records
the set of used features in the output binary for use by optimizers
and other tools later in the toolchain.

The "atomics" feature is always required or disallowed to prevent
linking code with stripped atomics into multithreaded binaries. Other
features are marked used if they are enabled globally or on any
function in a module.

Future CLs will add linker flags for ignoring feature compatibility
checks and for specifying the set of allowed features, implement using
the presence of the "atomics" feature to control the type of memory
and segments in the linked binary, and add front-end flags for
relaxing the linkage policy for atomics.

Reviewers: aheejin, sbc100, dschuff

Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59173

llvm-svn: 356610
33 files changed:
lld/test/wasm/Inputs/disallow-feature-foo.yaml [new file with mode: 0644]
lld/test/wasm/Inputs/no-feature-foo.yaml [new file with mode: 0644]
lld/test/wasm/Inputs/require-feature-foo.yaml [new file with mode: 0644]
lld/test/wasm/Inputs/use-feature-foo.yaml [new file with mode: 0644]
lld/test/wasm/target-feature-disallowed.yaml [new file with mode: 0644]
lld/test/wasm/target-feature-required.yaml [new file with mode: 0644]
lld/test/wasm/target-feature-used.yaml [new file with mode: 0644]
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/include/llvm/Object/Wasm.h
llvm/include/llvm/ObjectYAML/WasmYAML.h
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/ObjectYAML/WasmYAML.cpp
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
llvm/test/CodeGen/WebAssembly/target-features.ll [new file with mode: 0644]
llvm/test/MC/WebAssembly/array-fill.ll
llvm/test/MC/WebAssembly/assembler-binary.ll
llvm/test/MC/WebAssembly/bss.ll
llvm/test/MC/WebAssembly/comdat.ll
llvm/test/MC/WebAssembly/debug-info.ll
llvm/test/MC/WebAssembly/explicit-sections.ll
llvm/test/MC/WebAssembly/global-ctor-dtor.ll
llvm/test/MC/WebAssembly/visibility.ll
llvm/test/MC/WebAssembly/weak-alias.ll
llvm/test/MC/WebAssembly/weak.ll
llvm/test/ObjectYAML/wasm/target-features-section.yaml [new file with mode: 0644]
llvm/tools/obj2yaml/wasm2yaml.cpp
llvm/tools/yaml2obj/yaml2wasm.cpp