442 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
21e2c0016c Revert "[WebAssembly] Handle debug information and virtual registers without crashing"
This reverts commit r278967, since the new test is failing when you
don't build the WebAssembly target (most people, since it's
off-by-default).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278973 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 20:41:50 +00:00
Dominic Chen
1d359ed1ff [WebAssembly] Handle debug information and virtual registers without crashing
Summary: Currently, enabling debug information when compiling for WebAssembly crashes the backend. This commit fixes these by skipping debug values in backend passes.

Reviewers: jfb, aprantl, dschuff, echristo

Subscribers: mehdi_amini, yurydelendik, dexonsmith, MatzeB, jfb, dschuff, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278967 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 20:11:03 +00:00
Benjamin Kramer
c94acb05ee [WebAssembly] Plug MachineMemOperand leaks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278545 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 18:33:50 +00:00
David Majnemer
5d08e375ab Use the range variant of remove_if instead of unpacking begin/end
No functionality change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 04:32:37 +00:00
Dominic Chen
a01f239d02 [WebAssembly] Cleanup trailing whitespace
Summary: Test for commit access.

Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 04:10:56 +00:00
Derek Schuff
4dd8705c8c [WebAssembly] Add -emscripten-cxx-exceptions-whitelist option
This patch adds -emscripten-cxx-exceptions-whitelist option to
WebAssemblyLowerEmscriptenExceptions pass. This options is the list of
function names in which Emscripten-style exception handling is enabled.
This is to support emscripten's EXCEPTION_CATCHING_WHITELIST which
exists because of the performance impact of emscripten's non-zero-cost
EH method.

Patch by Heejin Ahn

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278171 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 22:37:00 +00:00
Derek Schuff
e7c619024b [WebAssembly] Fix bugs in WebAssemblyLowerEmscriptenExceptions pass
* Delete extra '_' prefixes from JS library function names. fixImports()
  function in JS glue code deals with this for wasm.
* Change command-line option names in order to be consistent with
  asm.js.
* Add missing lowering code for llvm.eh.typeid.for intrinsics
* Delete commas in mangled function names
* Fix a function argument attributes bug. Because we add the pointer to
  the original callee as the first argument of invoke wrapper, all
  argument attribute indices have to be incremented by one.

Patch by Heejin Ahn

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278081 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 00:29:55 +00:00
Derek Schuff
1d5ec70571 [WebAssembly] Check return value of getRegForValue in FastISel
Previously, FastISel for WebAssembly wasn't checking the return value of
`getRegForValue` in certain cases, which would generate instructions
referencing NoReg. This patch fixes this behavior.

