Commit Graph

24943 Commits

Author SHA1 Message Date
Aditya Nandakumar 9d8c6d38d9 [GISel]: Add legalization support for Widening UADDO/USUBO
https://reviews.llvm.org/D51384

Added code in LegalizerHelper to widen UADDO/USUBO along with unit
tests.

Reviewed by volkan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340892 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 03:17:08 +00:00
Craig Topper ee609f0f12 [X86] Support v2i32 gather/scatter indices with -x86-experimental-vector-widening-legalization
Summary: This is split out from D41062 to cover the code in LegalVectorTypes.cpp

Reviewers: RKSimon, spatel, efriedma

Reviewed By: efriedma

Subscribers: sdardis, jvesely, nhaehnle, jrtc27, atanasyan, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340891 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 02:12:49 +00:00
Aditya Nandakumar f8d714889d [GISel]: Add missing opcodes for overflow intrinsics
https://reviews.llvm.org/D51197

Currently, IRTranslator (and GISel) seems to be arbitrarily picking
which overflow intrinsics get mapped into opcodes which either have a
carry as an input or not.
For intrinsics such as Intrinsic::uadd_with_overflow, translate it to an
opcode (G_UADDO) which doesn't have any carry inputs (similar to LLVM
IR).

This patch adds 4 missing opcodes for completeness - G_UADDO, G_USUBO,
G_SSUBE and G_SADDE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340865 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:54:10 +00:00
Nirav Dave 7eda1917c3 [DAGCombine] Rework MERGE_VALUES to inline in single pass. NFCI.
Avoid hyperlinear cost of inlining MERGE_VALUE node by constructing
temporary vector and doing a single replacement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340853 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:13:26 +00:00
Nirav Dave f0b6863bfb [DAG] Avoid recomputing Divergence checks. NFCI.
When making multiple updates to the same SDNode, recompute node
divergence only once after all changes have been made.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340852 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:13:00 +00:00
Nirav Dave a24ff67fb6 [DAG] Fix updateDivergence calculation
Check correct SDNode when deciding if we should update the divergence
property.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340851 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:12:35 +00:00
Craig Topper 00ca244b7d [DAGCombiner][AMDGPU][Mips] Fold bitcast with volatile loads if the resulting load is legal for the target.
Summary:
I'm not sure if this patch is correct or if it needs more qualifying somehow. Bitcast shouldn't change the size of the load so it should be ok? We already do something similar for stores. We'll change the type of a volatile store if the resulting store is Legal or Custom. I'm not sure we should be allowing Custom there...

I was playing around with converting X86 atomic loads/stores(except seq_cst) into regular volatile loads and stores during lowering. This would allow some special RMW isel patterns in X86InstrCompiler.td to be removed. But there's some floating point patterns in there that didn't work because we don't fold (f64 (bitconvert (i64 volatile load))) or (f32 (bitconvert (i32 volatile load))).

Reviewers: efriedma, atanasyan, arsenm

Reviewed By: efriedma

Subscribers: jvesely, arsenm, sdardis, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, arichardson, jrtc27, atanasyan, jfb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340797 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 03:47:20 +00:00
David Blaikie 237dc6a794 Revert "[CodeGenPrepare] Scan past debug intrinsics to find select candidates (NFC)"
This causes crashes due to the interleaved dbg.value intrinsics being
left at the end of basic blocks, causing the actual terminators (br,
etc) to be not where they should be (not at the end of the block),
leading to later crashes.

Further discussion on the original commit thread.

This reverts commit r340368.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340794 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 00:55:19 +00:00
Brendon Cahoon 6d962e3374 [Pipeliner] Fix incorrect phi values in the epilog and kernel
The code that generates the loop definition operand for phis
in the epilog and kernel is incorrect in some cases.

In the kernel, when a phi refers to another phi, the code that
updates PhiOp2 needs to include the stage difference between
the two phis.

