1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
Commit Graph

219294 Commits

Author SHA1 Message Date
Ayke van Laethem
8ded1a7aa8 [AVR] Fix rotate instructions
This patch fixes some issues with the RORB pseudo instruction.

  - A minor issue in which the instructions were said to use the SREG,
    which is not true.
  - An issue with the BLD instruction, which did not have an output operand.
  - A major issue in which invalid instructions were generated. The fix
    also reduce RORB from 4 to 3 instructions, so it's also a small
    optimization.

These issues were flagged by the machine verifier.

Differential Revision: https://reviews.llvm.org/D96957
2021-07-24 14:03:26 +02:00
Ayke van Laethem
1bf9d7e37d [AVR] Expand large shifts early in IR
This patch makes sure shift instructions such as this one:

    %result = shl i32 %n, %amount

are expanded just before the IR to SelectionDAG conversion to a loop so
that calls to non-existing library functions such as __ashlsi3 are
avoided. The generated code is currently pretty bad but there's a lot of
room for improvement: the shift itself can be done in just four
instructions.

Differential Revision: https://reviews.llvm.org/D96677
2021-07-24 14:03:26 +02:00
Ayke van Laethem
2e9e365692 [AVR] Improve 8/16 bit atomic operations
There were some serious issues with atomic operations. This patch should
fix the biggest issues.

For details on the issue take a look at this Compiler Explorer sample:
https://godbolt.org/z/n3ndhn

Code:

    void atomicadd(_Atomic char *val) {
        *val += 5;
    }

Output:

    atomicadd:
        movw    r26, r24
        ldi     r24, 5     ; 'operand' register
        in      r0, 63
        cli
        ld      r24, X     ; load value
        add     r24, r26   ; value += X
        st      X, r24     ; store value back
        out     63, r0
        ret                ; return the wrong value (in r24)

There are various problems with this.

 - The value to add (5) is stored in r24. However, the value to add to
   is loaded in the same register: r24.
 - The `add` instruction adds half of the pointer to the loaded value,
   instead of (attempting to) add the operand with value 5.
 - The output value of the cmpxchg instruction (which is not used in
   this code sample) is the new value with 5 added, not the old value.
   The LangRef specifies that it has to be the old value, before the
   operation.

This patch fixes the first two and leaves the third problem to be fixed
at a later date. I believe atomics were mostly broken before this patch,
with this patch they should become usable as long as you ignore the
output of the atomic operation. In particular it fixes the following
things:

 - It sets the earlyclobber flag for the input ('$operand' operand) so
   that the register allocator puts it in a different register than the
   output value.
 - It fixes a number of issues with the pseudo op expansion pass, for
   example now it adds the $operand field instead of the pointer. This
   fixes most machine instruction verifier issues (other flagged issues
   are unrelated to atomics).

Differential Revision: https://reviews.llvm.org/D97127
2021-07-24 14:03:26 +02:00
Ayke van Laethem
6efffceb63 [AVR] Set R31R30 as clobbered after ADJCALLSTACKDOWN
In most cases, using R31R30 is fine because the call (which always
precedes ADJCALLSTACKDOWN) will clobber R31R30 anyway. However, in some
rare cases the register allocator might insert an instruction between
the call and the ADJCALLSTACKDOWN instruction and expect the register
pair to be live afterwards. I think this happens as a result of
rematerialization. Therefore, to fix this, the instruction needs to have
Defs set to R31R30.

Setting the Defs field does have the effect of making the instruction
look dead, which it certainly is not. This is fixed by setting
hasSideEffects to true.

Differential Revision: https://reviews.llvm.org/D97745
2021-07-24 14:03:26 +02:00
Ayke van Laethem
4dd15b258c [AVR] Do not chain stores in call frame setup
Previously, AVRTargetLowering::LowerCall attempted to keep stack stores
in order with chains. Perhaps this worked in the past, but it does not
work now: it appears that the SelectionDAG legalization phase removes
these chains. Therefore, I've removed these chains entirely to match
X86 (which, similar to AVR, also prefers to use push instructions over
stack-relative stores to set up a call frame). With this change, all the
stack stores are in a somewhat reasonable order.

