[WebAssembly] Enforce assembler emits to streamer in order.
authorWouter van Oortmerssen <aardappel@gmail.com>
Mon, 3 Dec 2018 20:30:28 +0000 (20:30 +0000)
committerWouter van Oortmerssen <aardappel@gmail.com>
Mon, 3 Dec 2018 20:30:28 +0000 (20:30 +0000)
commitc7b89f0f626b733b631e30b73f8aa35c1122190e
treef707fe43189bb9192f4370fd5664c1efc72941b1
parentdc7d7e3fe81b94e4370d1f83c758890f5d49eccd
[WebAssembly] Enforce assembler emits to streamer in order.

Summary:
The assembler processes directives and instructions in whatever order
they are in the file, then directly emits them to the streamer. This
could cause badly written (or generated) .s files to produce
incorrect binaries.

It now has state that tracks what it has most recently seen, to
enforce they are emitted in a given order that always produces
correct wasm binaries.

Also added a new test that compares obj2yaml output from llc (the
backend) to that going via .s and the assembler to ensure both paths
generate the same binaries.

The features this test covers could be extended.

Passes all wasm Lit tests.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=39557

Reviewers: sbc100, dschuff, aheejin

Subscribers: jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 348185
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/assembler-binary.ll [new file with mode: 0644]