534051 Commits

Author SHA1 Message Date
Prabhu Rajasekaran
04b6f541b7
[NFC][llvm] Create UEFI helper function (#132462)
Create useful helper functions for UEFI 64 bit target that can be used in
tablegen files in future changes.
2025-04-14 09:15:51 -07:00
Andre Kuhlenschmidt
2e353a635b
[flang][openacc] Relax constraint on OpenACC declare statement (#135238)
OpenACC declare statements are restricted from having having clauses
that reference assumed size arrays. It should be the case that we can
implement `deviceptr` and `present` clauses for assumed-size arrays.
This is a first step towards relaxing this restriction.

Note running flang on the following example results in an error in
lowering.
```
$ cat t.f90
subroutine vadd (a, b, c, n)
   real(8) :: a(*), b(*), c(*)
!$acc declare deviceptr(a, b, c)
!$acc parallel loop
   do i = 1,n
      c(i) = a(i) + b(i)
   enddo
end subroutine

$ flang -fopenacc -c t.f90
error: loc("/home/akuhlenschmi/work/p4/ta/tests/openacc/src/t.f90":3:7): expect declare attribute on variable in declare operation
error: Lowering to LLVM IR failed
error: loc("/home/akuhlenschmi/work/p4/ta/tests/openacc/src/t.f90":4:7): unsupported OpenACC operation: acc.private.recipe
error: loc("/home/akuhlenschmi/work/p4/ta/tests/openacc/src/t.f90":4:7): LLVM Translation failed for operation: acc.private.recipe
error: failed to create the LLVM module
```

I would like to to share this code, because others are currently working
on the implementation of `deviceptr`, but it is obviously not running
end-to-end. I think the cleanest approach to this would be to put this
exception to the rule behind some feature flag, but I am not certain
what the precedence for that is.
2025-04-14 09:08:21 -07:00
Camsyn
71d10590db
[CaptureTracking][NFC] Clarify usage expectations in PointerMayBeCaptured comments (#132744)
Fixes issue #132739.

CaptureAnalysis only considers captures through the def-use chain of the
provided pointer, explicitly excluding captures of underlying values or
implicit captures like those involving external globals.

The previous comment for `PointerMayBeCaptured` did not clearly state
this limitation, leading to its incorrect usage in files such as
ThreadSanitizer.cpp and SanitizerMetadata.cpp.

This PR addresses this by refining the comments for the relevant APIs
within `PointerMayBeCaptured` to explicitly document this behavior.
2025-04-14 18:06:33 +02:00
Rahul Joshi
8ede3dd8a1
[NFC][MC] Use StringRef for Modifier in Inst/Asm Printers (#135403)
- Change various Inst/Asm Printer functions to use a StringRef for the
Modifier parameter (instead of a const char *).
- This simplifies various string comparisons used within these
functions.
- Remove these params for print functions that do not use them.
2025-04-14 09:02:49 -07:00
Peter Klausler
9f7aac177c
[flang] Allow host-associated INTENT(OUT) in specification expr. (#135426)
Nearly, but not all, other compilers have a blanket prohibition against
the use of an INTENT(OUT) dummy argument in a specification expression.
Some compilers, however, permit an INTENT(OUT) dummy argument to appear
in a specification expression in a BLOCK construct or inner procedure
via host association.

The argument some have put forth to accept this usage comes from a
reading of 10.1.11 (specification expressions) in Fortran 2023 that, if
followed consistently, would also require host-associated OPTIONAL dummy
argument to be allowed. That would be dangerous for reasons that should
be obvious.

However, I can agree that a non-OPTIONAL dummy argument can't be assumed
to remain undefined on entry to a BLOCK construct or inner procedure, so
we can accept host-associated INTENT(OUT) in specification expressions
with a portability warning.
2025-04-14 09:00:12 -07:00
Peter Klausler
882200684b
[flang][OpenMP] Prescanning bug with !$ fixed form line continuation (#135416)
The logic for fixed form compiler directive line continuation has a hole
that can apply continuation for !$ even if the next line does not begin
with a fixed form comment character. Rearrange the nested if statements
to enforce that requirement for all compiler directives.
2025-04-14 08:59:52 -07:00
Matheus Izvekov
13b55ad3bb
[clang] implement printing of canonical expressions (#135133)
This patch extends the canonicalization printing policy to cover
expressions
and template names, and wires that up to the template argument printer,
covering expressions, and to the expression within a dependent decltype.

This is helpful for debugging, or if these expressions somehow end up
in diagnostics, as without this patch they can print as completely
unrelated
expressions, which can be quite confusing.

This is because expressions are not uniqued, unlike types, and
when a template specialization containing an expression is the first to
be
canonicalized, the expression ends up appearing in the canonical type of
subsequent equivalent specializations.

Fixes https://github.com/llvm/llvm-project/issues/92292
2025-04-14 12:59:36 -03:00
Peter Klausler
dba757a33c
[flang] Rework preprocessor fix for replacement in kind suffixes (#135406)
Recent work to better handle macro replacement in literal constant kind
suffixes isn't handling fixed form well, leading to a crash in Fujitsu
test 0113/0113_0073.F. The look-ahead needs to be done with the
higher-level prescanner functions that skip over fixed form comment
fields after column 72. Rework.
2025-04-14 08:59:28 -07:00
Peter Klausler
da6f493d4a
[flang][NFC] Update module file documentation (#135107)
The current module file documentation antedates the current
implementation of module files and contains many aspirational and
conditional statements, all of which can now be resolved with
descriptions of how things actually work.
2025-04-14 08:59:07 -07:00
Shilei Tian
fcf0f810ac
[Clang][AMDGPU] Enable avail-extern-to-local for ThinLTO in HIP (#134476)
In HIP, the Clang driver already sets `force-import-all` when ThinLTO is
enabled. As a result, all imported functions get the
`available_externally`
linkage. However, these functions are later removed by the
`EliminateAvailableExternallyPass`, effectively undoing the forced
import and
eventually leading to link errors.

The `EliminateAvailableExternallyPass` provides an option to convert
`available_externally` functions into local functions, renaming them to
avoid
conflicts. This behavior is exactly what we need for HIP. This PR
enables that
option (`avail-extern-to-local`) alongside `force-import-all` when
ThinLTO is
used.

With this change, ThinLTO almost works correctly on AMDGPU. The only
remaining
issue is an undefined reference to `__assert_fail`, but that falls
outside the
scope of this PR.
2025-04-14 11:52:19 -04:00
LLVM GN Syncbot
b04045cc41 [gn build] Port 2d30a60e9ff8 2025-04-14 15:31:59 +00:00
John Harrison
2d30a60e9f
[lldb-dap] Adding support for cancelling a request. (#130169)
Adding support for cancelling requests.

There are two forms of request cancellation.

* Preemptively cancelling a request that is in the queue.
* Actively cancelling the in progress request as a best effort attempt
using `SBDebugger.RequestInterrupt()`.
2025-04-14 08:29:02 -07:00
Nikita Popov
44e32a263a [Verifier] Fix intrinsic signatures in immarg tests (NFC) 2025-04-14 17:24:50 +02:00
Akshat Oke
f133eae70c
[CodeGen][NPM] Port MachineSanitizerBinaryMetadata to NPM (#130069)
Didn't find a test for this (but there are tests for the `Function`
version of this pass)
2025-04-14 20:52:26 +05:30
agozillon
b2c9a58b8f
[Flang][OpenMP][MLIR] Check for presence of Box type before emitting store in MapInfoFinalization pass (#135477)
Currently we don't check for the presence of descriptor/BoxTypes before
emitting stores which lower to memcpys, the issue with this is that
users can have optional arguments, where they don't provide an input,
making the argument effectively null. This can still be mapped and this
causes issues at the moment as we'll emit a memcpy for function
arguments to store to a local variable for certain edge cases, when we
perform this memcpy on a null input, we cause a segfault at runtime.

The fix to this is to simply create a branch around the store that
checks if the data we're copying from is actually present. If it is, we
proceed with the store, if it isn't we skip it.
2025-04-14 17:15:56 +02:00
Björn Pettersson
092b6e73e6
[InstCombine] Handle "add like" in ADD+GEP->GEP+GEP rewrites (#135156)
Considering that "or disjoint" is the canonical for certain add
operations, then I think we want to support such "add like" operations
when doing ADD+GEP->GEP+GEP rewrites to make things more consistent.

Problem was found when improving ValueTracking, which turned an ADD into
OR, and then suddenly optimizations got worse due to these rewrites no
longer triggering.
2025-04-14 17:11:13 +02:00
Michał Górny
a485abbddd
[flang] Fix Driver/do_concurrent_to_omp_cli.f90 test not to use runtime (#135485)
Fix Flang invocation in `Driver/do_concurrent_to_omp_cli.f90` test to
run compilation step only, to fix testing when building with
`-DFLANG_INCLUDE_RUNTIME=OFF`. The test is only concerned with warning
being emitted by the compiler, so there is no need to link the resulting
executable.
2025-04-14 16:56:49 +02:00
Matheus Izvekov
40727bca9f
[clang] remove unused frontend flag -fretain-subst-template-type-parm-type-ast-nodes (#134177)
This is a follow-up to #132748, where we deferred the flag removal in
order to ease transition for external users.

The plan is to merge this in the nearish future, in two weeks or so is
my best guess.
2025-04-14 11:54:13 -03:00
Aiden Grossman
dbeb7c1bbb
[Github][CI] Upload .ninja_log as an artifact
This enables using tools like https://github.com/nico/ninjatracing for
performance introspection.

Reviewers: mizvekov, lnihlen, tstellar, Endilll, Keenuts

Reviewed By: Keenuts

Pull Request: https://github.com/llvm/llvm-project/pull/135539
2025-04-14 16:28:50 +02:00
SivanShani-Arm
bcbdbd25c0
[llvm][ELF][build attributes] Change StringRef to std::string for BuildAttributeSubSection::Name (#135625)
BuildAttributeSubSection::Name must be a std::string instead of
StringRef because it may be assigned from non-persistent memory.
StringRef is non-owning and unsafe in this context. This change ensures
the subsection name owns its memory, preventing use-after-free or
dangling references.

Context: Work in progress in PR #131990.
2025-04-14 14:59:24 +01:00
Michael Maitland
74e8f29f31
[RegAlloc] Sort CopyHint by IsCSR (#131046)
`weightCalcHelper` is responsible for adding hints to MRI. Prior to this
PR, we fell back on register ID as the last tie breaker for sorting
hints. However, there is an opportunity to add an additional sorting
characteristic: whether or not a register is a callee-saved-register.

I thought of this idea because I saw that `AllocationOrder::create`
calls `RegisterClassInfo::getOrder`, which returns a list of registers
such that the registers which alias callee-saved-registers come last.
From this, I conclude that the register allocator prefers an order such
that callee-saved-registers are allocated after
non-callee-saved-registers to avoid having to spill the CSR.

This sorting characteristic occurs only as a tie breaker to the Weight
calculation. This is a good idea since the weight calculation is pretty
complex and I'm sure it is a pretty stable metric. I think its pretty
reasonable to agree that whether a register is callee-saved or not is a
better tie breaker than register ID. I think this is evident by the test
diff, since the changes all seem to have no impact or improve the
register allocation.
2025-04-14 09:58:46 -04:00
Lukacma
efe9cb0f79
[AArch64] Model ZA array using inaccessible memory (#132058)
This patch changes how ZA array is modelled at LLVM-IR level. Currently
accesses to ZA are represented at LLVM-IR level as memory reads and
writes and at instruction level as unmodeled side-effects. This patch
changes that and models them as purely Inaccessible memory accesses
without any unmodeled side-effects.
2025-04-14 14:55:06 +01:00
Matheus Izvekov
10a1502421
[clang] AST: remove source locations from [Variable/Dependent]SizedArrayType (#135511) 2025-04-14 10:44:25 -03:00
Fraser Cormack
4cb1803ff9 [libclc][NFC] Fix typo in comment 2025-04-14 14:38:58 +01:00
SivanShani-Arm
4eaf3a7596
[readobj][ELF][AArch64] Handle misformed AArch64 build attribute section (#134888)
Report an error when the .ARM.attributes section for AArch64 is
malformed or violates expected format.
2025-04-14 14:23:00 +01:00
Wenju He
0c21d6b4c8
[libclc] Fix commands in compile_to_bc are executed sequentially (#130755)
In libclc, we observe that compiling OpenCL source files to bitcode is
executed sequentially on Windows, which increases debug build time by
about an hour.
add_custom_command may introduce additional implicit dependencies, see
https://gitlab.kitware.com/cmake/cmake/-/issues/17097
This PR adds a target for each command, enabling parallel builds of
OpenCL source files.
CMake 3.27 has fixed above issue with DEPENDS_EXPLICIT_ONLY. When LLVM
upgrades cmake vertion to 3.7, we can switch to DEPENDS_EXPLICIT_ONLY.
2025-04-14 14:11:04 +01:00
Jakub Kuderski
0078cf79ad
[mlir] Remove deprecated cast member functions (#135556)
These have been deprecated for over two years now in favor of free
functions.

See the relevant discourse thread:

https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
and the deprecation notice: https://mlir.llvm.org/deprecation/.
2025-04-14 09:08:34 -04:00
Michael Buch
cbbf562d1c [lldb][Format][NFC] Remove unused FormatEntity::FormatCString
One can use `FormatStringRef` instead anyway
2025-04-14 13:42:35 +01:00
Mariya Podchishchaeva
88d0b0835d
[MS][clang] Revert vector deleting destructors support (#135611)
Finding operator delete[] is still problematic, without it the extension
is a security hazard, so reverting until the problem with operator
delete[] is figured out.

This reverts the following PRs:
Reland [MS][clang] Add support for vector deleting destructors (llvm#133451)
[MS][clang] Make sure vector deleting dtor calls correct operator delete (llvm#133950)
[MS][clang] Fix crash on deletion of array of pointers (llvm#134088)
[clang] Do not diagnose unused deleted operator delete[] (llvm#134357)
[MS][clang] Error about ambiguous operator delete[] only when required (llvm#135041)
2025-04-14 14:17:36 +02:00
Iris
fe54d1afcc
[ConstraintElim] Simplify cmp after uadd.sat/usub.sat (#135603)
- Closes #135557
2025-04-14 20:15:55 +08:00
dlav-sc
14cb8c56b2
[lldb] add required for lldb RISCV relocations in MCJIT (#126266)
After implementing CFI instructions in the function prologue, LLDB
testing for RISC-V started failing due to insufficient relocations
(e.g., R_RISCV_SET8, R_RISCV_SET16).

This patch adds support for the necessary RISC-V relocations in MCJIT.
2025-04-14 15:15:33 +03:00
Aaron Puchert
1c04ebbbb5
Remove debugger pretty printers for llvm::Optional (#135235)
Since 2916b99182752b1aece8cc4479d8d6a20b5e02da this is just an alias to
std::optional, and by now it has been removed entirely.
2025-04-14 14:11:55 +02:00
Pengcheng Wang
e8e98683d7
[RISCV][NFC] Use bitmasks generated by TableGen
So that we don't need to sync-up the table manually.

Reviewers: BeMg, preames, lenary

Reviewed By: BeMg

Pull Request: https://github.com/llvm/llvm-project/pull/135600
2025-04-14 19:32:13 +08:00
Han-Kuan Chen
123993fd97
[SLP] Make getSameOpcode support interchangeable instructions. (#133888)
We use the term "interchangeable instructions" to refer to different
operators that have the same meaning (e.g., `add x, 0` is equivalent to
`mul x, 1`).
Non-constant values are not supported, as they may incur high costs with
little benefit.

---------

Co-authored-by: Alexey Bataev <a.bataev@gmx.com>
2025-04-14 19:23:18 +08:00
Pengcheng Wang
90c01f4bad
[RISCV] Add missing bitmask for some extensions (#135599)
According to:
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/main/src/c-api.adoc#extension-bitmask-definitions

And we sort the bitmask by group id and then bit position.
2025-04-14 19:18:38 +08:00
Dmitry Vasilyev
e4a672bc17
[LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (#135033)
The original PR is #132274.

Co-authored-by: @bulbazord Alex Langford
2025-04-14 14:30:09 +04:00
Nikita Popov
1e2dc5b087 [SROA] Add load-only promotion tests with dynamic offset load 2025-04-14 12:16:06 +02:00
Nikita Popov
a9474191e0
[SROA] Improve handling of lifetimes in load-only promotion (#135382)
The propagateStoredValuesToLoads() transform currently bails out if
there is a lifetime intrinsic spanning the whole alloca, but the
individual loads/stores operate on some smaller part, because the slice
/ partition size does not match.
    
Fix this by ignoring assume-like slices early, regardless of which range
they cover.
    
I've changed the overall code structure here a bit because I was getting
confused by the different iterators.
2025-04-14 11:52:42 +02:00
Pierre van Houtryve
c9eebc7af4
[GlobalISel] Combine redundant sext_inreg (#131624) 2025-04-14 11:48:08 +02:00
Tom Eccles
77341388a7
[mlir][OpenMP] allow cancellation to not be directly nested (#134084)
omp.cancel and omp.cancellationpoint contain an attribute describing the
type of parent construct which should be cancelled. e.g.
```
!$omp cancel do
```
Must be inside of a wsloop. Previously the verifer required the
immediate parent to be this operation. This is not quite right because
something like the following is valid:
```
!$omp parallel do
do i = 1, N
  if (cond) then
    !$omp cancel do
  endif
enddo
```

This patch relaxes the verifier to only require that some parent
operation matches (not necessarily the immediate parent).
2025-04-14 10:39:03 +01:00
Wenju He
cbda72a547
[NFC][libclc] Merge atomic extension built-ins with identical name into a single file (#134489)
llvm-diff shows there is no change to amdgcn--amdhsa.bc.

Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a
same file for math built-ins, this PR do the same to atom_* built-ins.

The main motivation is to prevent that two files with same base name
implementats different built-ins. In a follow-up PR, I'd like to relax
libclc_configure_lib_source to only compare filename instead of path for
overriding, since in our downstream the same category of built-ins, e.g.
math, are organized in several different folders.
2025-04-14 10:27:48 +01:00
Yingwei Zheng
dffef041d5
[IR][ADT] Remove APFloat/Type::isIEEE (#130496)
Address comment
https://github.com/llvm/llvm-project/pull/130477#issuecomment-2708801892.
2025-04-14 17:03:39 +08:00
Björn Pettersson
29555ad5ef
[InstCombine] Improve inbounds preservation for ADD+GEP -> GEP+GEP (#135155)
Given that we have a "add nuw" and a "getelementptr inbounds nuw" like
this:
   %idx = add nuw i64 %idx1, %idx2
   %gep = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx

Then we can preserve the "inbounds nuw" flag when transforming that into
two getelementptr instructions:
   %gep1 = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx1
   %gep = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx2

Similarly for just having "nuw", and "nusw nuw" instead of "inbounds nuw"
on the getelementptr.

Proof: https://alive2.llvm.org/ce/z/QSweWW
2025-04-14 11:03:06 +02:00
Pengcheng Wang
bcd7f54d34 [mailmap] Update my name 2025-04-14 16:54:14 +08:00
Thomas Preud'homme
95d526f7f5
[MLIR][Tosa] Fix argmax NaN propagate lowering (#133074)
In the propagate mode, NaN compare equal to each other so in case of
several NaNs the index of the first one needs to be returned. This
commit changes the index update condition to check that the current
index is not that of a NaN.

The commit also simplifies argmax NaN ignore lowering to only use OGT.
This prevent any update in case of NaN. The only case where the index of
a NaN is returned is when all values are NaN and this is covered by the
fact that the initial index value is 0 so no update will result in 0
being returned.
2025-04-14 09:37:09 +01:00
Pierre van Houtryve
931a78a1db
[AMDGPU] Add sext_trunc in RegBankCombiner (#131623) 2025-04-14 10:15:29 +02:00
Jonas Devlieghere
73b554d7a0
[lldb] Make sure the process is stopped when computing the symbol context (#135458)
Make sure the process is stopped when computing the symbol context. Both
Adrian and Felipe reported a handful of crashes in GetSymbolContext
called from Statusline::Redraw on the default event thread.

Given that we're handling a StackFrameSP, it's not clear to me how that
could have gotten invalidated, but Jim points out that it doesn't make
sense to compute the symbol context for the frame when the process isn't
stopped.

Depends on  #135455
2025-04-14 10:09:43 +02:00
Jonas Devlieghere
d792094c26
[lldb] Remove ProcessRunLock::TrySetRunning (#135455)
I traced the issue reported by Caroline and Pavel in #134757 back to the
call to ProcessRunLock::TrySetRunning. When that fails, we get a
somewhat misleading error message:

> process resume at entry point failed: Resume request failed - process
still running.

This is incorrect: the problem was not that the process was in a running
state, but rather that the RunLock was being held by another thread
(i.e. the Statusline). TrySetRunning would return false in both cases
and the call site only accounted for the former.

Besides the odd semantics, the current implementation is inherently
race-y and I believe incorrect. If someone is holding the RunLock, the
resume call should block, rather than give up, and with the lock held,
switch the running state and report the old running state.

This patch removes ProcessRunLock::TrySetRunning and updates all callers
to use ProcessRunLock::SetRunning instead. To support that,
ProcessRunLock::SetRunning (and ProcessRunLock::SetStopped, for
consistency) now report whether the process was stopped or running
respectively. Previously, both methods returned true unconditionally.

The old code has been around pretty much pretty much forever, there's
nothing in the git history to indicate that this was done purposely to
solve a particular issue. I've tested this on both Linux and macOS and
confirmed that this solves the statusline issue.

A big thank you to Jim for reviewing my proposed solution offline and
trying to poke holes in it.
2025-04-14 10:09:19 +02:00
Kazu Hirata
ebd1667059
[CodeGen] Avoid repeated hash lookups (NFC) (#135584) 2025-04-14 01:03:06 -07:00
Aiden Grossman
97bc9137e5
[Github][CI] Upload artifacts directory for premerge workflow
The premerge pipeline currently creates an artifacts directory with some
statistics that gets uploaded on the buildkite side for later
inspection. This patch adds support for this on the Github side by using
the upload artifacts action.

Reviewers: Keenuts, lnihlen, mizvekov, tstellar, Endilll

Reviewed By: mizvekov

Pull Request: https://github.com/llvm/llvm-project/pull/135538
2025-04-14 09:37:47 +02:00