In the epilog, the check for using the loop definition instead
of the phi definition uses the StageDiffAdj value (the difference
between the phi stage and the loop definition stage), but the
adjustment is not needed to determine if the current stage
contains an iteration with the loop definition.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340782 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 22:04:50 +00:00
Matt Arsenault bfb50d8dbc DAG: Check transformed type for forming fminnum/fmaxnum from vselect
Follow up to r340655 to fix vector types which are split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340766 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 18:11:31 +00:00
Matt Arsenault 9b313de7bb MachineVerifier: Fix assert on implicit virtreg use
If the liveness of a physical register was invalid, this
was attempting to iterate the subregisters of all register
uses of the instruction, which would assert when it
encountered an implicit virtual register operand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340763 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 17:40:09 +00:00
Sanjay Patel 4f83e0c2a4 [SelectionDAG] add helper query for binops; NFC
We will also use this in a planned enhancement for vector insertelement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340741 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 14:20:15 +00:00
Sanjay Patel 79923d92c5 [SelectionDAG][x86] turn insertelement into undef with variable index into splat
I noticed this along with the patterns in D51125, but when the index is variable, 
we don't convert insertelement into a build_vector.

For x86, that means these get expanded at legalization time into the loading/spilling 
code that we see in the tests. I think it's always better to avoid going to memory on 
these, and we get the optimal 'broadcast' if it's available.

I suspect other targets may want to look at enabling the hook. AArch64 and AMDGPU have 
regression tests that would be affected (although I did not check what would happen in 
those cases). In the most basic cases shown here, AArch64 would probably do much 
better with a splat.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340705 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 18:20:41 +00:00
Chandler Carruth 9179aee2c1 [IR] Replace isa<TerminatorInst> with isTerminator().
This is a bit awkward in a handful of places where we didn't even have
an instruction and now we have to see if we can build one. But on the
whole, this seems like a win and at worst a reasonable cost for removing
`TerminatorInst`.

All of this is part of the removal of `TerminatorInst` from the
`Instruction` type hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340701 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 09:51:22 +00:00
Chandler Carruth 5eb83c58cd [IR] Begin removal of TerminatorInst by removing successor manipulation.
The core get and set routines move to the `Instruction` class. These
routines are only valid to call on instructions which are terminators.

The iterator and *generic* range based access move to `CFG.h` where all
the other generic successor and predecessor access lives. While moving
the iterator here, simplify it using the iterator utilities LLVM
provides and updates coding style as much as reasonable. The APIs remain
pointer-heavy when they could better use references, and retain the odd
behavior of `operator*` and `operator->` that is common in LLVM
iterators. Adjusting this API, if desired, should be a follow-up step.

Non-generic range iteration is added for the two instructions where
there is an especially easy mechanism and where there was code
attempting to use the range accessor from a specific subclass:
`indirectbr` and `br`. In both cases, the successors are contiguous
operands and can be easily iterated via the operand list.

This is the first major patch in removing the `TerminatorInst` type from
the IR's instruction type hierarchy. This change was discussed in an RFC
here and was pretty clearly positive:
http://lists.llvm.org/pipermail/llvm-dev/2018-May/123407.html

There will be a series of much more mechanical changes following this
one to complete this move.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340698 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 08:41:15 +00:00
Craig Topper 16d64ea7be [SelectionDAG][X86] Reorder the operands the MaskedStoreSDNode to put the value first.
Summary:
Previously the value being stored is the last operand in SDNode. This causes the type legalizer to visit the mask operand before the value operand. The type legalizer was more complicated because of this since we want the type of the value to drive the decisions.

This patch moves the value to be the first operand so we visit it first during type legalization. It also simplifies the type legalization code accordingly.

X86 is currently the only in tree target that uses this SDNode. Not sure if there are any users out of tree.

Reviewers: RKSimon, delena, hfinkel, eli.friedman

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340689 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-25 17:48:17 +00:00
Bjorn Pettersson 9a9829f273 [CodeGen] Set FrameSetup/FrameDestroy on BUNDLE instructions
Summary:
If any of the bundled instructions are marked as FrameSetup
or FrameDestroy, then that property is set on the BUNDLE
instruction as well.

