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

217346 Commits

Author SHA1 Message Date
LLVM GN Syncbot
55cf55cf08 [gn build] Port f27e4548fc42 2021-06-17 17:09:43 +00:00
Saleem Abdulrasool
bb616e9e7a test: clean up some of the RISCV tests (NFC)
This addresses some post-commit comments from jrtc27 to make the tests
easier to process.
2021-06-17 09:51:09 -07:00
Haojian Wu
e76e730b8f fix an -Wunused-variable warning in release built, NFC 2021-06-17 18:48:47 +02:00
Sanjay Patel
25656e8196 [InstSimplify] add tests for computeKnownBits of shift-with-bitcast op; NFC 2021-06-17 12:39:16 -04:00
Sanjay Patel
48440d6126 [InstCombine][x86] add tests for complex vector shift value tracking; NFC
https://llvm.org/PR50123
2021-06-17 12:39:16 -04:00
Saleem Abdulrasool
f56e4f6d3d RISCV: adjust handling of relocation emission for RISCV
This re-architects the RISCV relocation handling to bring the
implementation closer in line with the implementation in binutils.  We
would previously aggressively resolve the relocation.  With this
restructuring, we always will emit a paired relocation for any symbolic
difference of the type of S±T[±C] where S and T are labels and C is a
constant.

GAS has a special target hook controlled by `RELOC_EXPANSION_POSSIBLE`
which indicates that a fixup may be expanded into multiple relocations.
This is used by the RISCV backend to always emit a paired relocation -
either ADD[WIDTH] + SUB[WIDTH] for text relocations or SET[WIDTH] +
SUB[WIDTH] for a debug info relocation.  Irrespective of whether linker
relaxation support is enabled, symbolic difference is always emitted as
a paired relocation.

This change also sinks the target specific behaviour down into the
target specific area rather than exposing it to the shared relocation
handling.  In the process, we also sink the "special" handling for debug
information down into the RISCV target.  Although this improves the path
for the other targets, this is not necessarily entirely ideal either.
The changes in the debug info emission could be done through another
type of hook as this functionality would be required by any other target
which wishes to do linker relaxation.  However, as there are no other
targets in LLVM which currently do this, this is a reasonable thing to
do until such time as the code needs to be shared.

Improve the handling of the relocation (and add a reduced test case from
the Linux kernel) to ensure that we handle complex expressions for
symbolic difference.  This ensures that we correct relocate symbols with
the adddends normalized and associated with the addition portion of the
paired relocation.

This change also addresses some review comments from Alex Bradbury about
the relocations meant for use in the DWARF CFA being named incorrectly
(using ADD6 instead of SET6) in the original change which introduced the
relocation type.

This resolves the issues with the symbolic difference emission
sufficiently to enable building the Linux kernel with clang+IAS+lld
(without linker relaxation).

Resolves PR50153, PR50156!
Fixes: ClangBuiltLinux/linux#1023, ClangBuiltLinux/linux#1143

Reviewed By: nickdesaulniers, maskray

Differential Revision: https://reviews.llvm.org/D103539
2021-06-17 08:20:02 -07:00
Stephen Tozer
84970078e4 Reapply "[DebugInfo] Prevent non-determinism when updating DIArgList users of a value"
Reapply the commit which previously caused build failures due to the
mismatched template arguments between the return type and the returned
SmallVector.

This reverts commit e8991caea8690ec2d17b0b7e1c29bf0da6609076.
2021-06-17 16:16:55 +01:00
Kevin P. Neal
abe1b0a2fe [FPEnv][InstSimplify] Precommit tests for D103169.
In D103169 I'm adding to InstSimplify support for NaN to constrained
intrinsics that have a regular FP IR instruction counterpart. Precommit
the tests for clarity when that ticket lands.
2021-06-17 10:34:39 -04:00
Guillaume Chatelet
913b337ddc [llvm] fix typo in comment 2021-06-17 14:30:52 +00:00
Stephen Tozer
2242a1aa55 Revert "[DebugInfo] Prevent non-determinism when updating DIArgList users of a value"
Commit caused build errors on buildbots with [-Werror,-Wreturn-std-move]
enabled.