Differential Revision: https://reviews.llvm.org/D97853
2021-07-24 14:03:26 +02:00
Simon Pilgrim
cb0d04c29e [DAG] Add initial SelectionDAG::isGuaranteedNotToBeUndefOrPoison framework (PR51129)
I've setup the basic framework for the isGuaranteedNotToBeUndefOrPoison call and updated DAGCombiner::visitFREEZE to use it, further Opcodes can be handled when we have test coverage.

I'm not aware of any vector test freeze coverage so the DemandedElts (and the Depth) args are not being used yet - but they are in place.

SelectionDAG::isGuaranteedNotToBePoison wrappers have also been added.

Differential Revision: https://reviews.llvm.org/D106668
2021-07-24 11:36:35 +01:00
Sanjay Patel
70ba442475 [x86] add more tests for add with CMOV of constants; NFC
See D106607 / https://llvm.org/PR51069 for details.
2021-07-24 06:23:36 -04:00
Alexander Belyaev
4bc5332eae [llvm] Inline getAssociatedFunction() in LLVM_DEBUG.
Function* F is used only inside LLVM_DEBUG, so that it causes unused
variable warning.
2021-07-24 11:49:21 +02:00
hyeongyu kim
c8147441f9 [InstCombine] Add freezeAllUsesOfArgument to visitFreeze
In D106041, a freeze was added before the branch condition to solve the miscompilation problem of SimpleLoopUnswitch.
However, I found that the added freeze disturbed other optimizations in the following situations.
```
arg.fr = freeze(arg)
use(arg.fr)
...
use(arg)
```
It is a problem that occurred when arg and arg.fr were recognized as different values.
Therefore, changing to use arg.fr instead of arg throughout the function eliminates the above problem.
Thus, I add a function that changes all uses of arg to freeze(arg) to visitFreeze of InstCombine.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D106233
2021-07-24 18:08:58 +09:00
Nikita Popov
d4948ed188 [SimplifyCFG] Add additional if conversion tests (NFC)
Test a readonly call in between, as well as the combination of
an atomic and simple store.
2021-07-24 10:35:36 +02:00
Markus Böck
db4a145be0 [CMake] Add LIBXML2_DEFINITIONS when testing for symbol existance
Currently when linking LLVM against Libxml2, a simple check is performed to check whether it can be linked successfully. This check currently adds the include directories and the libraries for libxml2, but not definitions found by the config.

This causes issues on Windows when trying to link against a static libxml2. Libxml2 requires LIBXML_STATIC to be defined in the preprocessor to be able to link statically. This definition is put into LIBXML2_DEFINITIONS in the cmake config, but not properly forwarded to check_symbol_exists leading to it failing as it could not find xmlReadMemory in a DLL.

This patch simply appends the content of LIBXML2_DEFINITIONS to the symbol check definitions, fixing the issue.

Differential Revision: https://reviews.llvm.org/D106740
2021-07-24 09:55:14 +02:00
Azharuddin Mohammed
ac4ed88e1d [CMake] Don't LTO optimize targets on Darwin, but only if its not ThinLTO
This is just a workaround. Pass the `-mllvm,-O0` link flags only if its
not ThinLTO. Doing that with ThinLTO currently results in an error:

```
Remaining virtual register operands
UNREACHABLE executed at .../llvm/lib/CodeGen/MachineRegisterInfo.cpp:209!
```
2021-07-23 22:38:35 -07:00
Amara Emerson
c79055fae4 [GlobalISel] Add GUnmerge, GMerge, GConcatVectors, GBuildVector abstractions. NFC.
Use these to slightly simplify some code in the artifact combiner.
2021-07-23 22:32:26 -07:00
Lang Hames
500a10cb5e Re-re-re-apply "[ORC][ORC-RT] Add initial native-TLV support to MachOPlatform."
The ccache builders have recevied a config update that should eliminate the
build issues seen previously.
2021-07-24 13:16:12 +10:00
LLVM GN Syncbot
28751b1109 [gn build] Port 96709823ec37 2021-07-24 03:08:02 +00:00
Kuter Dinel
a502a514d2 [AMDGPU] Deduce attributes with the Attributor
This patch introduces a pass that uses the Attributor to deduce AMDGPU specific attributes.

