232 Commits

Author SHA1 Message Date
Alex Voicu
ab7dba233a
[CodeGen][LLVM] Make the va_list related intrinsics generic. (#85460)
Currently, the builtins used for implementing `va_list` handling
unconditionally take their arguments as unqualified `ptr`s i.e. pointers
to AS 0. This does not work for targets where the default AS is not 0 or
AS 0 is not a viable AS (for example, a target might choose 0 to
represent the constant address space). This patch changes the builtins'
signature to take generic `anyptr` args, which corrects this issue. It
is noisy due to the number of tests affected. A test for an upstream
target which does not use 0 as its default AS (SPIRV for HIP device
compilations) is added as well.
2024-03-27 11:41:34 +00:00
ManuelJBrito
229640343e
[NewGVN][NFC]Regenerate test checks (#85280)
Regenerate test checks for NewGVN.
2024-03-14 21:49:45 +00:00
Nikita Popov
2d69827c5c [Transforms] Convert tests to opaque pointers (NFC) 2024-02-05 11:57:34 +01:00
Alex Richardson
0359a78f77 Add target REQUIRES to 3 more tests
These tests all need an x86 backend for the correct data layout.
2023-10-26 17:41:05 -07:00
Alex Richardson
e39f6c1844 [opt] Infer DataLayout from triple if not specified
There are many tests that specify a target triple/CPU flags but no
DataLayout which can lead to IR being generated that has unusual
behaviour. This commit attempts to use the default DataLayout based
on the relevant flags if there is no explicit override on the command
line or in the IR file.

One thing that is not currently possible to differentiate from a missing
datalayout `target datalayout = ""` in the IR file since the current
APIs don't allow detecting this case. If it is considered useful to
support this case (instead of passing "-data-layout=" on the command
line), I can change IR parsers to track whether they have seen such a
directive and change the callback type.

Differential Revision: https://reviews.llvm.org/D141060
2023-10-26 12:07:37 -07:00
Nikita Popov
8e353fb6e9 [NewGVN] Patch replacement instruction even for removed instructions
When removing an instruction, we still need to merge its IR flags
into the leader, because there may have been a transitive use.

Fixes https://github.com/llvm/llvm-project/issues/53218.
2023-09-28 11:45:19 +02:00
Nikita Popov
fb8ce45a03 [NewGVN] Add another test for #53218 (NFC) 2023-09-26 15:06:19 +02:00
Nikita Popov
a09e32e5fe [InstSimplify] Respect UseInstrInfo in more folds
Some folds using m_NUW, m_NSW style matchers were missed, make
sure they respect UseInstrInfo.

This is part of #53218, but not a complete fix for the issue.
2023-09-26 13:54:03 +02:00
Nikita Popov
78c7201d68 [NewGVN] Regenerate test checks (NFC) 2023-09-26 13:54:03 +02:00
Nikita Popov
1d3e38bfb7 [NewGVN] Add test for #53218 (NFC) 2023-09-26 13:54:03 +02:00
Konstantina Mitropoulou
3583d40b3c
[NFC][NewGVN] Update assume_dominating_icmp.ll (#66711) 2023-09-18 23:47:48 -07:00
Konstantina Mitropoulou
135e5216ba
[NewGVN] Set parent to the temporal instructions that are generated during phi-of-ops optimization (#66314)
- Test for future commit in NewGVN
- [NewGVN] Set parent to the temporal instructions that are generated
during phi-of-ops optimization
2023-09-18 10:13:44 -07:00
Konstantina Mitropoulou
798f2465f3 [NewGVN] Decrement UseCount only if SSA copy has one use
Committing on behalf of @vladimirradosavljevic (Vladimir Radosavljevic)

Differential Revision : https: // reviews.llvm.org/D157267
2023-09-11 18:08:14 -07:00
ManuelJBrito
a1f5ea5b5f Revert "[NewGVN][PHIOFOPS] Relax conditions when checking safety of memory accesses"
NewGVN isn't enabled by default so some test failures were being missed.
Reverting to do more testing offline.

This reverts commit c59bc230e738036050f4c9b1ebde88699eec74bf.
2023-08-28 15:25:16 +01:00
Alina Sbirlea
89fa0dd1fb [MemorySSA] Handle queries with empty memory location. 2023-08-10 09:57:32 -07:00
ManuelJBrito
c59bc230e7 [NewGVN][PHIOFOPS] Relax conditions when checking safety of memory accesses
Currently, we consider any instruction that might read from memory to be unsafe for phi-of-ops.
This patch refines that by walking the clobbering memDefs until we either hit a block that
strictly dominates the phi block (safe) or we hit a clobbering memPhi (unsafe).

Differential Revision: https://reviews.llvm.org/D156055
2023-08-01 08:51:57 +01:00
ManuelJBrito
fb4a836b5c [NewGVN] Regenerate test checks (NFC)
Regenerate some test checks in  preparation for a patch that
fixes https://github.com/llvm/llvm-project/issues/53218.
2023-07-26 17:24:39 +01:00
ManuelJBrito
ace9b6bbf5 [NewGVN] Canonicalize expressions for commutative intrinsics
Ensure that commutative intrinsics that only differ by a permutation
of their operands get the same value number by sorting the operand value
numbers.

Fixes https://github.com/llvm/llvm-project/issues/46753

Differential Revision: https://reviews.llvm.org/D155309
2023-07-16 17:24:17 +01:00
Jay Foad
c0ad1b4597 [NewGVN] Fold equivalent freeze instructions
Differential Revision: https://reviews.llvm.org/D152529
2023-06-09 20:57:36 +01:00
Jay Foad
b27b5dcc00 [NewGVN] Precommit test for folding freeze
Differential Revision: https://reviews.llvm.org/D152528
2023-06-09 20:57:36 +01:00
Jay Foad
c86a1e6903 [GVN] Do not combine convergent calls in GVN/NewGVN
Note that this is very conservative since it will not even combine
convergent calls that appear in the same basic block, but EarlyCSE will
handle that case.

Differential Revision: https://reviews.llvm.org/D150974
2023-05-19 21:27:35 +01:00
Jay Foad
41a2c66aee [GVN] Precommit tests for convergent calls in GVN/NewGVN 2023-05-19 16:39:53 +01:00
Nikita Popov
11eb8d88d8 [NewGVN] Convert tests to opaque pointers (NFC) 2023-04-21 12:43:05 +02:00
Nikita Popov
1de68667eb [NewGVN] Regenerate test checks (NFC) 2023-04-21 12:43:05 +02:00
Nikita Popov
e7f4ad13ae [Transforms] Convert some tests to opaque pointers (NFC) 2023-04-11 16:49:12 +02:00
luxufan
9630a9999b [Local] Preserve !nonnull only when K dominate J and K has a !noundef
Similar to D142687

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D146799
2023-03-26 22:25:45 +08:00
luxufan
558b33c5aa [NFC] Regenerate test NewGVN/metadata-nonnull.ll 2023-03-24 16:26:32 +08:00
luxufan
f44c7dec67 [Local] Use most generic range if K does not dominate J or K doesn't have a !noundef
Since D141386 has changed the return value of !range from IUB to poison,
metadata !range shouldn't be preserved even if K dominates J.

If this patch was accepted, I plan to adjust metadata !nonnull as well.
BTW, I found that metadata !noundef is not handled in combineMetadata,
is this intentional?

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D142687
2023-03-23 19:31:55 +08:00
Nikita Popov
1a9d49524a [GVN] Regenerate test checks (NFC) 2023-03-22 11:40:07 +01:00
Nick Desaulniers
9e9293ee6a [llvm][test] convert one test to use opaque ptrs (NFC)
Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D143682
2023-02-14 13:33:43 -08:00
Nick Desaulniers
c062e97acf [llvm][test] restrict 2 GVN tests to just test GVN (NFC)
Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D143681
2023-02-14 13:30:23 -08:00
Nikita Popov
9ed2f14c87 [AsmParser] Remove typed pointer auto-detection
IR is now always parsed in opaque pointer mode, unless
-opaque-pointers=0 is explicitly given. There is no automatic
detection of typed pointers anymore.

The -opaque-pointers=0 option is added to any remaining IR tests
that haven't been migrated yet.

Differential Revision: https://reviews.llvm.org/D141912
2023-01-18 09:58:32 +01:00
Nikita Popov
fa8448c1b1 [NewGVN] Convert some tests to opaque pointers (NFC) 2023-01-04 16:44:50 +01:00
Roman Lebedev
1010977fde
[NFC] Port all NewGVN tests to -passes= syntax 2022-12-08 02:38:49 +03:00
Arthur Eubanks
f3a928e233 [opt] Don't translate legacy -analysis flag to require<analysis>
Tests relying on this should explicitly use -passes='require<analysis>,foo'.
2022-10-07 14:54:34 -07:00
Arthur Eubanks
d3d8465446 [opt] Stop treating alias analysis specially when translating legacy opt syntax
I've attempted to keep AA tests as close to their original intent as possible.
2022-10-07 11:50:43 -07:00
Konstantina
5bc8791187 [NewGVN][PHIOFOPS] Bail out if an operand is in OpSafeForPHIOfOps but it is not safe for the current basic block.
NewGVN tables are not cleared out between the initial run of NewGVN and the verification. In case of phi-of-ops optimization, OpSafeForPHIOfOps goes out of sync between the two runs. One operand might not be safe for one basic block, but it might be safe for one of its successors. In this case, the operand will be added in OpSafeForPHIOfOps map. In verification phase, we reuse OpSafeForPHIOfOps without updating it again. As a result, the operand will be considered safe for phi-of-ops optimization even for the case that it is not. This patch fixes this problem.

Fix for 53807.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D130910
2022-08-17 18:57:46 -07:00
Augie Fackler
85063090e9 MemoryBuiltins: remove malloc-family funcs from list
We no longer need specialized knowledge of these allocator functions in
this file since we have the correct attributes available now.

As far as I can tell the changes in the attributor tests are due to
things getting more consistent on alloc-family once we remove the static
list entries.

The two test changes in NewGVN merit extra scrutiny: NewGVN appears to
be _extremely_ sensitive to the inaccessiblememonly for reasons that
are beyond me. As a result, I had-enumerated all the attributes on
allocation functions in those two tests instead of using -inferattrs.
I assumed that the two -disable-simplify-libcalls tests there no
longer are sensible since the function declaration now includes all the
relevant attributes.

Differential Revision: https://reviews.llvm.org/D130107
2022-07-25 17:29:01 -04:00
chenglin.bi
810b5c471f [NewGVN] add context instruction for SimplifyQuery
NewGVN will find operator from other context. ValueTracking currently doesn't have a way to run completely without context instruction.
So it will use operator itself as conext instruction.
If the operator in another branch will never be executed but it has an assume, it may caused value tracking use the assume to do wrong simpilfy.

It would be better to make these simplification queries not use context at all, but that would require some API changes.
For now we just use the orignial instruction as context instruction to fix the issue.

Fix #56039

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D127942
2022-06-22 12:25:24 +08:00
Nikita Popov
41d5033eb1 [IR] Enable opaque pointers by default
This enabled opaque pointers by default in LLVM. The effect of this
is twofold:

* If IR that contains *neither* explicit ptr nor %T* types is passed
  to tools, we will now use opaque pointer mode, unless
  -opaque-pointers=0 has been explicitly passed.
* Users of LLVM as a library will now default to opaque pointers.
  It is possible to opt-out by calling setOpaquePointers(false) on
  LLVMContext.

A cmake option to toggle this default will not be provided. Frontends
or other tools that want to (temporarily) keep using typed pointers
should disable opaque pointers via LLVMContext.

Differential Revision: https://reviews.llvm.org/D126689
2022-06-02 09:40:56 +02:00
Simon Pilgrim
6e078f9804 [GVN][NewGVN] Regenerate no_speculative_loads_with_asan.ll tests
As discussed on D124284 - ensure we actually checking the codegen not just a label + return
2022-04-27 10:45:39 +01:00
Jameson Nash
d25a4b5485 Enable tests from rG8e67982384d4a11892c04d16c2d10d7533e56094 that seem to work now
I noticed randomly that the only reason these tests from
rG8e67982384d4a11892c04d16c2d10d7533e56094 seemed to still be failing is
that they are missing CHECK lines. I don't know anymore than that they
don't appear to crash or assert when I ran them today.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D115377
2022-02-25 15:28:49 -05:00
Nuno Lopes
0dc20e321c [InstSimplify] fold 'xor X, poison' and 'div/rem X, poison' to poison 2022-01-30 10:46:54 +00:00
Nuno Lopes
42a761e57c [NewGVN][NFC] add poison tests 2022-01-30 10:04:00 +00:00
Nuno Lopes
f1c18acb07 [NewGVN] do phi(undef, x) -> x only if x is not poison
phi([undef, A], [x, B]) -> x is only correct x is guaranteed to be
a non-poison value.
Otherwise we would be changing an undef to poison in the branch A.

Differential Revision: https://reviews.llvm.org/D117907
2022-01-29 21:43:57 +00:00
Bjorn Pettersson
bcdcf984cc [test][NewGVN] Use '-passes=newgvn' instead of '-basic-aa -newgvn'
This updates NewGVN test cases that were running
  "opt -basic-aa -newgvn ..."
to run
  "opt -passes=newgvn ..."
instead.

The pipeline will be more similar to what we used to have with
legacy PM by doing it this way. The compatility mode that we've
been using for awhile during transition from legacy PM to new PM,
i.e. using the legacy syntax together with new PM, has resulted in
a pipeline such as
  -passes='function(require<basic-aa>),function(newgvn)'
but running the analysis in a separate function pass manager seem
overly complicated for these tests.

Another difference is that we will get the default aa-pipeline instead
of only running basic-aa. That might be a bit questioned (given that
the tests originally specified basic-aa). The output is however
identival for all the test cases modified here regardless of using
basic-aa or the default aa-pipeline.

This is also another small step towards removal of the support for
using the legacy PM syntax in opt.

Differential Revision: https://reviews.llvm.org/D118340
2022-01-28 13:58:22 +01:00
Bjorn Pettersson
4f73528403 [test][NewGVN] Use -passes=newgvn instead of -newgvn
Use the new PM syntax when specifying the pipeline in regression
tests previously running
  "opt -newgvn ..."

Instead we now do
  "opt -passes=newgvn ..."

Notice that this also changes the aa-pipeline to become the default
aa-pipeline instead of just basic-aa. Since these tests haven't been
explicitly requesting basic-aa in the past (compared to the test cases
updated in a separate patch involving "-basic-aa -newgvn") it is
assumed that the exact aa-pipeline isn't important for the validity
of the test cases. An alternative could have been to add
-aa-pipeline=basic-aa as well to the run lines, but that might just
add clutter in case the test cases do not care about the aa-pipeline.

This is another step to move away from the legacy PM syntax when
specifying passes in opt.

Differential Revision: https://reviews.llvm.org/D118341
2022-01-28 13:58:22 +01:00
Nuno Lopes
24a49e99f3 [NewGVN] FIx phi-of-ops in the presence of memory read operations
The phi-of-ops functionality has a function OpIsSafeForPHIOfOps
to determine when it's safe to create the new phi.
But this function only checks for the obvious dominator conditions
and ignores memory.
This patch takes the conservative approach and disables phi-of-ops
whenever there's a load that doesn't dominate the phi, as its
value may be affected by a store inside the loop.

This can be improved later to check aliasing between the
load/stores.

Fixes https://llvm.org/PR53277

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D117999
2022-01-26 10:19:18 +00:00
Nuno Lopes
1a5dea9e2b [NewGVN][NFC] precommit tests for PR53277 2022-01-23 19:06:21 +00:00
Nuno Lopes
7128bb61fb [NFC] Pre-commit NewGVN tests for wrong phi(undef, X) optimization 2021-12-30 15:45:20 +00:00