This reverts commit fa1de88f81e9c6db5255ca7c4d0fd25606c5a054.
2021-06-17 15:20:59 +01:00
Stephen Tozer
3173d57109 [DebugInfo] Prevent non-determinism when updating DIArgList users of a value
This patch fixes an issue where builds of programs with multiple dbg.values
with DIArgList locations could have non-deterministic output. This issue
was caused by ReplaceableMetadataImpl::getAllArgListUsers, which
returned DIArgList pointers in a random order; the output of this
function would later be used to insert dbg.values, causing the order of
insertion to be non-deterministic. This patch changes getAllArgListUsers
to return pointers in a fixed order.

Differential Revision: https://reviews.llvm.org/D104105
2021-06-17 15:09:27 +01:00
Sjoerd Meijer
523d263530 [FuncSpec] Precommit test: don't specialise funcs with NoDuplicate instrs. NFC. 2021-06-17 14:13:25 +01:00
Simon Pilgrim
1bc07d1287 [X86] combineSelect - refactor MIN/MAX detection code to make it easier to add additional select(setcc,x,y) folds. NFCI.
I need to add some additional handling to address some of the regressions from D101074
2021-06-17 13:50:59 +01:00
Florian Hahn
19b14a93b0 [X86] Check using default in test added in 0bd5bbb31e0345ae.
Make sure llvm-mc is invariant with respect to debug locations in the
test (checks update to use the -x86-pad-for-align default value)
2021-06-17 13:19:43 +01:00
Florian Hahn
3e8d4a4389 [X86] Add test showing binary differences with -x86-pad-for-align.
This patch adds a test case showing how a single extra .loc can cause
binary differences when using -x86-pad-for-align=true.

The issue has been discussed in D94542, PR42138, PR48742.
2021-06-17 12:27:17 +01:00
hyeongyukim
73cd3d2fbf [InstCombine] Fix miscompile on GEP+load to icmp fold (PR45210)
As noted in PR45210: https://bugs.llvm.org/show_bug.cgi?id=45210
...the bug is triggered as Eli say when sext(idx) * ElementSize overflows.

```
   // assume that GV is an array of 4-byte elements
   GEP = gep GV, 0, Idx // this is accessing Idx * 4
   L = load GEP
   ICI = icmp eq L, value
 =>
   ICI = icmp eq Idx, NewIdx
```

The foldCmpLoadFromIndexedGlobal function simplifies GEP+load operation to icmp.
And there is a problem because Idx * ElementSize can overflow.

Let's assume that the wanted value is at offset 0.
Then, there are actually four possible values for Idx to match offset 0: 0x00..00, 0x40..00, 0x80..00, 0xC0..00.
We should return true for all these values, but currently, the new icmp only returns true for 0x00..00.

This problem can be solved by masking off (trailing zeros of ElementSize) bits from Idx.

```
   ...
 =>
   Idx' = and Idx, 0x3F..FF
   ICI = icmp eq Idx', NewIdx
```

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D99481
2021-06-17 19:46:17 +09:00
Martin Storsjö
3f31f63125 [llvm-dlltool] Imply the target arch from a tool triple prefix
Also use the default LLVM target as default for dlltool. This
matches how GNU dlltool behaves; it is compiled with one default
target, which is used if no option is provided.

Extend the anonymous namespace in the implementation file instead
of using static functions.

Based on a patch by Mateusz Mikuła.

The effect of the default LLVM target, if neither the -m option
nor a tool triple prefix is provided, isn't tested, as we can't
make assumptions about what it is set to.

(We could make the default be forced to one of the four supported
architectures if the default triple is another arch, and then just
test that llvm-dlltool without an -m option is able to produce an
import library, without checking the actual architecture though.)