Reviewed By: jdoerfert, arsenm

Differential Revision: https://reviews.llvm.org/D104997
2021-07-24 06:07:15 +03:00
Philip Reames
882c5434a1 [tests] SCEV trip count w/ neg step and varying rhs 2021-07-23 17:19:46 -07:00
Philip Reames
429872ef0c Style tweaks for SCEV's computeMaxBECountForLT [NFC] 2021-07-23 17:19:45 -07:00
Fangrui Song
f767ab54db [LangRef] Clarify comdat
* ELF supports `nodeduplicate`.
* ELF calls the concept "section group". `GRP_COMDAT` emulates the PE COMDAT deduplication feature.
* "COMDAT group" is an ELF term. Avoid it for PE/COFF.
* WebAssembly supports comdat but only supports the `any` selection kind. https://bugs.llvm.org/show_bug.cgi?id=50531
* A comdat must be included or omitted as a unit. Both the compiler and the linker must obey this rule.
* A global object can be a member of at most one comdat.
* COFF requires a non-local linkage for non-`nodeduplicate` selection kinds.
* llvm.global_ctors/.llvm.global_dtors: if the third field is used on ELF, it must reference a global variable or function in a comdat

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D106300
2021-07-23 16:33:06 -07:00
Kuter Dinel
bb892cf39f [Attributor][FIX] checkForAllInstructions, correctly handle declarations
checkForAllInstructions was not handling declarations correctly.
It should have been returning false when it gets called on a declaration

The patch also fixes a test case for AAFunctionReachability for it to be able
to pass after the changes to the checkForAllinstructions.

Differential Revision: https://reviews.llvm.org/D106625
2021-07-24 02:21:29 +03:00
Stella Stamenova
eb8efed47c [cmake] Export LLVM_HOST_TRIPLE in the LLVMConfig.cmake
This is referenced in several of the cmake files that are part of an llvm install and it is also useful by downstream components such as onnx-mlir.

Differential Revision: https://reviews.llvm.org/D106686
2021-07-23 15:52:36 -07:00
Philip Reames
307c1ee33f [SCEV] Fix bug involving zero step and non-invariant RHS in trip count logic
Eli pointed out the issue when reviewing D104140. The max trip count logic makes an assumption that the value of IV changes. When the step is zero, the nowrap fact becomes trivial, and thus there's nothing preventing the loop from being nearly infinite. (The "nearly" part is because mustprogress may disallow an infinite loop while still allowing 999999999 iterations before RHS happens to allow an exit.)

This is very difficult to see in practice. You need a means to produce a loop varying RHS in a mustprogress loop which doesn't allow the loop to be infinite. In most cases, LICM or SCEV are smart enough to remove the loop varying expressions.

Differential Revision: https://reviews.llvm.org/D106327
2021-07-23 15:19:23 -07:00
Roman Lebedev
2a3a16cec8 [NFC][SimplifyCFG] Add tests for FoldTwoEntryPHINode() with prof md 2021-07-24 01:03:37 +03:00
Nikita Popov
c2a36153e1 [ConstantFold] Fix GEP of GEP fold with opaque pointers
This was previously combining indices even though they operate on
different types. For non-opaque pointers, the condition is
automatically satisfied based on the pointer types being equal.
2021-07-23 23:56:41 +02:00
Nikita Popov
140985f91f [ConstantFold] Extract GEP of GEP fold (NFCI)
Move this fold into a separate function and clean up the control
flow a bit.
2021-07-23 23:49:40 +02:00
Thomas Lively
a913c9bb30 [WebAssembly] Codegen for pmin and pmax
Replace the clang builtins and LLVM intrinsics for {f32x4,f64x2}.{pmin,pmax}
with standard codegen patterns. Since wasm_simd128.h uses an integer vector as
the standard single vector type, the IR for the pmin and pmax intrinsic
functions contains bitcasts that would not be there otherwise. Add extra codegen
patterns that can still select the pmin and pmax instructions in the presence of
these bitcasts.