Patch by Dominic Chen

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277742 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 18:01:52 +00:00
Derek Schuff
d8ef8b0e48 [WebAssembly] Remove unnecessary subtarget checks in peephole pass
Leftover from D22686; the passes can handle all the instructions
unconditionally; only isel needs to care whether to generate them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 23:31:56 +00:00
Derek Schuff
75834f76b2 [WebAssembly] Initial SIMD128 support.
Kicks off the implementation of wasm SIMD128 support (spec:
https://github.com/stoklund/portable-simd/blob/master/portable-simd.md),
adding support for add, sub, mul for i8x16, i16x8, i32x4, and f32x4.

The spec is WIP, and might change in the near future.

Patch by João Porto

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277543 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 23:16:09 +00:00
Dan Gohman
143e93e010 [WebAssembly] Remove a README.txt entry that is now implemented.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277467 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 14:53:44 +00:00
Derek Schuff
23429a5af3 [WebAssembly] Support CFI for WebAssembly target
Summary: This patch implements CFI for WebAssembly. It modifies the
LowerTypeTest pass to pre-assign table indexes to functions that are
called indirectly, and lowers type checks to test against the
appropriate table indexes. It also modifies the WebAssembly backend to
support a special ".indidx" assembly directive that propagates the table
index assignments out to the linker.

Patch by Dominic Chen

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277398 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 22:25:02 +00:00
Derek Schuff
6b6b112dba [WebAssembly] Add asm.js-style exception handling support
Summary: This patch includes asm.js-style exception handling support for
WebAssembly. The WebAssembly MVP does not have any support for
unwinding or non-local control flow. In order to support C++ exceptions,
emscripten currently uses JavaScript exceptions along with some support
code (written in JavaScript) that is bundled by emscripten with the
generated code.
This scheme lowers exception-related instructions for wasm such that
wasm modules can be compatible with emscripten's existing scheme and
share the support code.

Patch by Heejin Ahn

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277391 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 21:34:04 +00:00
Matthias Braun
f79c57a412 MachineFunction: Return reference for getFrameInfo(); NFC
getFrameInfo() never returns nullptr so we should use a reference
instead of a pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277017 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 18:40:00 +00:00
David Blaikie
795e327d8d [WebAssembly] Update for Target API (TargetRegistry::RegisterMCAsmBackend) change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276694 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 21:41:42 +00:00
Derek Schuff
17ea6c191e Fix calls to SelectionDAG::getStore
It was refactored in r275592. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275601 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 19:35:43 +00:00
Jacques Pienaar
48ed4ab2d6 Rename AnalyzeBranch* to analyzeBranch*.
Summary: NFC. Rename AnalyzeBranch/AnalyzeBranchPredicate to analyzeBranch/analyzeBranchPredicate to follow LLVM coding style and be consistent with TargetInstrInfo's analyzeCompare and analyzeSelect.

Reviewers: tstellarAMD, mcrosier

Subscribers: mcrosier, jholewinski, jfb, arsenm, dschuff, jyknight, dsanders, nemanjai

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275564 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 14:41:04 +00:00
Nirav Dave
6b00c9f9a9 Fix branch relaxation in 16-bit mode.
Thread through MCSubtargetInfo to relaxInstruction function allowing relaxation
to generate jumps with 16-bit sized immediates in 16-bit mode.

This fixes PR22097.

Reviewers: dwmw2, tstellarAMD, craig.topper, jyknight

Subscribers: jfb, arsenm, jyknight, llvm-commits, dsanders

Differential Revision: http://reviews.llvm.org/D20830

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 14:23:53 +00:00
Duncan P. N. Exon Smith
a3dcb9e3b4 WebAssembly: Avoid implicit iterator conversions, NFC
Avoid implicit conversions from MachineInstrBundleIterator to
MachineInstr* in the WebAssembly backend by preferring MachineInstr&
over MachineInstr*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274912 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 19:36:40 +00:00
Rafael Espindola
9931d67967 Delete MCCodeGenInfo.
MC doesn't really care about CodeGen stuff, so this was just
complicating target initialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274258 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 18:25:11 +00:00
Duncan P. N. Exon Smith
567409db69 CodeGen: Use MachineInstr& in TargetInstrInfo, NFC
This is mostly a mechanical change to make TargetInstrInfo API take
MachineInstr& (instead of MachineInstr* or MachineBasicBlock::iterator)
when the argument is expected to be a valid MachineInstr.  This is a
general API improvement.

Although it would be possible to do this one function at a time, that
would demand a quadratic amount of churn since many of these functions
call each other.  Instead I've done everything as a block and just
updated what was necessary.

This is mostly mechanical fixes: adding and removing `*` and `&`
operators.  The only non-mechanical change is to split
ARMBaseInstrInfo::getOperandLatencyImpl out from
ARMBaseInstrInfo::getOperandLatency.  Previously, the latter took a
`MachineInstr*` which it updated to the instruction bundle leader; now,
the latter calls the former either with the same `MachineInstr&` or the
bundle leader.

As a side effect, this removes a bunch of MachineInstr* to
MachineBasicBlock::iterator implicit conversions, a necessary step
toward fixing PR26753.

Note: I updated WebAssembly, Lanai, and AVR (despite being
off-by-default) since it turned out to be easy.  I couldn't run tests
for AVR since llc doesn't link with it turned on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274189 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 00:01:54 +00:00
Reid Kleckner
06876d225a Fix the wasm build by including EndianStream.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273591 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 18:12:31 +00:00
Benjamin Kramer
af18e017d2 Pass DebugLoc and SDLoc by const ref.
This used to be free, copying and moving DebugLocs became expensive
after the metadata rewrite. Passing by reference eliminates a ton of
track/untrack operations. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272512 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-12 15:39:02 +00:00
Benjamin Kramer
ad53d4da9e Remove dead function with incredibly broken assert.
Found by clang-tidy's misc-assert-side-effect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 12:10:42 +00:00
Derek Schuff
561fb73b85 [WebAssembly] Emit type signatures for declared functions
Under emscripten, C code can take the address of a function implemented
in Javascript (which is exposed via an import in wasm). Because imports
do not have linear memory address in wasm, we need to generate a thunk
to be the target of the indirect call; it call the import directly.

To make this possible, LLVM needs to emit the type signatures for these
functions, because they may not be called directly or referred to other
than where the address is taken.

This uses s new .s directive (.functype) which specifies the signature.

Differential Revision: http://reviews.llvm.org/D20891

Re-apply r271599 but instead of bailing with an error when a declared
function has multiple returns, replace it with a pointer argument. Also
add the test case I forgot to 'git add' last time around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 18:34:36 +00:00
Derek Schuff
13e11d741a Revert "[WebAssembly] Emit type signatures for declared functions"
This reverts r271599, it broke the integration tests.
More places than I expected had nontrival return types in imports, or
else the check was wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 23:02:44 +00:00
Derek Schuff
1fa45c8fb6 [WebAssembly] Emit type signatures for declared functions
Under emscripten, C code can take the address of a function implemented
in Javascript (which is exposed via an import in wasm). Because imports
do not have linear memory address in wasm, we need to generate a thunk
to be the target of the indirect call; it call the import directly.

To make this possible, LLVM needs to emit the type signatures for these
functions, because they may not be called directly or referred to other
than where the address is taken.

This uses s new .s directive (.functype) which specifies the signature.

Differential Revision: http://reviews.llvm.org/D20891

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271599 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 21:34:18 +00:00
Dan Gohman
04c5ee8513 [WebAssembly] Put __stack_pointer in the offset field of loads and stores.
Instead of this:

i32.const       $push10=, __stack_pointer
i32.load        $push11=, 0($pop10)

Emit this:

i32.const       $push10=, 0
i32.load        $push11=, __stack_pointer($pop10)

It's not currently clear which is better, though there's a chance the second
form may be better at overall compression. We can revisit this when we have
more data; for now it makes sense to make PEI consistent with isel.

Differential Revision: http://reviews.llvm.org/D20411


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270635 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 23:47:41 +00:00
Dan Gohman
7e9fa84c67 [WebAssembly] Basic TargetTransformInfo support for SIMD128.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270508 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 22:47:07 +00:00
Dan Gohman
7333a98310 [WebAssembly] Speed up LiveIntervals updating.
Use the more specific LiveInterval::removeSegment instead of
LiveInterval::shrinkToUses when we know the specific range that's
being removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270463 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 17:42:57 +00:00
Dan Gohman
1a513a6964 [WebAssembly] Optimize away return instructions using fallthroughs.
This saves a small amount of code size, and is a first small step toward
passing values on the stack across block boundaries.

Differential Review: http://reviews.llvm.org/D20450


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-21 00:21:56 +00:00
Dan Gohman
15399a989c [WebAssembly] Simplify code that never has to handle physical registers. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270137 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 21:07:20 +00:00
Dan Gohman
62dec0fa6b [WebAssembly] Update WebAssembly target for r269988.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270017 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 03:00:05 +00:00
Dan Gohman
b3b1972f26 [WebAssembly] Disable the MachineScheduler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269976 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 20:19:02 +00:00
Dan Gohman
da38a6d070 [WebAssembly] Don't expand divisions by constants.
Don't expand divisions by constants if it would require multiple instructions.
The current assumption is that engines will perform the desired optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269930 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 14:29:42 +00:00
Dan Gohman
51510adcfa [WebAssembly] Rename $discard to $drop in the assembly output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269862 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:19:03 +00:00
Dan Gohman
b9fa981c8a [WebAssembly] Model the stack evaluation order more precisely.
We currently don't represent get_local and set_local explicitly; they
are just implied by virtual register use and def. This avoids a lot of
clutter, but it does complicate stackifying: get_locals read their
operands at their position in the stack evaluation order, rather than
at their parent instruction. This patch adds code to walk the stack to
determine the precise ordering, when needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269854 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 22:24:18 +00:00
Dan Gohman
e5abbb2bf0 [WebAssembly] Don't stackify calls past stack pointer modifications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269843 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 21:14:26 +00:00
Dan Gohman
f9336ec145 [WebAssembly] Stackify induction variable increment instructions.
This handles instructions where the defined register is also used, as in
"x = x + 1".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269830 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 20:19:47 +00:00
Derek Schuff
b63ec0f596 [WebAssembly] Remove our copy of PrologEpilogInserter
It's no longer needed after r269750

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 11:18:35 +00:00
Derek Schuff
4bfd3e29b1 Factor PrologEpilogInserter around spilling, frame finalization, and scavenging
PrologEpilogInserter has these 3 phases, which are related, but not
all of them are needed by all targets. This patch reorganizes PEI's
varous functions around those phases for more clear separation. It also
introduces a new TargetMachine hook, usesPhysRegsForPEI, which is true
for non-virtual targets. When it is true, all the phases operate as
before, and PEI requires the AllVRegsAllocated property on
MachineFunctions. Otherwise, CSR spilling and scavenging are skipped and
only prolog/epilog insertion/frame finalization is done.

Differential Revision: http://reviews.llvm.org/D18366

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 08:49:59 +00:00
Dan Gohman
c1fd522352 [WebAssembly] Improve the precision of memory and side effect dependence tracking.
MachineInstr::isSafeToMove is more conservative than is needed here;
use a more explicit check, and incorporate knowledge of some
WebAssembly-specific opcodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269736 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 04:05:31 +00:00
Dan Gohman
594d70d5cc [WebAssembly] Mark COPY_LOCAL and TEE_LOCAL instructions has having no side effects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269683 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 19:16:32 +00:00
Dan Gohman
b57691df7a [WebAssembly] Use eqz to negate a branch conditions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269681 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 18:59:34 +00:00
Dan Gohman
b5e78617f3 [WebAssembly] Add a few optimization ideas to README.txt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269677 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 18:51:03 +00:00
Dan Gohman
c40a684451 [WebAssembly] Fix legalization of i128 shifts.
compiler-rt/libgcc shift routines expect the shift count to be an i32, so
use i32 as the shift count for shifts that are legalized to libcalls. This
also reverts r268991, now that the signatures are correct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269531 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-14 02:15:47 +00:00
Derek Schuff
505ba6dd9a [WebAssembly] Update expected torture test failures
NFC; the waterfall just changed the way they are built.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269523 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-14 00:22:17 +00:00
Justin Bogner
20520cf22a SDAG: Implement Select instead of SelectImpl in WebAssemblyDAGToDAGISel
This backend doesn't do anything custom here yet, so we just modernize
the boilerplate.

Part of llvm.org/pr26808.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269506 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 22:44:57 +00:00
Dan Gohman
ca8feb05bb [WebAssembly] Fast-isel support for calls, arguments, and selects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269273 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 04:19:09 +00:00
Dan Gohman
9cc168109a [WebAssembl] Implement enough of fast-isel to run the comparison tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11 16:32:42 +00:00