Differential Revision: https://reviews.llvm.org/D104212
2021-06-17 13:02:35 +03:00
Martin Storsjö
a93c99de02 [llvm-dlltool] [test] Add a testcase for all machine option types. NFC.
The existing tests only test that some options (but not e.g. arm)
are accepted, but it doesn't test their functional effect of
affecting the generated object files.

Differential Revision: https://reviews.llvm.org/D104215
2021-06-17 13:02:35 +03:00
Martin Storsjö
fa4e390afc [llvm-dlltool] [test] Remove superfluous --coff-exports option to llvm-readobj. NFC.
The --coff-exports option to llvm-readobj prints the exported symbols
from a DLL/EXE, it doesn't do anything with regards to an import
library.

Differential Revision: https://reviews.llvm.org/D104214
2021-06-17 13:02:34 +03:00
Martin Storsjö
0cb5ff725f [llvm-dlltool] [test] Test both short and long forms of options. NFC.
Differential Revision: https://reviews.llvm.org/D104213
2021-06-17 13:02:34 +03:00
Sjoerd Meijer
467b51294d [FuncSpec] Don't specialise functions with attribute NoDuplicate.
Differential Revision: https://reviews.llvm.org/D104378
2021-06-17 10:32:29 +01:00
Fraser Cormack
9c88fca850 [RISCV][VP] Lower FP VP ISD nodes to RVV instructions
With the exception of `frem`, this patch supports the current set of VP
floating-point binary intrinsics by lowering them to to RVV instructions. It
does so by using the existing `RISCVISD *_VL` custom nodes as an intermediate
layer. Both scalable and fixed-length vectors are supported by using this
method.

The `frem` node is unsupported due to a lack of available instructions. For
fixed-length vectors we could scalarize but that option is not (currently)
available for scalable-vector types. The support is intentionally left out so
it equivalent for both vector types.

The matching of vector/scalar forms is currently lacking, as scalable vector
types do not lower to the custom `VFMV_V_F_VL` node. We could either make
floating-point scalable vector splats lower to this node, or support the
matching of multiple kinds of splat via a `ComplexPattern`, much like we do for
integer types.

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D104237
2021-06-17 10:04:00 +01:00
David Green
751ee64aee [InterleaveAccess] Copy fast math flags when adjusting binary operators in interleave access pass
The Interleave Access pass will convert shuffle(binop(load, load)) to
binop(shuffle(load), shuffle(load)), in order to create more
interleaving load patterns (VLD2/3/4) that might have been messed up by
instcombine. As shown in D104247 we were missing copying IR flags to the
new instruction though, which should just be kept the same as the
original instruction.

Differential Revision: https://reviews.llvm.org/D104255
2021-06-17 09:53:33 +01:00
Tomasz Miąsko
a8b1d6117d [Demangle] Support Rust v0 mangling scheme in llvm::demangle
The llvm::demangle is currently used by llvm-objdump and llvm-readobj,
so this effectively adds support for Rust v0 mangling to those
applications.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D104340
2021-06-17 10:37:26 +02:00
Florian Hahn
9585730a05 [VPlan] Support PHIs as LastInst when inserting scalars in ::get().
At the moment, we create insertelement instructions directly after
LastInst when inserting scalar values in a vector in
VPTransformState::get.

This results in invalid IR when LastInst is a phi, followed by another
phi. In that case, the new instructions should be inserted just after
the last PHI node in the block.

At the moment, I don't think the problematic case can be triggered, but
it can happen once predicate regions are merged and multiple
VPredInstPHI recipes are in the same block (D100260).

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D104188
2021-06-17 09:36:44 +01:00
Bjorn Pettersson
29ffba4b56 Update @llvm.powi to handle different int sizes for the exponent
This can be seen as a follow up to commit 0ee439b705e82a4fe20e2,
that changed the second argument of __powidf2, __powisf2 and
__powitf2 in compiler-rt from si_int to int. That was to align with
how those runtimes are defined in libgcc.
One thing that seem to have been missing in that patch was to make
sure that the rest of LLVM also handle that the argument now depends
on the size of int (not using the si_int machine mode for 32-bit).
When using __builtin_powi for a target with 16-bit int clang crashed.
And when emitting libcalls to those rtlib functions, typically when
lowering @llvm.powi), the backend would always prepare the exponent
argument as an i32 which caused miscompiles when the rtlib was
compiled with 16-bit int.