Differential Revision: https://reviews.llvm.org/D106612
2021-07-23 14:49:21 -07:00
Thomas Lively
40588d371f [WebAssembly][NFC] Simplify SIMD bitconvert pattern
Differential Revision: https://reviews.llvm.org/D106680
2021-07-23 14:43:48 -07:00
Roman Lebedev
14b3a6d1a9 [NFC][SimplifyCFG] Make 'conditional block' handling more straight-forward
This will simplify making use of profile weights
to not perform the speculation when obviously unprofitable.
2021-07-24 00:18:27 +03:00
Roman Lebedev
4b1e13b415 [NFC][SimplifyCFG] FoldTwoEntryPHINode(): make better use of GetIfCondition() returning dom block 2021-07-24 00:18:26 +03:00
Roman Lebedev
fdb7d69784 [NFC][BasicBlockUtils] Refactor GetIfCondition() to return the branch, not it's condition
Otherwise e.g. the FoldTwoEntryPHINode() has to do a lot of legwork
to re-deduce what is the dominant block (i.e. for which block
is this branch the terminator).
2021-07-24 00:18:26 +03:00
Pirama Arumuga Nainar
987b8f791e [NewPM] Add CrossDSOCFI pass irrespective of LTO optimization level
This pass is not an optimization and is needed for CFI functionality
(cross-dso verification).

Differential Revision: https://reviews.llvm.org/D106699
2021-07-23 14:13:12 -07:00
Nikita Popov
2a84a8fcc2 [MergeICmps] Relax sinking check
The check for sinking instructions past the load + cmp sequence
currently checks for side-effects, which includes writing to memory
and unwinding. However, I don't believe we care about sinking the
instructions past an unwind (as they don't have any side-effects
themselves).

Differential Revision: https://reviews.llvm.org/D106591
2021-07-23 22:16:11 +02:00
Martin Storsjö
7161be9ee9 [CMake] Add version to libLLVM also on non-UNIX
As discussed in https://reviews.llvm.org/D87521

llvm-config expects versioned library regardless of platform.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D89009
2021-07-23 23:05:55 +03:00
Martin Storsjö
ea4f7bb1a3 [llvm-rc] Allow dashes as part of resource name strings
This matches what MS rc.exe allows in practice. I'm not aware of
any legal syntax case that are broken by allowing dashes as part
of what the tokenizer considers an Identifier - but I'm not
very well versed in the RC syntax either, can @amccarth think of
any case that would be broken by this?

This fixes downstream bug
https://github.com/msys2/MINGW-packages/issues/9180.

Additionally, rc.exe allows such resource name strings to be surrounded
by quotes, ending up with e.g.

    Resource name (string): "QUOTEDNAME"

(i.e., the quotes end up as part of the string), which llvm-rc doesn't
support yet either. (I'm not aware of such cases in the wild though,
but resource string names with dashes do exist.)

This also allows including files with unquoted paths, with filenames
containing dashes (which fixes
https://github.com/msys2/MINGW-packages/issues/9130, which has been
worked around differently so far).

Differential Revision: https://reviews.llvm.org/D106598
2021-07-23 23:05:20 +03:00
Kevin P. Neal
41668e0357 Revert "[FPEnv][InstSimplify] Enable more folds for constrained fadd"
Build bots have started failing.

This reverts commit 64c2b2c69d61dbb6459037a7bfddf29e1f280c8f.
2021-07-23 15:09:05 -04:00
Kevin P. Neal
67bfc4816d [FPEnv][InstSimplify] Enable more folds for constrained fadd
Precommit tests.
2021-07-23 14:59:38 -04:00
Cyndy Ishida
cd241d2fc0 [llvm][NFC] Fix typos in Errc.h description 2021-07-23 11:54:49 -07:00
Mircea Trofin
4559a48614 [NFC][MLGO] Just use the underlying protobuf object for logging
Avoid buffering just to copy the buffered data, in 'development
mode', when logging. Instead, just populate the underlying protobuf.