As long as the scheduler/packetizer aren't mixing
prologue/epilogue instructions (i.e. all the bundled
instructions have the same property) then this simply gives
the bundle the correct property (so when using a bundle
iterator in late passes a bundle will be correctly identified
as FrameSetup/FrameDestroy).

When for example bundling a mix of FrameSetup instructions
with non-FrameSetup instructions it could be discussed if
the bundle should have the property or not. The choice here
has been to set these properties on the BUNDLE instruction if
any of the bundled instructions have the property set.

Reviewers: #debug-info, kparzysz

Reviewed By: kparzysz

Subscribers: vsk, thegameg, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340680 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-25 11:26:17 +00:00
Bjorn Pettersson 48bfbb5c8c [LiveDebugVariables] Avoid faulty addDefsFromCopies in computeIntervals
Summary:
When computeIntervals is looking through COPY instruction to
extend the location mapping for a debug variable it did not
handle subregisters correctly.

For example
    DBG_VALUE debug-use %0.sub_8bit_hi, ...
    %1:gr16 = COPY %0
was transformed into
    DBG_VALUE debug-use %0.sub_8bit_hi, ...
    %1:gr16 = COPY %0
    DBG_VALUE debug-use %1, ...
So the subregister index was missing in the added DBG_VALUE.

As long as the subreg refered to the least significant bits
of the superreg, then I guess we could get the correct
result in a debugger even when referring to the superreg.
But as in the example above when the subreg refers to other
parts of the superreg, then debuginfo would be incorrect.

I'm not sure exactly how to fix this properly, so this patch
just avoids looking through the COPY when there is a subreg
involved (for more info, see the FIXME added in the code).

Reviewers: rnk, aprantl

Reviewed By: aprantl

Subscribers: JDevlieghere, llvm-commits

Tags: #debug-info

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340679 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-25 10:02:03 +00:00
Matt Arsenault 936b78d214 DAG: Allow matching fminnum/fmaxnum from vselect
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340655 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 21:24:18 +00:00
Eli Friedman e07179a223 [SafeStack] Set debug location for calls to __safestack_pointer_address.
Otherwise, the debug info is incorrect.  On its own, this is mostly
harmless, but the safe-stack also later inlines the call to
__safestack_pointer_address, which leads to debug info with the wrong
scope, which eventually causes an assertion failure (and incorrect debug
info in release mode).

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340651 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 20:42:32 +00:00
Peter Collingbourne 84d4a7bcc9 CodeGen: Add two more conditions for adding symbols to the address-significance table.
Firstly, require the symbol to be used within the module. If a
symbol is unused within a module, then by definition it cannot be
address-significant within that module. This condition is useful on all
platforms because it could make symbol tables smaller -- without this
change, emitting an address-significance table could cause otherwise
unused undefined symbols to be added to the object file.

But this change is necessary with COFF specifically in order to
preserve the property that an unreferenced undefined symbol in an IR
module does not result in a link failure. This is already the case for
ELF because ELF linkers only reject links with unresolved symbols if
there is a relocation to that symbol, but COFF linkers require all
undefined symbols to be resolved regardless of relocations. So if
a module contains an unreferenced undefined symbol, we need to make
sure not to add it to the address-significance table (and thus the
symbol table) in case it doesn't end up resolved at link time.