The solution used here is to use an overloaded type for the second
argument in @llvm.powi. This way clang can use the "correct" type
when lowering __builtin_powi, and then later when emitting the libcall
it is assumed that the type used in @llvm.powi matches the rtlib
function.

One thing that needed some extra attention was that when vectorizing
calls several passes did not support that several arguments could
be overloaded in the intrinsics. This patch allows overload of a
scalar operand by adding hasVectorInstrinsicOverloadedScalarOpd, with
an entry for powi.

Differential Revision: https://reviews.llvm.org/D99439
2021-06-17 09:38:28 +02:00
Lang Hames
9d62b78ea1 [ORC] Switch from uint8_t to char buffers for TargetProcessControl::runWrapper.
This matches WrapperFunctionResult's char buffer, cutting down on the number of
pointer casts needed.
2021-06-17 13:27:09 +10:00
Stanislav Mekhanoshin
20998194c9 [AMDGPU] Fixed constexpr expansion to handle multiple uses
Recently added convertConstantExprsToInstructions() does not handle
a case when a same ConstantExpr used multiple times in the same
instruction. A first use is replaced and the rest of the uses in the
instruction are replaced as well with the replaceUsesOfWith(). Then
function attempts to replace a constant already destroyed.

So far this interface is only used by the AMDGPU BE.

Differential Revision: https://reviews.llvm.org/D104425
2021-06-16 16:57:41 -07:00
Ben Shi
e14cf3b432 [RISCV][test] Add new tests of SH*ADD in the zba extension
These tests will show the following optimization by future patches.

Rx + Ry * 6  => (SH1ADD (SH2ADD Rx, Ry), Ry)
Rx + Ry * 10 => (SH1ADD (SH3ADD Rx, Ry), Ry)
Rx + Ry * 12 => (SH2ADD (SH3ADD Rx, Ry), Ry)

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D104210
2021-06-17 07:02:33 +08:00
Nico Weber
9be684f5d3 [gn build] (manually) port f9aba9a5afe 2021-06-16 18:04:46 -04:00
Joachim Meyer
473878f311 Use -cfg-func-name value as filter for -view-cfg, etc.
Currently the value is only used when calling `F->viewCFG()` which is missing out on its potential and usefulness.
So I added the check to the printer passes as well.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D102011
2021-06-16 23:54:51 +02:00
Adrian Prantl
be89f7fc66 Move the definition of LLVM_SUPPORT_XCODE_SIGNPOSTS into llvm-config.h
since it is now used by a public header file (Signposts.h).
This fixes the standalone LLDB build.
2021-06-16 14:40:37 -07:00
Min-Yih Hsu
341aadfd56 [MCA] Anchoring the vtable of CustomBehaviour
Put the dtor of mca::CustomBehaviour into the cpp file to avoid
undefined vtable when linking libLLVMMCACustomBehaviourAMDGPU as shared
library.

Differential Revision: https://reviews.llvm.org/D104401
2021-06-16 12:43:58 -07:00
Eli Friedman
76e90724b1 [NFC][ScalarEvolution] Refactor createNodeForSelectOrPHI
In preparation for D103660.
2021-06-16 12:32:32 -07:00
Fangrui Song
294d3d8800 [llvm-objcopy][MachO] Copy LC_LINKER_OPTIMIZATION_HINT
This fixes `error: unsupported load command (cmd=0x2e)`
2021-06-16 12:09:50 -07:00
Hongtao Yu
45a66978f9 [CSSPGO] Report zero-count probe in profile instead of dangling probes.
Previously dangling samples were represented by INT64_MAX in sample profile while probes never executed were not reported. This was based on an observation that dangling probes were only at a smaller portion than zero-count probes. However, with compiler optimizations, dangling probes end up becoming at large portion of all probes in general and reporting them does not make sense from profile size point of view. This change flips sample reporting by reporting zero-count probes instead. This enabled dangling probe to be represented by none (missing entry in profile). This has a couple benefits:

