diff options
author | Dan Gohman <dan433584@gmail.com> | 2017-02-28 23:37:04 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2017-02-28 23:37:04 +0000 |
commit | 7d7409e553877d3c75f0906d656a159d08229c34 (patch) | |
tree | e65c0f42bfd8b70dd55af54416d133332466fafd /llvm/lib/Target/WebAssembly | |
parent | 06f92e6dcbda7588aca03ddf62c57fa9d1c405a6 (diff) | |
download | bcm5719-llvm-7d7409e553877d3c75f0906d656a159d08229c34.tar.gz bcm5719-llvm-7d7409e553877d3c75f0906d656a159d08229c34.zip |
[WebAssembly] Convert the remaining unit tests to the new wasm-object-file target.
To facilitate this, add a new hidden command-line option to disable
the explicit-locals pass. That causes llc to emit invalid code that doesn't
have all locals converted to get_local/set_local, however it simplifies
testwriting in many cases.
llvm-svn: 296540
Diffstat (limited to 'llvm/lib/Target/WebAssembly')
-rw-r--r-- | llvm/lib/Target/WebAssembly/README.txt | 16 | ||||
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | 12 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/README.txt b/llvm/lib/Target/WebAssembly/README.txt index 3be7007a57f..3433b1553e8 100644 --- a/llvm/lib/Target/WebAssembly/README.txt +++ b/llvm/lib/Target/WebAssembly/README.txt @@ -150,3 +150,19 @@ Add support for mergeable sections in the Wasm writer, such as for strings and floating-point constants. //===---------------------------------------------------------------------===// + +The function @dynamic_alloca_redzone in test/CodeGen/WebAssembly/userstack.ll +ends up with a tee_local in its prolog which has an unused result, requiring +an extra drop: + + get_global $push8=, 0 + tee_local $push9=, 1, $pop8 + drop $pop9 + [...] + +The prologue code initially thinks it needs an FP register, but later it +turns out to be unneeded, so one could either approach this by being more +clever about not inserting code for an FP in the first place, or optimizing +away the copy later. + +//===---------------------------------------------------------------------===// diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index 50ee79b7079..41249117ae0 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -31,6 +31,14 @@ using namespace llvm; #define DEBUG_TYPE "wasm-explicit-locals" +// A command-line option to disable this pass. Note that this produces output +// which is not valid WebAssembly, though it may be more convenient for writing +// LLVM unit tests with. +static cl::opt<bool> DisableWebAssemblyExplicitLocals( + "disable-wasm-explicit-locals", cl::ReallyHidden, + cl::desc("WebAssembly: Disable emission of get_local/set_local."), + cl::init(false)); + namespace { class WebAssemblyExplicitLocals final : public MachineFunctionPass { StringRef getPassName() const override { @@ -164,6 +172,10 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { "********** Function: " << MF.getName() << '\n'); + // Disable this pass if directed to do so. + if (DisableWebAssemblyExplicitLocals) + return false; + // Disable this pass if we aren't doing direct wasm object emission. if (MF.getSubtarget<WebAssemblySubtarget>() .getTargetTriple().isOSBinFormatELF()) |