Secondly, do not add dllimport symbols to the table. These symbols
won't be able to be resolved because their definitions live in another
module and are accessed via the IAT, and the address-significance
table has no effect on other modules anyway. It wouldn't make sense
to add the IAT entry symbol to the address-significance table either
because the IAT entry isn't address-significant -- the generated code
never takes its address.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340648 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 20:37:09 +00:00
David Blaikie 10937f20e4 DebugInfo: Fix skipping CUs in DWARFv5 debug_names table
My previoust test case had skipped CUs from one TU out of a two-TU LTO
scenario, which meant the CU index wasn't needed (as it was unambiguous
which CU a table entry applied to) - expanding the test to use 3 TUs,
skipping one (so long as it's not the last one) shows the indexes are
miscomputed. Fix that with a little indirection for the index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340646 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 20:31:05 +00:00
Craig Topper cd6221355b [DAGCombiner][Mips] Don't combine bitcast+store after LegalOperations when the store is volatile, if the resulting store isn't Legal
Previously we allowed the store to be Custom. But without knowing for sure that the Custom handling won't split the store, we shouldn't convert a volatile store. We also probably shouldn't be creating a store the requires custom handling after LegalizeOps. This could lead to an infinite loop if the custom handling was to insert a bitcast. Though I guess isStoreBitCastBeneficial could be used to block such a loop.

The test changes here are due to the volatile part of this. The stores in the test are all volatile and i32 stores are marked custom, So we are no longer converting them

This is related to D50491 where I was trying to allow some bitcasting of volatile loads

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340626 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 17:48:25 +00:00
Justin Bogner 2024fa294b [SDAG] Add versions of computeKnownBits that return a value
Having the KnownBits as an output parameter is kind of awkward to use
and a holdover from when it was two separate APInts. Instead, just
return a KnownBits object.

I'm leaving the existing interface in place for now, since updating
the callers all at once would be thousands of lines of diff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340594 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 02:42:24 +00:00
Tim Renouf 17b68c25c6 [RegisterCoalescer] Fix for assert in removePartialRedundancy
Summary:
I got "Use not jointly dominated by defs" when removePartialRedundancy
attempted to prune then re-extend a subrange whose only liveness was a
dead def at the copy being removed.

V2: Removed junk from test. Improved comment.
V3: Addressed minor review comments.

Subscribers: MatzeB, qcolombet, nhaehnle, llvm-commits

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

Change-Id: I6f894e9f517f71e921e0c6d81d28c5f344db8dad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340549 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 17:28:33 +00:00
Chandler Carruth d8e05e4ef2 Revert r340508: [DebugInfo] Fix bug in LiveDebugVariables.
This patch's test case relies on debug prints which isn't generally an
OK way to test stuff in LLVM and fails whenever asserts aren't enabled.
I've send a heads-up to the commit and detailed comments on the review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340513 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 05:39:02 +00:00
Hsiangkai Wang 0119632373 [DebugInfo] Fix bug in LiveDebugVariables.
In lib/CodeGen/LiveDebugVariables.cpp, it uses std::prev(MBBI) to
get DebugValue's SlotIndex. However, the previous instruction may be
also a debug instruction. It could not use a debug instruction to query
SlotIndex in mi2iMap.

Scan all debug instructions and use the first debug instruction to query
SlotIndex for following debug instructions. Only handle DBG_VALUE in
handleDebugValue().

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340508 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 03:28:24 +00:00
Sanjay Patel 417158854a [SelectionDAG] unroll unsupported vector FP ops earlier to avoid libcalls on undef elements (PR38527)
This solves the motivating case from:
https://bugs.llvm.org/show_bug.cgi?id=38527

If we are legalizing an FP vector op that maps to 1 of the LLVM intrinsics that mimic libm calls, 
but we're going to end up with scalar libcalls for that vector type anyway, then we should unroll 
the vector op into scalars before widening. This avoids libcalls because we've lost the knowledge 
that some of the scalar elements are undef.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340469 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 22:52:05 +00:00
Eli Friedman 575895c12e [ARM] Lower llvm.ctlz.i32 to a libcall when clz is not available.
The inline sequence is very long (about 70 bytes on Thumb1), so it's
not really a good idea to inline it, especially when optimizing for
size.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340458 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 21:47:14 +00:00
Eli Friedman 66ce6fc8af [SafeStack] Handle unreachable code with safe stack coloring.
Instead of asserting that the function doesn't have any unreachable
code, just ignore it for the purpose of computing liveness.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340456 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 21:38:57 +00:00
Vedant Kumar 67fcaf191e [CodeGenPrepare] Set debug locs when folding a comparison into a uadd.with.overflow
CGP can replace a branch + select with a uadd.with.overflow. Teach it to
set debug locations as it does this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340432 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 18:15:03 +00:00
Aditya Nandakumar 273215d0f9 [GISel]: Add legalization support for widening bit counting operations
https://reviews.llvm.org/D51053

Added legalization for WidenScalar of various bitcounting opcodes.

Reviewed by arsenm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340429 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 17:59:18 +00:00
Vedant Kumar cc831d0660 [CodeGenPrepare] Set debug loc when widening a switch condition
Set a debug location on the cast instruction used to widen a switch
condition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340379 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 01:23:31 +00:00
Vedant Kumar 2570fb4675 [CodeGenPrepare] Set debug locations when splitting selects
When splitting a select into a diamond, set debug locations on
newly-created branch instructions and phi nodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340371 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 00:10:37 +00:00
Vedant Kumar dc62ec40e6 [CodeGenPrepare] Clean up dbg.value use-before-def as late as possible
CodeGenPrepare has a strategy for moving dbg.values so that a value's
definition always dominates its debug users. This cleanup was happening
too early (before certain CGP transforms were run), resulting in some
dbg.value use-before-def errors.

Perform this cleanup as late as possible to avoid use-before-def.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340370 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 23:43:08 +00:00
Vedant Kumar 404a8add81 [CodeGenPrepare] Scan past debug intrinsics to find select candidates (NFC)
In optimizeSelectInst, when scanning for candidate selects to rewrite
into branches, scan past debug intrinsics. This makes the debug-enabled
and non-debug paths through optimizeSelectInst more congruent.

NFC because every select is eventually visited either way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340368 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 23:42:38 +00:00
Vedant Kumar 510d469d61 [CodeGenPrepare] Exit earlier when optimizing selects (NFC)
When optimizing for size, this allows optimizeSelectInst to skip a
linear scan and exit early.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340367 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 23:42:23 +00:00
Tom Stellard 486f7d6d9f MachineScheduler: Refactor setPolicy() to limit computing remaining latency
Summary:
Computing the remaining latency can be very expensive especially
on graphs of N nodes where the number of edges approaches N^2.

This reduces the compile time of a pathological case with the
AMDGPU backend from ~7.5 seconds to ~3 seconds.  This test case has
a basic block with 2655 stores, each with somewhere between 500
and 1500 successors and predecessors.

Reviewers: atrick, MatzeB, airlied, mareko

Reviewed By: mareko

Subscribers: tpr, javed.absar, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340346 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 21:48:43 +00:00
Heejin Ahn c315e740ba [WebAssembly] Don't make wasm cleanuppads into funclet entries
Summary:
Catchpads and cleanuppads are not funclet entries; they are only EH
scope entries. We already dont't set `isEHFuncletEntry` for catchpads.
This patch does the same thing for cleanuppads.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340330 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 20:04:42 +00:00
Bjorn Pettersson 17b7b8e97f [RegisterCoalescer] Use substPhysReg in reMaterializeTrivialDef
Summary:
When RegisterCoalescer::reMaterializeTrivialDef is substituting
a register use in a DBG_VALUE instruction, and the old register
is a subreg, and the new register is a physical register,
then we need to use substPhysReg in order to extract the correct
subreg.

Reviewers: wmi, aprantl

Reviewed By: wmi

Subscribers: hiraditya, MatzeB, qcolombet, tpr, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340326 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:47:32 +00:00
Heejin Ahn 408053d6cd [WebAssembly] Add isEHScopeReturn instruction property
Summary:
So far, `isReturn` property is used to mean both a return instruction
from a functon and the end of an EH scope, a scope that starts with a EH
scope entry BB and ends with a catchret or a cleanupret instruction.
Because WinEH uses funclets, all EH-scope-ending instructions are also
real return instruction from a function. But for wasm, they only serve
as the end marker of an EH scope but not a return instruction that
exits a function. This mismatch caused incorrect prolog and epilog
generation in wasm EH scopes. This patch fixes this.

This patch is in the same vein with rL333045, which splits
`MachineBasicBlock::isEHFuncletEntry` into `isEHFuncletEntry` and
`isEHScopeEntry`.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340325 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:44:11 +00:00
Krzysztof Parzyszek 3682387e68 [RegisterCoalscer] Manually remove leftover segments when commuting def
In removeCopyByCommutingDef, segments from the source live range are
copied into (and merged with) the segments of the target live range.
This is performed for all subranges of the source interval. It can
happen that there will be subranges of the target interval that had
no corresponding subranges in the source interval, and in such cases
these subrages will not be updated. Since the copy being coalesced
is about to be removed, these ranges need to be updated by removing
the segments that are started by the copy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340318 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:01:26 +00:00
Yury Delendik 985ee9ed76 Update DBG_VALUE register operand during LiveInterval operations
Summary:
Handling of DBG_VALUE in ConnectedVNInfoEqClasses::Distribute() was fixed in
PR16110. However DBG_VALUE register operands are not getting updated. This
patch properly resolves the value location.

Reviewers: MatzeB, vsk

Reviewed By: MatzeB

Subscribers: kparzysz, thegameg, vsk, MatzeB, dschuff, sbc100, jgravelle-google, aheejin, sunfish, llvm-commits

Tags: #debug-info

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 17:48:28 +00:00
Aditya Nandakumar 43485c4468 Revert "Revert rr340111 "[GISel]: Add Legalization/lowering code for bit counting operations""
This reverts commit d1341152d9.

This patch originally made use of Nested MachineIRBuilder buildInstr
calls, and since order of argument processing is not well defined, the
instructions were built slightly in a different order (still correct).
I've removed the nested buildInstr calls to have a defined order now.

Patch was tested by Mikael.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340309 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 17:30:31 +00:00
Bjorn Pettersson 6a7eb84023 Change how finalizeBundle selects debug location for the BUNDLE instruction
Summary:
Previously a BUNDLE instruction inherited the DebugLoc from the
first instruction in the bundle, even if that DebugLoc had no
DILocation. With this commit this is changed into selecting the
first DebugLoc that has a DILocation, by searching among the
bundled instructions.

The idea is to reduce amount of bundles that are lacking
debug locations.

Reviewers: #debug-info, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere, mattd, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340267 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:59:50 +00:00
Sam Parker 48cb502069 [DAGCombiner] Reduce load widths of shifted masks
During combining, ReduceLoadWdith is used to combine AND nodes that
mask loads into narrow loads. This patch allows the mask to be a
shifted constant. This results in a narrow load which is then left
shifted to compensate for the new offset.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340261 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:26:59 +00:00
Simon Pilgrim d92e522f12 [TargetLowering] Add BuildSDiv support for division by one or negone.
This reduces most of the sdiv stages (the MULHS, shifts etc.) to just zero/identity values and use the numerator scale factor to multiply by +1/-1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340260 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:20:36 +00:00
Bjorn Pettersson 56f506811f [RegisterCoalescer] Do not assert when trying to remat dead values
Summary:
RegisterCoalescer::reMaterializeTrivialDef used to assert that
the input register was live in. But as shown by the new
coalesce-dead-lanes.mir test case that seems to be a valid
scenario. We now return false instead of the assert, simply
avoiding to remat the dead def.

Normally a COPY of an undef value is eliminated by
eliminateUndefCopy(). Although we only do that when the
destination isn't a physical register. So the situation
above should be limited to the case when we copy an undef
value to a physical register.

Reviewers: kparzysz, wmi, tpr

Reviewed By: kparzysz

Subscribers: MatzeB, qcolombet, tpr, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340255 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 07:49:05 +00:00
Krzysztof Parzyszek 7e54adc682 Consistently use MemoryLocation::UnknownSize to indicate unknown access size
1. Change the software pipeliner to use unknown size instead of dropping
   memory operands. It used to do it before, but MachineInstr::mayAlias
   did not handle it correctly.
2. Recognize UnknownSize in MachineInstr::mayAlias.
3. Print and parse UnknownSize in MIR.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340208 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-20 20:37:57 +00:00
Cameron McInally 3e54b8bebb [FPEnv] Support constrained FREM intrinsic
Differential Revision: https://reviews.llvm.org/D50975



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340201 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-20 19:28:56 +00:00