1. Reducing sample profile size in optimize mode, even when the number of non-executed probes outperform the number of dangling probes, since INT64_MAX takes more space over 0 to encode.

2. Binary size savings. No need to encode dangling probe anymore, since missing probes are treated as dangling in the profile reader.

3. Reducing compiler work to track dangling probes. However, for probes that are real dead and removed, we still need the compiler to identify them so that they can be reported as zero-count, instead of mistreated as dangling probes.

4. Improving counts quality by respecting the counts already collected on the non-dangling copy of a probe. A probe, when duplicated, gets two copies at runtime. If one of them is dangling while the other is not, merging the two probes at profile generation time will cause the real samples collected on the non-dangling one to be discarded. Not reporting the dangling counterpart will keep the real samples.

5. Better readability.

6. Be consistent with non-CS dwarf line number based profile. Zero counts are trusted by the compiler counts inferencer while missing counts will be inferred by the compiler.

Note that the current patch does include any work for #3. There will be follow-up changes.

For #1, I've seen for a large Facebook service, the text profile is reduced by 7%. For extbinary profile, the size of  LBRProfileSection is reduced by 35%.

For #4, I have seen general counts quality for SPEC2017 is improved by 10%.

Reviewed By: wenlei, wlei, wmi

Differential Revision: https://reviews.llvm.org/D104129
2021-06-16 11:45:29 -07:00
Sanjay Patel
03cd031cb2 [ValueTracking] add FP intrinsics to test for propagatesPoison; NFC
I'm not sure what behavior we want if the FP environment is
not default (also not sure if there's a way to enumerate
the full list of intrinsics programmatically), but currently
these are all defaulting to 'false' (doesn't propagate).
2021-06-16 13:43:03 -04:00
Fangrui Song
231f43b13f RISCVFixupKinds.h: Don’t duplicate function or class name at the beginning of the comment && fix some comments 2021-06-16 10:42:43 -07:00
Fangrui Song
30cd61aad2 [llvm-objcopy] Make ihex writer similar to binary writer
There is no need to differentiate whether `UseSegments` is true or
false. Unifying the cases makes the behavior closer to BinaryWriter.

This improves compatibility with objcopy because SHF_ALLOC sections not in
a PT_LOAD will not be skipped. Such cases are usually erroneous input, though.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D104186
2021-06-16 10:08:20 -07:00
Sushma Unnibhavi
900cbf02d0 [M68k][GloballSel] Adding initial GlobalISel infrastructure
Wiring up GlobalISel for the M68k backend

Differential Revision: https://reviews.llvm.org/D101819
2021-06-16 10:48:38 -06:00
Sanjay Patel
be210d2cc2 [ValueTracking] add tests for propagatesPoison with FP ops; NFC
Verify that this matches the behavior in InstSimplify:
D104383 / ce95200b7942

We still need to add code/tests for FP intrinsics.
2021-06-16 12:14:28 -04:00
LLVM GN Syncbot
a4f344271c [gn build] Port ef16c8eaa5cd 2021-06-16 15:57:43 +00:00
Patrick Holland
449e2cbd5e Reapply "[MCA] Adding the CustomBehaviour class to llvm-mca".
The original change was pushed in main as commit f7a23ecece52.
It was then reverted by commit a04f01bab2 because it caused linker failures
on buildbots that don't build the AMDGPU target.

--

Some instructions are not defined well enough within the target’s scheduling
model for llvm-mca to be able to properly simulate its behaviour. The ideal
solution to this situation is to modify the scheduling model, but that’s not
always a viable strategy. Maybe other parts of the backend depend on that
instruction being modelled the way that it is. Or maybe the instruction is quite
complex and it’s difficult to fully capture its behaviour with tablegen. The
CustomBehaviour class (which I will refer to as CB frequently) is designed to
provide intuitive scaffolding for developers to implement the correct modelling
for these instructions.

More details are available in the original commit log message (f7a23ecece52).

Differential Revision: https://reviews.llvm.org/D104149
2021-06-16 16:54:48 +01:00
Sanjay Patel
31ec72a21f [InstSimplify] propagate poison through FP ops
We already have this fold:
  fadd float poison, 1.0 --> poison
...via ConstantFolding, so this makes the behavior consistent
if the other operand(s) are non-constant.

The fold for undef was added before poison existed as a
value/type in IR.

This came up in D102673 / D103169
because we're trying to sort out the more complicated handling
for constrained math ops.
We should have the handling for the regular instructions done
first, so we can build on that (or diverge as needed).

Differential Revision: https://reviews.llvm.org/D104383
2021-06-16 11:31:58 -04:00
Sjoerd Meijer
6a5d677fd3 [FuncSpec] Fixed prefix typo in test function-specialization-noexec.ll. NFC. 2021-06-16 16:25:26 +01:00
Dylan Fleming
59503026a4 [SVE] Selection failure with scalable insertelements
Reviewed By: efriedma, CarolineConcatto

Differential Revision: https://reviews.llvm.org/D104244
2021-06-16 15:38:31 +01:00
James Henderson
8beee28e98 [obj2yaml] Address D104035 review comments
Accidentally missed from commit 5c1639fe064b.

Differential Revision: https://reviews.llvm.org/D104035
2021-06-16 15:01:54 +01:00
Jay Foad
53635563ca [AMDGPU] Set VOP3P flag on Real instructions
This does not affect codegen but might benefit llvm-mca.
2021-06-16 15:00:45 +01:00
David Spickett
0a8120a8f5 [llvm][AArch64] Handle arrays of struct properly (from IR)
This only applies to FastIsel. GlobalIsel seems to sidestep
the issue.

This fixes https://bugs.llvm.org/show_bug.cgi?id=46996

One of the things we do in llvm is decide if a type needs
consecutive registers. Previously, we just checked if it
was an array or not.
(plus an SVE specific check that is not changing here)

This causes some confusion when you arbitrary IR like:
```
%T1 = type { double, i1 };
define [ 1 x %T1 ] @foo() {
entry:
  ret [ 1 x %T1 ] zeroinitializer
}
```

We see it is an array so we call CC_AArch64_Custom_Block
which bails out when it sees the i1, a type we don't want
to put into a block.

This leaves the location of the double in some kind of
intermediate state and leads to odd codegen. Which then crashes
the backend because it doesn't know how to implement
what it's been asked for.

You get this:
```
  renamable $d0 = FMOVD0
  $w0 = COPY killed renamable $d0
```

Rather than this:
```
  $d0 = FMOVD0
  $w0 = COPY $wzr
```

The backend knows how to copy 64 bit to 64 bit registers,
but not 64 to 32. It can certainly be taught how but the real
issue seems to be us even trying to assign a register block
in the first place.

This change makes the logic of
AArch64TargetLowering::functionArgumentNeedsConsecutiveRegisters
a bit more in depth. If we find an array, also check that all the
nested aggregates in that array have a single member type.

Then CC_AArch64_Custom_Block's assumption of a type that looks
like [ N x type ] will be valid and we get the expected codegen.

New tests have been added to exercise these situations. Note that
some of the output is not ABI compliant. The aim of this change is
to simply handle these situations and not to make our processing
of arbitrary IR ABI compliant.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D104123
2021-06-16 13:56:01 +00:00
Andrea Di Biagio
a8b232ce81 [MCA][InstrBuilder] Always check for implicit uses of resource units (PR50725).
When instructions are issued to the underlying pipeline resources, the
mca::ResourceManager should also check for the presence of extra uses induced by
the explicit consumption of multiple partially overlapping group resources.

Fixes PR50725
2021-06-16 14:51:12 +01:00