1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00
Commit Graph

210148 Commits

Author SHA1 Message Date
Florian Hahn
5b8c530938 [FuzzMutate] Add mutator to modify instruction flags.
This patch adds a new InstModificationIRStrategy to mutate flags/options
for instructions. For example, it may add or remove nuw/nsw flags from
add, mul, sub, shl instructions or change the predicate for icmp
instructions.

Subtle changes such as those mentioned above should lead to a more
interesting range of inputs. The presence or absence of overflow flags
can expose subtle bugs, for example.

Reviewed By: bogner

Differential Revision: https://reviews.llvm.org/D94905
2021-01-23 19:05:20 +00:00
Kazu Hirata
dcbeaf027c [llvm] Use pop_back_val (NFC) 2021-01-23 10:56:33 -08:00
Kazu Hirata
f3e18e1dd6 [Target] Use llvm::append_range (NFC) 2021-01-23 10:56:31 -08:00
Kazu Hirata
f4934140cd [llvm] Forward-declare ICFLoopSafetyInfo (NFC)
LoopUtils.h needs ICFLoopSafetyInfo but relies on a forward
declaration of ICFLoopSafetyInfo in IVDescriptors.h.  This patch adds
a forward declaration right in LoopUtils.h.

While we are at it, this patch removes the one in IVDescriptors.h,
where it is unnecessary.
2021-01-23 10:56:30 -08:00
Florian Hahn
1a0245b43a [InstCombine] Set MadeIRChange in replaceInstUsesWith.
Some utilities used by InstCombine, like SimplifyLibCalls, may add new
instructions and replace the uses of a call, but return nullptr because
the inserted call produces multiple results.

Previously, the replaced library calls would get removed by
InstCombine's deleter, but after
292077072ec1279d89d21873fe900061e55ef936 this may not happen, if the
willreturn attribute is missing.

As a work-around, update replaceInstUsesWith to set MadeIRChange, if it
replaces any uses. This catches the cases where it is used as replacer
by utilities used by InstCombine and seems useful in general; updating
uses will modify the IR.

This fixes an expensive-check failure when replacing
@__sinpif/@__cospifi with @__sincospif_sret.
2021-01-23 17:52:59 +00:00
Ben Shi
0d8fd96903 [AVR] Optimize 16-bit comparison with constant
Reviewed By: dylanmckay

Differential Revision: https://reviews.llvm.org/D93976
2021-01-24 00:38:57 +08:00
Sanjay Patel
77d1393c15 [SLP] fix fast-math-flag propagation on FP reductions
As shown in the test diffs, we could miscompile by
propagating flags that did not exist in the original
code.

The flags required for fmin/fmax reductions will be
fixed in a follow-up patch.
2021-01-23 11:17:20 -05:00
Sanjay Patel
6c70b83a23 [SLP] add reduction test with mixed fast-math-flags; NFC 2021-01-23 11:17:20 -05:00
Florian Hahn
283961f4c8 [Local] Treat calls that may not return as being alive.
With the addition of the `willreturn` attribute, functions that may
not return (e.g. due to an infinite loop) are well defined, if they are
not marked as `willreturn`.

This patch updates `wouldInstructionBeTriviallyDead` to not consider
calls that may not return as dead.

This patch still provides an escape hatch for intrinsics, which are
still assumed as willreturn unconditionally. It will be removed once
all intrinsics definitions have been reviewed and updated.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94106
2021-01-23 16:05:14 +00:00
Ben Shi
dbeacbd88e [AVR] Optimize 8-bit logic left/right shifts
Reviewed By: dylanmckay

