532960 Commits

Author SHA1 Message Date
Michael Klemm
581f8bccb5
[clang][OpenMP] Fix bug #62099 - use hash value when inode ID cannot be determined (#131646)
When creating the name of an outlined region, Clang uses the file's
inode ID to generate a unique name. When the file does not exist, this
causes a fatal abort of the compiler. This PR switches to a has value
that is used instead.

---------

Co-authored-by: Michael Kruse <github@meinersbur.de>
2025-04-02 15:09:22 +02:00
Maxim Zhukov
2b7daaf967
[sanitizer][CFI] Add support to build CFI with sanitize-coverage (#131296)
Added ability to build together with -fsanitize=cfi and
-fsanitize-coverage=trace-cmp at the same time.
2025-04-02 16:05:44 +03:00
Jean-Didier PAILLEUX
c309abd925
[flang] Implement !DIR$ NOVECTOR and !DIR$ NOUNROLL[_AND_JAM] (#133885)
Hi,
This patch implements support for the following directives :
- `!DIR$ NOUNROLL_AND_JAM` to disable unrolling and jamming on a DO
LOOP.
- `!DIR$ NOUNROLL` to disable unrolling on a DO LOOP.
- `!DIR$ NOVECTOR` to disable vectorization on a DO LOOP.
2025-04-02 14:30:01 +02:00
dianqk
842785adf7
[MachineInstr] Remove the code that was accidentally added in #132536 (NFC) 2025-04-02 20:08:37 +08:00
Ryotaro Kasuga
cf976bfdeb
[LoopInterchange] Add tests for the vectorization profitability (NFC) (#133665)
There is a problem with the current profitability check for
vectorization in LoopInterchange. There are both false positives and
false negatives. The former means that the heuristic may say that "an
exchange is necessary to vectorize the innermost loop" even though it's
already possible. The latter means that the heuristic may miss a case
where an exchange is necessary to vectorize the innermost loop. Note
that this is not a dependency analysis problem. This is caused by
incorrect handling of the dependency matrix in the profitability check,
so these problems can occur even if the analysis is accurate (no
overestimation).

This patch adds tests to clarify the cases that should be fixed. The
root cause of these cases is that the heuristic doesn't handle the
direction of a dependency correctly.
2025-04-02 21:02:30 +09:00
cor3ntin
14335be078
[Clang][NFC] Minor constraint satisfaction checking cleanup (#134059)
We had a weird, incorrect, "ConstraintEvaluator" object that was not
useful for anything, so I removed that.

I also changed the CheckConstraintSatisfaction overload that just took
an Expr* as this did not make much sense at all.

Satisfaction checking is still fairly wrong,
we do not follow the standard that requires we only substitute into the
mapping of the normal form, so we produce errors for incorrect
substitution into concepts id, even though we should not.
2025-04-02 13:49:48 +02:00
Lyle Dean
a0b75b9d99
[Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (#132116)
Split diagnosing base class qualifiers from the ``-Wignored-Qualifiers``
diagnostic group into a new ``-Wignored-base-class-qualifiers``
diagnostic group (which is grouped under ``-Wignored-qualifiers``).

Fixes #131935
2025-04-02 07:31:42 -04:00
NAKAMURA Takumi
3cc7148fe0 [bazel] Update for #134043 2025-04-02 20:29:52 +09:00
Aaron Ballman
574e43dffd
[C23] Allow casting from a null pointer constant to nullptr_t (#133742)
C23 allows a cast of a null pointer constant to nullptr_t. e.g.,
(nullptr_t)0 or (nullptr_t)(void *)0.

Fixes #133644
2025-04-02 07:28:45 -04:00
Akshat Oke
7c4009f21b
[AMDGPU] AMDGPUSetWavePriority: Remove unused variable NFC (#134069)
Fixes a13a51b91fcb2797cc5a16bd8bc7ad714bb15df6 (#130064)
2025-04-02 16:52:05 +05:30
Aaron Ballman
53f3031005
[C99] Fix definitions of INTn_C macros (#133916)
C99 introduced macros of the form `INTn_C(v)` which expand to a signed
or unsigned integer constant with the specified value `v` and the type
`int_leastN_t`. Clang's initial implementation of these macros used
token pasting to form the integer constants, but this means that users
cannot define a macro named `L`, `U`, `UL`, etc before including
`<stdint.h>` (in freestanding mode, where Clang's header is being used)
because that could form invalid token pasting results. The new
definitions now use the predefined `__INTn_C` macros instead of using
token pasting. This matches the behavior of GCC.

Fixes #85995
2025-04-02 07:21:15 -04:00
Han-Kuan Chen
5bbcc765cc
[SLP][REVEC] getNumElements should not be used as VF when REVEC is enabled. (#134031) 2025-04-02 19:04:07 +08:00
Akshat Oke
a13a51b91f
[AMDGPU][NPM] Port AMDGPUSetWavePriority to NPM (#130064) 2025-04-02 16:28:05 +05:30
Pavel Labath
d7afafdbc4
[lldb] Return *const* UnwindPlan pointers from FuncUnwinders (#133247)
These plans are cached and accessed from multiple threads. Modifying
them would be a Bad Idea(tm).
2025-04-02 12:48:57 +02:00
Yingwei Zheng
f066d7504e
[Reland][SCEV] teach isImpliedViaOperations about samesign (#133711)
This patch relands https://github.com/llvm/llvm-project/pull/124270.
Closes https://github.com/llvm/llvm-project/issues/126409.

The root cause is that we incorrectly preserve the samesign flag after
truncating operands of an icmp:
https://alive2.llvm.org/ce/z/4NE9gS

---------

Co-authored-by: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
2025-04-02 18:45:33 +08:00
Kareem Ergawy
ef56b53712
[flang][OpenMP] Extend do concurrent mapping to multi-range loops (#127634)
Adds support for converting mulit-range loops to OpenMP (on the host
only for now). The changes here "prepare" a loop nest for collapsing by
sinking iteration variables to the innermost `fir.do_loop` op in the
nest.

PR stack:
- https://github.com/llvm/llvm-project/pull/126026
- https://github.com/llvm/llvm-project/pull/127595
- https://github.com/llvm/llvm-project/pull/127633
- https://github.com/llvm/llvm-project/pull/127634 (this PR)
- https://github.com/llvm/llvm-project/pull/127635
2025-04-02 12:43:04 +02:00
Longsheng Mou
7d441d9892
[mlir] Use dyn_cast instead of cast in MathToVCIX conversion (#134047)
Fixes #131093.
2025-04-02 18:30:42 +08:00
Simon Pilgrim
2426ac647f [X86] Add demanded elts for v8f32 VPERMV node
Based off #133923 - test to ensure the VPERMV node as only the lower 128-bit source elements are demanded.
2025-04-02 11:18:47 +01:00
Matt Arsenault
54385f5ebe
llvm-reduce: Increase operands-to-args test coverage (#133853)
This wasn't checking the output for all functions.
--match-full-lines is also particularly hazardous for the
interestingness checks for avoiding asserts and broken IR.

Also add tests for some of the filtered function user types.
This wasn't covered, and is overly conservative.
2025-04-02 17:02:53 +07:00
Miro Hrončok
e0f8898e1d
Avoid a race condition in opt-viewer/optrecord (#131214)
See https://bugzilla.redhat.com/2336915
See https://reviews.llvm.org/D41784?id=
See
https://github.com/androm3da/optviewer-demo/issues/4#issuecomment-718787822

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

The race condition happened when the demangler_proc was being set. The
locking mechanism itself happened too late.

This way, the lock always exists (to avoid a race when creating it) and
is always used when *creating* demangler_proc.
2025-04-02 11:52:41 +02:00
Tom Eccles
9b2fd1a6ec
[flang][OpenMP] Bump default OpenMP version to 3.1 (#133745)
Precise OpenMP standards support information is being documented in
#132707

Flang now has good support for OpenMP Version 3.1 and earlier.
2025-04-02 10:43:48 +01:00
Kareem Ergawy
3f8bfc9f7f
[flang][OpenMP] Map simple do concurrent loops to OpenMP host constructs (#127633)
Upstreams one more part of the ROCm `do concurrent` to OpenMP mapping
pass. This PR add support for converting simple loops to the equivalent
OpenMP constructs on the host: `omp parallel do`. Towards that end, we
have to collect more information about loop nests for which we add new
utils in the `looputils` name space.

PR stack:
- https://github.com/llvm/llvm-project/pull/126026
- https://github.com/llvm/llvm-project/pull/127595
- https://github.com/llvm/llvm-project/pull/127633 (this PR)
- https://github.com/llvm/llvm-project/pull/127634
- https://github.com/llvm/llvm-project/pull/127635
2025-04-02 11:26:58 +02:00
Luke Lau
8107b430ed
[VPlan] Simplify select c, x, x -> x (#133731)
As noted in 1a9358c090d0507be21c5e9b2d97a23ef1de8ab0, some
simplifications can produce a redundant select where the true and false
operands are the same, which this patch removes.

The is_fpclass test was changed so the condition wasn't made dead.
2025-04-02 10:26:48 +01:00
Fraser Cormack
dd19e7eaaa
[libclc] Move cbrt to the CLC library; vectorize (#133940) 2025-04-02 10:18:24 +01:00
Nikita Popov
9356091a98
[GlobalMerge][PPC] Don't merge globals in llvm.metadata section (#131801)
The llvm.metadata section is not emitted and has special semantics. We
should not merge globals in it, similarly to how we already skip merging
of `llvm.xyz` globals.

Fixes https://github.com/llvm/llvm-project/issues/131394.
2025-04-02 10:40:53 +02:00
Sirraide
10c6ebc427
Reapply "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (#132348)" (#134043)
This reapplies #132348 with a fix to the python bindings tests, reverting
076397ff32.
2025-04-02 10:40:05 +02:00
Kareem Ergawy
41d718b1cf
[flang][OpenMP] Upstream do concurrent loop-nest detection. (#127595)
Upstreams the next part of do concurrent to OpenMP mapping pass (from
AMD's ROCm implementation). See
https://github.com/llvm/llvm-project/pull/126026 for more context.

This PR add loop nest detection logic. This enables us to discover
muli-range do concurrent loops and then map them as "collapsed" loop
nests to OpenMP.

This is a follow up for
https://github.com/llvm/llvm-project/pull/126026, only the latest commit
is relevant.

This is a replacement for
https://github.com/llvm/llvm-project/pull/127478 using a
`/user/<username>/<branchname>` branch.

PR stack:
- https://github.com/llvm/llvm-project/pull/126026
- https://github.com/llvm/llvm-project/pull/127595 (this PR)
- https://github.com/llvm/llvm-project/pull/127633
- https://github.com/llvm/llvm-project/pull/127634
- https://github.com/llvm/llvm-project/pull/127635
2025-04-02 10:12:52 +02:00
Matt Arsenault
cde2ea377d
llvm-reduce: Defer a shouldKeep call in operand reduction (#133387)
Ideally shouldKeep is only called in contexts that will successfully
do something.
2025-04-02 15:00:41 +07:00
Harmen Stoppels
bd788dbf51
[AMDGPU] Remove detection of hip runtime for Spack (#133263)
There is special logic to detect the hip runtime when llvm is installed
with Spack. It works by matching the install prefix of llvm against
`llvm-amdgpu-*` followed by effectively globbing for

```
<llvm dir>/../hip-x.y.z-*/
```

and checking there is exactly one such directory.

I would suggest to remove autodetection for the following reasons:

1. In the Spack ecosystem it's by design that every package lives in
   its own prefix, and can only know where its dependencies are
   installed, it has no clue what its dependents are and where they are
installed. This heuristic detection breaks that invariant, since `hip`
   is a dependent of `llvm`, and can be surprising to Spack users.
2. The detection can lead to false positives, since users can be using
   an llvm installed "upstream" with their own build of hip locally, and
   they may not realize that clang is picking up upstream hip instead of
   their local copy.
3. It only works if the directory name is `llvm-amdgpu-*` which happens
   to be the name of AMD's fork of `llvm`, so it makes no sense that
   this code lives in the main LLVM repo for which the Spack package
   name is `llvm`. Feels wrong that LLVM knows about Spack package
   names, which can change over time.
4. Users can change the install directory structure, meaning that this
   detection is not robust under config changes in Spack.
2025-04-02 14:52:27 +07:00
Mariya Podchishchaeva
8a691cc615
[MS][clang] Make sure vector deleting dtor calls correct operator delete (#133950)
During additional testing I spotted that vector deleting dtor calls
operator delete, not operator delete[] when performing array deletion.
This patch fixes that.
2025-04-02 09:25:43 +02:00
Kareem Ergawy
5d364481e3
[flang][OpenMP] Upstream first part of do concurrent mapping (#126026)
This PR starts the effort to upstream AMD's internal implementation of
`do concurrent` to OpenMP mapping. This replaces #77285 since we
extended this WIP quite a bit on our fork over the past year.

An important part of this PR is a document that describes the current
status downstream, the upstreaming status, and next steps to make this
pass much more useful.

In addition to this document, this PR also contains the skeleton of the
pass (no useful transformations are done yet) and some testing for the
added command line options.

This looks like a huge PR but a lot of the added stuff is documentation.

It is also worth noting that the downstream pass has been validated on
https://github.com/BerkeleyLab/fiats. For the CPU mapping, this achived
performance speed-ups that match pure OpenMP, for GPU mapping we are
still working on extending our support for implicit memory mapping and
locality specifiers.

PR stack:
- https://github.com/llvm/llvm-project/pull/126026 (this PR)
- https://github.com/llvm/llvm-project/pull/127595
- https://github.com/llvm/llvm-project/pull/127633
- https://github.com/llvm/llvm-project/pull/127634
- https://github.com/llvm/llvm-project/pull/127635
2025-04-02 09:24:38 +02:00
nawrinsu
730e8a4a59
[OpenMP] Add memory allocation using hwloc (#132843)
This patch adds support for memory allocation using hwloc. To enable
memory allocation using hwloc, env KMP_TOPOLOGY_METHOD=hwloc needs to be
used. If hwloc is not supported/available, allocation will fallback to
default path.
2025-04-02 00:17:50 -07:00
Sudharsan Veeravalli
536fe74aaa
[RISCV] Modify register type of extd* Xqcibm instructions (#134027)
The v0.8 spec specifies that rs1 cannot be x31 (t6) since these
instructions operate on a pair of registers (rs1 and rs1 + 1) with no wrap
around.

The latest spec can be found here:
https://github.com/quic/riscv-unified-db/releases/tag/Xqci-0.8.0
2025-04-02 12:14:50 +05:30
Matt Arsenault
09e19cfacf
llvm-reduce: Do not reduce alloca array sizes to 0 (#132864)
Fixes #64340
2025-04-02 13:44:45 +07:00
Ryotaro Kasuga
528e408b94
[LoopInterchange] Add an option to control the cost heuristics applied (#133664)
LoopInterchange has several heuristic functions to determine if
exchanging two loops is profitable or not. Whether or not to use each
heuristic and the order in which to use them were fixed, but #125830
allows them to be changed internally at will. This patch adds a new
option to control them via the compiler option.

The previous patch also added an option to prioritize the vectorization
heuristic. This patch also removes it to avoid conflicts between it and
the newly introduced one, e.g., both
`-loop-interchange-prioritize-vectorization=1` and
`-loop-interchange-profitabilities='cache,vectorization'` are specified.
2025-04-02 15:41:40 +09:00
Ryotaro Kasuga
c47023dceb
[clang][CodeGen] Make pragma-loop test more rboust (NFC) (#133707)
pragma-loop.cpp contains tests for loop metadata generated by pragma
directives. These tests didn't work as (perhaps) expected. This is
because the regex `.*` consumes multiple elements in the metadata. For
example, there was a check directive like this.

```
// CHECK: ![[LOOP_9]] = distinct !{![[LOOP_9]], ![[WIDTH_8:.*]], ![[FIXED_VEC]], ...}
```

In the above case, `[[WIDTH_8]]` would have been expected to match a
node like `[[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}`.
However, since there is no check directive to verify the contents of
`[[WIDTH_8]]`, the regex `.*` consumed more than one element. There were
other similar cases.

This patch fixes the problem by not using regex matcher in the metadata
content (except for follow-up metadata). Instead, it uses string
variables whose contents are validated elsewhere.

Related:
https://github.com/llvm/llvm-project/pull/131985#discussion_r2014369699
2025-04-02 15:40:37 +09:00
Matt Arsenault
964650b69e
llvm-reduce: Add reduceOperandsToPoison reduction (#132862)
For now use it only for TargetExtTypes, which do not always support
zero initializers.
2025-04-02 13:38:46 +07:00
Sirraide
076397ff32
Revert "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics" (#134036)
Reverts llvm/llvm-project#132348

Some tests are failing and I still need to figure out what is going on
here.
2025-04-02 08:29:05 +02:00
Michael Liao
a2ca2f3f10 [CIR] Fix cir-canonicalize pass upstreaming issues. NFC
- Fix typos in 'RemoveEmptyScope' pattern rewriting and combine 'match'
  and 'rewrite' into 'matchAndRewrite' as they are deprecated.
2025-04-02 02:14:17 -04:00
Sirraide
9d06e0879b
[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (#132348)
This is a follow-up to #132129.

Currently, only `Parser` and `SemaBase` get a `DiagCompat()` helper; I’m
planning to keep refactoring compatibility warnings and add more helpers
to other classes as needed. I also refactored a single parser compat
warning just to make sure everything works properly when diagnostics
across multiple components (i.e. Sema and Parser in this case) are
involved.
2025-04-02 08:06:29 +02:00
Craig Topper
e020fc1895
[TableGen] Directly use SDNode functions to implement HasOneUse and HasNoUse. NFC (#133976)
The SDValue functions we were calling wrap SDNode functions we can call
directly.
2025-04-01 22:14:17 -07:00
Jonas Devlieghere
28b300d546
[lldb] Update ScriptInterpreterLua::LoadScriptingModule
Update the ScriptInterpreterLua::LoadScriptingModule signature after the
TargetSP argument was added in #133290.
2025-04-01 22:13:26 -07:00
Kazu Hirata
f1025c0e87
[mlir] Construct SmallVector with ArrayRef (NFC) (#134023) 2025-04-01 22:00:01 -07:00
Kazu Hirata
d760dbe6eb
[mlir] Remove extraneous calls to make_range (NFC) (#134020) 2025-04-01 21:59:51 -07:00
Kazu Hirata
86c382514e
[Target] Construct SmallVector with ArrayRef (NFC) (#134019) 2025-04-01 21:59:19 -07:00
Kazu Hirata
cc10896fa2
[SandboxVectorizer] Use llvm::erase (NFC) (#134018) 2025-04-01 21:58:57 -07:00
Kazu Hirata
e060acbd3b
[Sema] Use llvm::erase_if (NFC) (#134017) 2025-04-01 21:58:32 -07:00
Kazu Hirata
68fb7a5a1d Revert "[RISCV] Add Xqci Insn Formats (#132986)"
This reverts commit 0cfabd37df9940346f3bf8a4d74c19e1f48a00e9.

Multiple builtbot failures have been reported:
https://github.com/llvm/llvm-project/pull/132986
2025-04-01 21:51:54 -07:00
Matt Arsenault
23d894e0a3 llvm-reduce: Fix comment typo 2025-04-02 11:43:09 +07:00
Matt Arsenault
adbe9e20bf
llvm-reduce: Skip setting br conditions on already constant branches (#133841)
If we are trying to simplify branch conditions to true, ignore branches
already set to a constant true. If we are simplifying to constant false,
ignore the already constant false cases. This saves steps in this edge
case, and avoids the side effect of running simplifycfg on blocks we
did not intend to modify.
2025-04-02 11:41:47 +07:00