Commit Graph

516686 Commits

Author SHA1 Message Date
Jakub Kuderski
0f8a6b7d03 [mlir] Add fast walk-based pattern rewrite driver (#113825)
This is intended as a fast pattern rewrite driver for the cases when a
simple walk gets the job done but we would still want to implement it in
terms of rewrite patterns (that can be used with the greedy pattern
rewrite driver downstream).

The new driver is inspired by the discussion in
https://github.com/llvm/llvm-project/pull/112454 and the LLVM Dev
presentation from @matthias-springer earlier this week.

This limitation comes with some limitations:
* It does not repeat until a fixpoint or revisit ops modified in place
or newly created ops. In general, it only walks forward (in the
post-order).
* `matchAndRewrite` can only erase the matched op or its descendants.
  This is verified under expensive checks.
* It does not perform folding / DCE.
 
We could probably relax some of these in the future without sacrificing
too much performance.
2024-10-31 11:10:09 -04:00
Matt Arsenault
1d0370872f AMDGPU: Expand flat atomics that may access private memory (#109407)
If the runtime flat address resolves to a scratch address,
64-bit atomics do not work correctly. Insert a runtime address
space check (which is quite likely to be uniform) and select between
the non-atomic and real atomic cases.

Consider noalias.addrspace metadata and avoid this expansion when
possible (we also need to consider it to avoid infinitely expanding
after adding the predication code).
2024-10-31 08:08:48 -07:00
Timm Baeder
d6a0602cbb [clang] Fix an em/email typo in Maintainers.rst (#114385)
Pretty sure this was a mistake, everyone else uses "email".
2024-10-31 15:56:03 +01:00
Matt Arsenault
db5bcb24c2 GlobalISel: Fix combine duplicating atomic loads (#111730)
The sext_inreg (load) combine was not deleting the old load instruction,
and it would never be deleted if volatile or atomic.
2024-10-31 07:55:12 -07:00
Chris Apple
4ccd2b0c8f Reland "[rtsan] Intercept aligned_alloc on all versions of OSX if available on the build machine" (#114153)
This commit reverts commit 7c55426 (relands commit 97fb21ac)

With the additional step of ignoring a warning that we don't care about. (-Wunguarded-availability-new)

> We know that aligned_alloc will never be called on systems that do not have aligned_alloc defined because the client OSX won't provide it. This function is actually guarded on OS's lower than 10.15 because aligned_alloc declaration won't exist on that version. There will be no way to call this function from code.
2024-10-31 07:52:20 -07:00
Kenji Mouri / 毛利 研二
7e877fc0ac [Reland][TLI] Add support for hypot libcall. (#114343)
This patch adds basic support for `hypot`. Constant folding support will
be submitted in a subsequent patch.

Related issue: https://github.com/llvm/llvm-project/issues/113711

Note: It's my first time contributing to the LLVM with encouragement
from one of my friends, @fawdlstty. I learned a lot from
https://github.com/llvm/llvm-project/pull/99611, and thanks for that.

Note: I had created the same PR and merged
(https://github.com/llvm/llvm-project/pull/113724), but reverted caused
by the merging issue. (The CI issue happened in 3 A.M. at my timezone.
So, I need to fall asleep again after I replied about why issue
happened.) So, I rebased to the latest main branch and recreate the PR
and hope I won't have the third time to create the same PR.

I hope @arsenm can help me review the code again. I’m sorry for that.

Kenji Mouri
2024-10-31 07:50:29 -07:00
Chris Apple
880b3b26c9 [rtsan][NFC] Add 'known to have non-deterministic' caveat to documentation (#114281) 2024-10-31 07:49:59 -07:00
Ian Wood
1bc58a258e Extend getBackwardSlice to track values captured from above (#113478)
This change modifies `getBackwardSlice` to track values captures by the
regions of each operation that it traverses. Ignoring values captured
from a parent region may lead to an incomplete program slice. However,
there seems to be logic that depends on not traversing captured values,
so this change preserves the default behavior by hiding this logic
behind the `omitUsesFromAbove` flag.
2024-10-31 07:47:48 -07:00
Sander de Smalen
41448c1d07 [AArch64] NFC: Add RUN line for +sve2 for sve-intrinsics-perm-select.ll
The codegen for SVE and SVE2 may be different (e.g. for splice and ext).
A follow-up patch will improve codegen for EXT.
2024-10-31 14:46:00 +00:00
Matt Arsenault
12409024d3 AMDGPU/GlobalISel: Handle atomic sextload and zextload (#111721)
Atomic loads are handled differently from the DAG, and have separate opcodes
and explicit control over the extensions, like ordinary loads. Add
new patterns for these.

There's room for cleanup and improvement. d16 cases aren't handled.

Fixes #111645
2024-10-31 07:44:52 -07:00
Arvind Sudarsanam
eeee5a44bb [Clang][SYCL] Introduce clang-sycl-linker to link SYCL offloading device code (Part 1 of many) (#112245)
This PR is one of the many PRs in the SYCL upstreaming effort focusing
on device code linking during the SYCL offload compilation process. RFC:
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device
code linking for SYCL offload kind. It accepts SYCL device objects in
LLVM IR bitcode format and will generate a fully linked device object
that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for
objects with SYCL offload kind inside the clang-linker-wrapper. It can
also be invoked via clang driver as follows:

`clang --target=spirv64 --sycl-link input.bc`

Device code linking for SYCL offloading kind has a number of known
quirks that makes it difficult to use in a unified offloading setting.
Two of the primary issues are:
1. Several finalization steps are required to be run on the fully-linked
LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is
unique to SYCL offloading compilation flow.
2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR
code generation cannot be done as part of LTO. This limitation will be
lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform
SYCL device linking.

Co-Author: Michael Toguchi
Thanks

---------

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
2024-10-31 09:39:55 -05:00
SpencerAbson
c485ee1968 [AArch64] Add assembly/disassembly for zeroing SVE REV{B,H,W,D} and RBIT (#114110)
This patch adds assembly/disassembly for the following SVE2.2
instructions

      - RBIT (zeroing)
      - REVB (zeroing)
      - REVH (zeroing)
      - REVW (zeroing)
      - REVD (zeroing)

- In accordance with:
https://developer.arm.com/documentation/ddi0602/2024-09/SVE-Instructions

Co-authored-by: Marian Lukac marian.lukac@arm.com
2024-10-31 14:30:11 +00:00
Jannick Kremer
31faa39c92 [libclang/python/tests] Remove Python <3.6 workarounds (#114399)
This removes workarounds for Python versions before 3.6, since our
minimum Python version has been bumped to 3.8
2024-10-31 15:21:40 +01:00
Jannick Kremer
4493897499 [libclang/python/tests] Remove unused variables (#114397)
Remove all occurrences of unused varialbes in the python bindings tests.
Use `_` to ignore unused values in tuple unpacking expressions.
2024-10-31 15:20:59 +01:00
Jannick Kremer
d0ffb5369c [libclang/python] Fix incorrect assert in test (#114395)
This mistake was introduced in #109846
2024-10-31 15:20:30 +01:00
Timm Baeder
2c82079924 [clang][bytecode] Fix Pointer::toAPValue() for multidimensional arrays (#114400)
When we see an array root, that pointer might yet again be an array
element, so check for that.
2024-10-31 15:15:59 +01:00
goldsteinn
1e072ae289 [CGP] [CodeGenPrepare] Folding urem with loop invariant value plus offset (#104724)
This extends the existing fold:

```
for(i = Start; i < End; ++i)
   Rem = (i nuw+- IncrLoopInvariant) u% RemAmtLoopInvariant;
```
 ->
```
Rem = (Start nuw+- IncrLoopInvariant) % RemAmtLoopInvariant;
for(i = Start; i < End; ++i, ++rem)
   Rem = rem == RemAmtLoopInvariant ? 0 : Rem;
```

To work with a non-zero `IncrLoopInvariant`.

This is a common usage in cases such as:

```
for(i = 0; i < N; ++i)
    if ((i + 1) % X) == 0)
        do_something_occasionally_but_not_first_iter();
```

Alive2 w/ i4/unrolled 6x (needs to be ran locally due to timeout):
https://alive2.llvm.org/ce/z/6tgyN3

Exhaust proof over all uint8_t combinations in C++:
https://godbolt.org/z/WYa561388
2024-10-31 09:14:33 -05:00
Aaron Ballman
0ab44fd246 Replace documentation mentions of IRC with Discord (#114276)
This does not touch code owners or credits files that list IRC handles,
that can be done separately if we want to make that change.

See
https://discourse.llvm.org/t/rfc-remove-irc-as-a-recommended-communication-channel/82808/3
for the RFC.
2024-10-31 09:22:46 -04:00
WÁNG Xuěruì
5581e43a2b [LoongArch][NFC] Pre-commit tests for LSX/LASX bswap codegen (#114170) 2024-10-31 21:10:26 +08:00
Nathan Gauër
cf3d6fded9 [SPIR-V] Re-enable -verify-machineinstrs on tests (#114388)
Many tests had this flag removed because of the G_BITCAST emission
issue. Now that the PR is merged, we can re-enable this additional
check.

2 tests (basic_int_types) just have the TODO removed because they are
not useful for SPIR-V as-is: SPIR-V requires reg2mem/mem2reg to run,
which removes all the body. Integers are used in other spirv tests, and
seems like testing for spirv32/64 and relying on others for the logical
target coverage should be fine.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-10-31 13:55:30 +01:00
Benjamin Maxwell
89a8c71db6 [SDAG] Support expanding FSINCOS to vector library calls (#114039)
This shares most of its code with the scalar sincos expansion. It allows
expanding vector FSINCOS nodes to a library call from the specified
`-vector-library`. The upside of this is it will mean the vectorizer
only needs to handle the sincos intrinsic, which has no memory effects,
and this can handle lowering the intrinsic to a call that takes output
pointers.
2024-10-31 12:41:43 +00:00
Jan Svoboda
3f17613509 [docs] Point to Discourse for creating RFCs (#114341) 2024-10-31 05:35:57 -07:00
Hari Limaye
b396921d0c [SCCP] Handle llvm.vscale intrinsic calls (#114033)
Teach SCCP to compute a constant range for calls to llvm.vscale
intrinsics.
2024-10-31 12:22:15 +00:00
Momchil Velikov
b185e925ad [AArch64] Add assembly/disassembly for {S,U,SU,US}TMOPA instructions (#113946)
The new instructions are described in
https://developer.arm.com/documentation/ddi0602/2024-09/SME-Instructions

Co-Authored-By:  Marian Lukac <Marian.Lukac@arm.com>
2024-10-31 12:16:17 +00:00
Pengcheng Wang
18f0f70934 [RISCV] Support llvm.masked.expandload intrinsic (#101954)
We can use `viota`+`vrgather` to synthesize `vdecompress` and lower
expanding load to `vcpop`+`load`+`vdecompress`.

And if `%mask` is all ones, we can lower expanding load to a normal
unmasked load.

Fixes #101914.
2024-10-31 20:03:58 +08:00
Sergio Afonso
bd6c21460f [MLIR][OpenMP] Emit descriptive errors for all unsupported clauses (#114037)
This patch improves error reporting in the MLIR to LLVM IR translation
pass for the 'omp' dialect by emitting descriptive errors when
encountering clauses not yet supported by that pass.

Additionally, not-yet-implemented errors previously missing for some
clauses are added, to avoid silently ignoring them.

Error messages related to inlining of `omp.private` and
`omp.declare_reduction` regions have been updated to use the same
format.
2024-10-31 11:59:51 +00:00
Simon Pilgrim
fcaa8c6e22 Fix MSVC "signed/unsigned mismatch" warning. NFC. 2024-10-31 11:50:19 +00:00
Sergio Afonso
21a6032eca [MLIR][OpenMP] Simplify translation to LLVM IR error handling (#114036)
This patch unifies the handling of errors passed through the
OpenMPIRBuilder and removes some redundant error messages through the
introduction of a custom `ErrorInfo` subclass.

Additionally, the current list of operations and clauses unsupported by
the MLIR to LLVM IR translation pass is added to a new Lit test to check
they are being reported to the user.
2024-10-31 11:34:24 +00:00
Longsheng Mou
262afc8aec [mlir][TosaToLinalg] RescaleConverter only support integer type (#114239)
This PR fixes a bug in the `RescaleConverter` that allows non-integer
types, which leads to a crash.
Fixes #61383.
2024-10-31 11:32:19 +00:00
Pavel Yaskevich
d3daa3c443 [clang/AST] Make it possible to use SwiftAttr in type context (#108631)
Swift ClangImporter now supports concurrency annotations on imported
declarations and their parameters/results, to make it possible to use
imported APIs in Swift safely there has to be a way to annotate
individual parameters and result types with relevant attributes that
indicate that e.g. a block is called on a particular actor or it accepts
a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which
is a declaration attribute to `DeclOrTypeAttr`. To support this
attribute in type context we need access to its "Attribute" argument
which requires `AttributedType` to be extended to include `Attr *` when
available instead of just `attr::Kind` otherwise it won't be possible to
determine what attribute should be imported.
2024-10-31 11:15:22 +00:00
Momchil Velikov
95c5042db8 [AArch64] Add assembly/disassembly for {S,SU,US,U}MOP4{A,S} instructions (#113349)
The new instructions are described in
https://developer.arm.com/documentation/ddi0602/2024-09/SME-Instructions

Co-Authored-By:  Marian Lukac <Marian.Lukac@arm.com>
2024-10-31 11:12:14 +00:00
Nikolas Klauser
73fbae8383 [libc++][C++03] Fix libc++ includes (#109000)
This is part of the "Freezing C++03 headers" proposal explained in
https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319/58.

This patch updates the include paths used in `__cxx03/` to refer to the
`__cxx03/` headers.
2024-10-31 12:10:20 +01:00
Simon Pilgrim
92af82a48d [VectorCombine] Fold "shuffle (binop (shuffle, shuffle)), undef" --> "binop (shuffle), (shuffle)" (#114101)
Add foldPermuteOfBinops - to fold a permute (single source shuffle) through a binary op that is being fed by other shuffles.

Fixes #94546
Fixes #49736
2024-10-31 10:58:09 +00:00
Dmitry Chernenkov
d924a9ba03 Revert "[InstrPGO] Support cold function coverage instrumentation (#109837)"
This reverts commit e517cfc531.
2024-10-31 10:55:17 +00:00
Dmitry Chernenkov
06e28ed84f Revert "specify clang --target to fix breakage on AIX (#114127)"
This reverts commit cc60c46e39.
2024-10-31 10:55:17 +00:00
Sven van Haastregt
22081dc40b [SPIR-V] Add missing ScalarOpts library (#114384)
Fixes an "undefined reference to `llvm::createRegToMemWrapperPass()'"
linker error introduced by cba70550cc ("[SPIR-V] Fix BB ordering &
register lifetime (#111026)", 2024-10-30).
2024-10-31 11:50:01 +01:00
SpencerAbson
0800351da4 [AArch64][SVE] Use INS when moving elements from bottom 128b of SVE type (#114034)
Moving elements from a scalable vector to a fixed-lengh vector should
use[ INS (vector, element)
](https://developer.arm.com/documentation/100069/0606/SIMD-Vector-Instructions/INS--vector--element-)
when we know that the extracted element is in the bottom 128-bits of the
scalable vector. This avoids inserting unecessary UMOV/FMOV
instructions.
2024-10-31 10:36:00 +00:00
Fraser Cormack
86974e15f5 [libclc] Restore header order, which formatting broke 2024-10-31 10:33:47 +00:00
Fraser Cormack
fba9f05ff7 [libclc] Format clc_ldexp.cl and clc_hypot.cl. NFC 2024-10-31 10:18:29 +00:00
LLVM GN Syncbot
78a98c7aa8 [gn build] Port e67e03a22c 2024-10-31 10:11:28 +00:00
Abid Qadeer
89f2d50cda [mlir][debug] Support DIGenericSubrange. (#113441)
`DIGenericSubrange` is used when the dimensions of the arrays are
unknown at build time (e.g. assumed-rank arrays in Fortran). It has same
`lowerBound`, `upperBound`, `count` and `stride` fields as in
`DISubrange` and its translation looks quite similar as a result.

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
2024-10-31 10:09:26 +00:00
Balazs Benics
e67e03a22c [analyzer] EvalBinOpLL should return Unknown less often (#114222)
SValBuilder::getKnownValue, getMinValue, getMaxValue use
SValBuilder::simplifySVal.

simplifySVal does repeated simplification until a fixed-point is
reached. A single step is done by SimpleSValBuilder::simplifySValOnce,
using a Simplifier visitor. That will basically decompose SymSymExprs,
and apply constant folding using the constraints we have in the State.
Once it decomposes a SymSymExpr, it simplifies both sides and then uses
the SValBuilder::evalBinOp to reconstruct the same - but now simpler -
SymSymExpr, while applying some caching to remain performant.

This decomposition, and then the subsequent re-composition poses new
challenges to the SValBuilder::evalBinOp, which is built to handle
expressions coming from real C/C++ code, thus applying some implicit
assumptions.

One previous assumption was that nobody would form an expression like
"((int*)0) - q" (where q is an int pointer), because it doesn't really
makes sense to write code like that.

However, during simplification, we may end up with a call to evalBinOp
similar to this.

To me, simplifying a SymbolRef should never result in Unknown or Undef,
unless it was Unknown or Undef initially or, during simplification we
realized that it's a division by zero once we did the constant folding,
etc.

In the following case the simplified SVal should not become UnknownVal:
```c++
void top(char *p, char *q) {
  int diff = p - q; // diff: reg<p> - reg<q>
  if (!p) // p: NULL
    simplify(diff); // diff after simplification should be: 0(loc) - reg<q>
}
```

Returning Unknown from the simplifySVal can weaken analysis precision in
other places too, such as in SValBuilder::getKnownValue, getMinValue, or
getMaxValue because we call simplifySVal before doing anything else.

For nonloc::SymbolVals, this loss of precision is critical, because for
those the SymbolRef carries an accurate type of the encoded computation,
thus we should at least have a conservative upper or lower bound that we
could return from getMinValue or getMaxValue - yet we would just return
nullptr.

```c++
const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
                                                      SVal V) {
  return getConstValue(state, simplifySVal(state, V));
}

const llvm::APSInt *SimpleSValBuilder::getMinValue(ProgramStateRef state,
                                                    SVal V) {
  V = simplifySVal(state, V);

  if (const llvm::APSInt *Res = getConcreteValue(V))
    return Res;

  if (SymbolRef Sym = V.getAsSymbol())
    return state->getConstraintManager().getSymMinVal(state, Sym);

  return nullptr;
}
```

For now, I don't plan to make the simplification bullet-proof, I'm just
explaining why I made this change and what you need to look out for in
the future if you see a similar issue.

CPP-5750
2024-10-31 11:01:47 +01:00
Timm Baeder
ccb7cc319f [clang][bytecode] Diagnose negative array sizes differently (#114380)
We have a special diagnostic ID for this.
2024-10-31 10:59:53 +01:00
dnsampaio
28d0718033 [DAGCombiner] Add combine avg from shifts (#113909)
This teaches dagcombiner to fold:
`(asr (add nsw x, y), 1) -> (avgfloors x, y)`
`(lsr (add nuw x, y), 1) -> (avgflooru x, y)`

as well the combine them to a ceil variant:
`(avgfloors (add nsw x, y), 1) -> (avgceils x, y)` 
`(avgflooru (add nuw x, y), 1) -> (avgceilu x, y)`

iff valid for the target.

Removes some of the ARM MVE patterns that are now dead code.
It adds the avg opcodes to `IsQRMVEInstruction` as to preserve the
immediate splatting as before.
2024-10-31 10:57:27 +01:00
Muhammad Omair Javaid
3bc58fc7f7 [lldb][test] Fix FileActionTest.cpp for Windows (#112657)
Disable part of the test failing on windows. as O_NOCTTY and
O_RDONLY dont have same behavior on windows vs linux.
2024-10-31 14:37:32 +05:00
Stanislav Mekhanoshin
ba1a09da8d [AMDGPU] Allow overload of __builtin_amdgcn_mov_dpp8 (#113610)
The same handling as for __builtin_amdgcn_mov_dpp.
2024-10-31 02:19:20 -07:00
Timm Baeder
f0b9a0ba06 [clang][bytecode] Diagnose delete with non-virtual dtor (#114373)
... in the base class.
2024-10-31 10:13:40 +01:00
David Spickett
7557972884 [lldb][test] Fix formatting in TestInlineStepping.py
Fixes a218f0f354
2024-10-31 09:08:00 +00:00
jimingham
a218f0f354 [lldb][test] Skip one inline stepping test for arm-ubuntu. (#114295)
The test is currently passing everywhere but this 32-bit arm ubuntu bot.
I don't have an easy way to debug this, so I'm skipping the test on that
platform till we get a chance to figure this out.
2024-10-31 09:06:42 +00:00
WANG Rui
862074fa57 [LoongArch][NFC] Pre-commit tests for the adjacency of expanded pseudo-insns 2024-10-31 16:59:41 +08:00