Differential Revision: https://reviews.llvm.org/D89047
2021-01-23 23:54:16 +08:00
LLVM GN Syncbot
06a1ff4c94 [gn build] Port 0057cc5a215e 2021-01-23 14:07:39 +00:00
Roman Lebedev
cbc12c9267 [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set, thus avoiding dangling pointers
If i change it to AssertingVH instead, a number of existing tests fail,
which means we don't consistently remove from the set when deleting blocks,
which means newly-created blocks may happen to appear in that set
if they happen to occupy the same memory chunk as did some block
that was in the set originally.

There are many places where we delete blocks,
and while we could probably consistently delete from LoopHeaders
when deleting a block in transforms located in SimplifyCFG.cpp itself,
transforms located elsewhere (Local.cpp/BasicBlockUtils.cpp) also may
delete blocks, and it doesn't seem good to teach them to deal with it.

Since we at most only ever delete from LoopHeaders,
let's just delegate to WeakVH to do that automatically.

But to be honest, personally, i'm not sure that the idea
behind LoopHeaders is sound.
2021-01-23 16:48:35 +03:00
LLVM GN Syncbot
f4c75ab0c3 [gn build] Port 2325157c0568 2021-01-23 13:38:51 +00:00
Nikita Popov
e42864bbb1 [LSR] Add test for PR46943 (NFC)
LSR should be dropping nowrap flags when adding new postinc users.
2021-01-23 13:53:09 +01:00
Florian Hahn
438026988c [LTO] Store target attributes as vector of strings (NFC).
The target features are obtained as a list of features/attributes.
Instead of storing them in a single string, store the vector. This
matches lto::Config's behavior and simplifies the transition to
lto::backend().

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D95224
2021-01-23 12:11:58 +00:00
Jeroen Dobbelaere
3fda99577d [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.
Insert a llvm.experimental.noalias.scope.decl intrinsic that identifies where a noalias argument was inlined.

This patch includes some refactorings from D90104.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93040
2021-01-23 12:10:57 +01:00
Simon Pilgrim
982a3c3ce9 [Support] TrigramIndex::insert - pass std::String argument by const reference. NFCI.
Avoid string copies and fix clang-tidy warning.
2021-01-23 11:04:00 +00:00
Roger Ferrer Ibanez
e9cd01d82d [RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making them immediately unreachable from the stack pointer
In RISC-V there is a single addressing mode of the form imm(reg) where
imm is a signed integer of 12-bit with a range of [-2048..2047] bytes
from reg.

The test MultiSource/UnitTests/C++11/frame_layout of the LLVM test-suite
exercises several scenarios with the stack, including function calls
where the stack will need to be realigned to to a local variable having
a large alignment of 4096 bytes.

In situations of large stacks, the RISC-V backend (in
RISCVFrameLowering) reserves an extra emergency spill slot which can be
used (if no free register is found) by the register scavenger after the
frame indexes have been eliminated. PrologEpilogInserter already takes
care of keeping the emergency spill slots as close as possible to the
stack pointer or frame pointer (depending on what the function will
use). However there is a final alignment step to honour the maximum
alignment of the stack that, when using the stack pointer to access the
emergency spill slots, has the side effect of setting them farther from
the stack pointer.

In the case of the frame_layout testcase, the net result is that we do
have an emergency spill slot but it is so far from the stack pointer
(more than 2048 bytes due to the extra alignment of a variable to 4096
bytes) that it becomes unreachable via any immediate offset.

During elimination of the frame index, many (regular) offsets of the
stack may be immediately unreachable already. Their address needs to be
computed using a register. A virtual register is created and later
RegisterScavenger should be able to find an unused (physical) register.
However if no register is available, RegisterScavenger will pick a
physical register and spill it onto an emergency stack slot, while we
compute the offset (restoring the chosen register after all this). This
assumes that the emergency stack slot is easily reachable (this is,
without requiring another register!).

This is the assumption we seem to break when we perform the extra
alignment in PrologEpilogInserter.

We can "float" the emergency spill slots by increasing (in absolute
value) their offsets from the incoming stack pointer. This way the
emergency spill slots will remain close to the stack pointer (once the
function has allocated storage for the stack, including the needed
realignment). The new size computed in PrologEpilogInserter is padding
so it should be OK to move the emergency spill slots there. Also because
we're increasing the alignment, the new location should stay aligned for
the purpose of the emergency spill slots.

Note that this change also impacts other backends as shown by the tests.
Changes are minor adjustments to the emergency stack slot offset.

Differential Revision: https://reviews.llvm.org/D89239
2021-01-23 09:10:03 +00:00
Sergey Dmitriev
d19ff967e7 [llvm-link] Fix for an assertion when linking global with appending linkage
This patch fixes llvm-link assertion when linking external variable
declaration with a definition with appending linkage.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D95126
2021-01-23 00:10:42 -08:00
Kazu Hirata
67c2d74113 [llvm] Use static_assert instead of assert (NFC)
Identified with misc-static-assert.
2021-01-22 23:25:05 -08:00
Kazu Hirata
0069e576c3 [llvm] Use isAlpha/isAlnum (NFC) 2021-01-22 23:25:03 -08:00
Kazu Hirata
94106f21e8 [Analysis] Use llvm::append_range (NFC) 2021-01-22 23:25:01 -08:00
Xun Li
5ecc45d24f [Coroutine] Improve coro-elide-musttail.ll test
The test wasn't sensitive to alias analysis. As you can seen from D95117 when AA is added by default this is affected.
Updating the test so that it coveres both cases for AA analysis.
Note that this patch depends on D95117 to land first.

Differential Revision: https://reviews.llvm.org/D95247
2021-01-22 20:23:48 -08:00
Craig Topper
4a8863f5e1 [TargetLowering] Use isOneConstant to simplify some code. NFC 2021-01-22 19:32:19 -08:00
Cassie Jones
163e70e009 Recommit "[AArch64][GlobalISel] Make G_USUBO legal and select it."
The expansion for wide subtractions includes G_USUBO.

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

This was miscompiling on ubsan bots.
2021-01-22 17:29:54 -08:00
Zequan Wu
44aa0837d2 [InstCombine] remove incompatible attribute when simplifying some lib calls
Like D95088, remove incompatible attribute in more lib calls.

Differential Revision: https://reviews.llvm.org/D95278
2021-01-22 17:27:36 -08:00
Hsiangkai Wang
8bb160d7f8 [RISCV] Add RV64 test cases for vsoxseg.
Differential Revision: https://reviews.llvm.org/D95195
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
86d4af42a4 [RISCV] Add RV32 test cases for vsoxseg.
Differential Revision: https://reviews.llvm.org/D95194
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
b2d743b5b2 [RISCV] Add RV64 test cases for vsuxseg.
Differential Revision: https://reviews.llvm.org/D95197
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
6787bd85ed [RISCV] Add RV32 test cases for vsuxseg.
Differential Revision: https://reviews.llvm.org/D95196
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
02776ce1c4 [RISCV] Implement vsoxseg/vsuxseg intrinsics.
Define vsoxseg/vsuxseg intrinsics and pseudo instructions.
Lower vsoxseg/vsuxseg intrinsics to pseudo instructions in RISCVDAGToDAGISel.

Differential Revision: https://reviews.llvm.org/D94940
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
9ef6b79d87 [RISCV] Add RV64 test cases for vloxseg.
Differential Revision: https://reviews.llvm.org/D95192
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
089dc9b09e [RISCV] Add RV32 test cases for vloxseg.
Differential Revision: https://reviews.llvm.org/D95191
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
5f5ae15454 [RISCV] Add RV64 test cases for vluxseg.
Differential Revision: https://reviews.llvm.org/D95190
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
e616e09b90 [RISCV] Add RV32 test cases for vluxseg.
Differential Revision: https://reviews.llvm.org/D95193
2021-01-23 08:54:56 +08:00
Hsiangkai Wang
233ef2a3eb [RISCV] Implement vloxseg/vluxseg intrinsics.
Define vloxseg/vluxseg intrinsics and pseudo instructions.
Lower vloxseg/vluxseg intrinsics to pseudo instructions in RISCVDAGToDAGISel.

Differential Revision: https://reviews.llvm.org/D94903
2021-01-23 08:54:56 +08:00
Philip Reames
c08128ee52 [LoopDeletion] Handle inner loops w/untaken backedges
This builds on the restricted after initial revert form of D93906, and adds back support for breaking backedges of inner loops. It turns out the original invalidation logic wasn't quite right, specifically around the handling of LCSSA.

When breaking the backedge of an inner loop, we can cause blocks which were in the outer loop only because they were also included in a sub-loop to be removed from both loops. This results in the exit block set for our original parent loop changing, and thus a need for new LCSSA phi nodes.

This case happens when the inner loop has an exit block which is also an exit block of the parent, and there's a block in the child which reaches an exit to said block without also reaching an exit to the parent loop.

(I'm describing this in terms of the immediate parent, but the problem is general for any transitive parent in the nest.)

The approach implemented here involves a potentially expensive LCSSA rebuild.  Perf testing during review didn't show anything concerning, but we may end up needing to revert this if anyone encounters a practical compile time issue.

Differential Revision: https://reviews.llvm.org/D94378
2021-01-22 16:31:29 -08:00
Duncan P. N. Exon Smith
e675c8ca11 ADT: Use 'using' to inherit assign and append in SmallString
Rather than reimplement, use a `using` declaration to bring in
`SmallVectorImpl<char>`'s assign and append implementations in
`SmallString`.

The `SmallString` versions were missing reference invalidation
assertions from `SmallVector`. This patch also fixes a bug in
`llvm::FileCollector::addFileImpl`, which was a copy/paste from
`clang::ModuleDependencyCollector::copyToRoot`, both caught by the
no-longer-skipped assertions.

As a drive-by, this also sinks the `const SmallVectorImpl&` versions of
these methods down into `SmallVectorImpl`, since I imagine they'd be
useful elsewhere.

Differential Revision: https://reviews.llvm.org/D95202
2021-01-22 16:17:58 -08:00
Stanislav Mekhanoshin
e27b35d042 [AMDGPU] Fix FP materialization/resolve with flat scratch
Differential Revision: https://reviews.llvm.org/D95266
2021-01-22 16:06:47 -08:00
Stanislav Mekhanoshin
dd3332e2e5 Change materializeFrameBaseRegister() to return register
The only caller of this function is in the LocalStackSlotAllocation
and it creates base register of class returned by the target's
getPointerRegClass(). AMDGPU wants to use a different reg class
here so let materializeFrameBaseRegister to just create and return
whatever it wants.

Differential Revision: https://reviews.llvm.org/D95268
2021-01-22 15:51:06 -08:00
Paul Robinson
42e5acf884 [RGT][TextAPI] Remove a zero-trip loop and the assertions within it
Found by the Rotten Green Tests project.

Differential Revision: https://reviews.llvm.org/D95259
2021-01-22 15:07:41 -08:00
Paul Robinson
7db9c41fd4 [RGT] Don't use EXPECT* macros in a subprocess that exits by signalling
Found by the Rotten Green Tests project.

Differential Revision: https://reviews.llvm.org/D95256
2021-01-22 15:04:34 -08:00
Paul Robinson
6be86e0db5 [RGT][ADT] Remove test assertion that will not be executed
Found by the Rotten Green Tests project.

Differential Revision: https://reviews.llvm.org/D95255
2021-01-22 14:52:55 -08:00
Craig Topper
bc9a268305 [RISCV] Add more cmov isel patterns to handle seteq/ne with a small non-zero immediate.
Similar to our free standing setcc patterns, we can use ADDI to
subtract the immediate from the other operand. Then the cmov
can check if the result is zero or non-zero.

Reviewed By: mundaym

Differential Revision: https://reviews.llvm.org/D95169
2021-01-22 14:51:22 -08:00
Francis Visoiu Mistrih
ab6f91458e [Matrix] Propagate shape information through fneg
Similar to binary operators like fadd/fmul/fsub, propagate shape info
through unary operators (fneg is the only one?).

Differential Revision: https://reviews.llvm.org/D95252
2021-01-22 14:34:28 -08:00
Mitch Phillips
069fed39cd Revert "[AArch64][GlobalISel] Make G_USUBO legal and select it."
This reverts commit 3dedad475da45c05bc4f66cd14e9f44581edf0bc.

Broke UBSan on Android:
http://lab.llvm.org:8011/#/builders/77/builds/3082

More details at: https://reviews.llvm.org/D95032
2021-01-22 14:32:12 -08:00
Mitch Phillips
1c4f0a4fdd Revert "[AArch64][GlobalISel] Implement widenScalar for signed overflow"
This reverts commit 541d98efa222b00e16c67348810898c2fa11f398.

Reason: Dependent patch 3dedad475da45c05bc4f66cd14e9f44581edf0bc broke
UBSan on Android: http://lab.llvm.org:8011/#/builders/77/builds/3082
2021-01-22 14:32:11 -08:00
Mitch Phillips
7a51025e46 Revert "[GlobalISel] LegalizerHelper - Extract widenScalarAddoSubo method"
This reverts commit 2bb92bf451d7eb2c817f3e5403353e7c0c14d350.

Dependent patch broke UBSan on Android:
3dedad475da45c05bc4f66cd14e9f44581edf0bc
2021-01-22 14:32:11 -08:00
Roman Lebedev
cd61097c03 [SimplifyCFG] FoldBranchToCommonDest(): re-lift restrictions on liveout uses of bonus instructions
I have previously tried doing that in
b33fbbaa34f0fe9fb16789afc72ae424c1825b69 / d38205144febf4dc42c9270c6aa3d978f1ef65e1,
but eventually it was pointed out that the approach taken there
was just broken wrt how the uses of bonus instructions are updated
to account for the fact that they should now use either bonus instruction
or the cloned bonus instruction. In particluar, all that manual handling
of PHI nodes in successors was just wrong.

But, the fix is actually much much simpler than my initial approach:
just tell SSAUpdate about both instances of bonus instruction,
and let it deal with all the PHI handling.

Alive2 confirms that the reproducers from the original bugs (@pr48450*)
are now handled correctly.

This effectively reverts commit 59560e85897afc50090b6c3d920bacfd28b49d06,
effectively relanding b33fbbaa34f0fe9fb16789afc72ae424c1825b69.
2021-01-23 01:29:05 +03:00
Roman Lebedev
c769c6dcc3 [NFC][SimplifyCFG] PerformBranchToCommonDestFolding(): move instruction cloning to after CFG update
This simplifies follow-up patch, and is NFC otherwise.
2021-01-23 01:29:04 +03:00