Differential Revision: https://reviews.llvm.org/D106592
2021-07-23 10:56:48 -07:00
Shilei Tian
89d6157c2c [AbstractAttributor] Refine logic to indicate pessimistic fixed point when folding __kmpc_is_spmd_exec_mode
Since we are using assumed information now, the logic should be refined to avoid
unncessary assertion.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D106630
2021-07-23 13:36:47 -04:00
Fangrui Song
c3bb156e90 Revert "[clang] -falign-loops="
This reverts commit 42896eeed9e3d12e7e38217a0d7e35b9736451ac.

Unfinished. Accidentally pushed when reverting a clangd commit.
2021-07-23 09:58:35 -07:00
Fangrui Song
05f5a9a949 [clang] -falign-loops= 2021-07-23 09:50:43 -07:00
Fraser Cormack
65b887fbf8 [RISCV] Add a test showing an incorrect vsetvli insertion
This patch adds a reduced test case which identifies an illegal vsetvli
inserted by the compiler. The compiler emits a vsetvli which is intended
to preserve VL with the SEW/LMUL ratio e32/m1 when in fact the VL could
have been set by e64/m2 in a predecessor block.

Differential Revision: https://reviews.llvm.org/D106286
2021-07-23 09:27:06 -07:00
LLVM GN Syncbot
cf4b05e2f6 [gn build] Port e5d8b93e5a25 2021-07-23 16:13:25 +00:00
LLVM GN Syncbot
5c1975283a [gn build] Port 0ad562b48bfd 2021-07-23 16:13:24 +00:00
Craig Topper
a4ed0c97a6 [RISCV] Avoid using x0,x0 vsetvli for vmv.x.s and vfmv.f.s unless we know the sew/lmul ratio is constant.
Since we're changing VTYPE, we may change VLMAX which could
invalidate the previous VL. If we can't tell if it is safe we
should use an AVL of 1 instead of keeping the old VL.

This is a quick fix. We may want to thread VL to the pseudo
instruction instead of making up a value. That will require ISD
opcode changes and changes to the C intrinsic interface.

This fixes the issue raised in D106286.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D106403
2021-07-23 09:12:05 -07:00
Craig Topper
da55d61e8f [X86] Fix a bug in TEST with immediate creation
This code tries to form a TEST from CMP+AND with an optional
truncate in between. If we looked through the truncate, we may
have extra bits in the AND mask that shouldn't participate in
the checks. Normally SimplifyDemendedBits takes care of this, but
the AND may have another user. So manually mask out any extra bits.

Fixes PR51175.

Differential Revision: https://reviews.llvm.org/D106634
2021-07-23 09:03:53 -07:00
luxufan
42d771a8d4 [JITLink] Add riscv.cpp 2021-07-23 23:57:44 +08:00
luxufan
85def5bf4e [JITLink][RISCV] Initial Support RISCV64 in JITLink
This patch is the initial support, it implements translation from object file to JIT link graph, and very few relocations were supported. Currently, the test file ELF_pc_indirect.s is passed, the HelloWorld program(compiled with mno-relax flag) can be linked correctly and run on instruction emulator correctly.

In the downstream implementation, I have implemented the GOT, PLT function, and EHFrame and some optimization will be implement soon. I will organize the code in to patches, then gradually send it to upstream.

Differential Revision: https://reviews.llvm.org/D105429
2021-07-23 23:47:30 +08:00
Fangrui Song
43ffee6b95 [llvm-symbolizer] Remove one-dash long options
Most modern tools only accept two-dash long options. Remove one-dash
long options which are not recognized by GNU style `getopt_long`.
This ensures long options cannot collide with grouped short options.

Note: llvm-symbolizer has `-demangle={true,false}` for pprof compatibility
(for a while). They are kept.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D106377
2021-07-23 08:35:45 -07:00
Kazu Hirata
73fafa5526 [ARM] Remove getHWDivName (NFC)
This function seems to be unused for at least 5 years.
2021-07-23 07:44:23 -07:00