533359 Commits

Author SHA1 Message Date
Akshat Oke
fcaefc2c19
[AMDGPU][NPM] Port SIPreEmitPeephole to NPM (#130065) 2025-04-08 17:58:48 +05:30
Joseph Huber
79cb6f05da
[Clang] Unify 'nvptx-arch' and 'amdgpu-arch' into 'offload-arch' (#134713)
Summary:
These two tools do the same thing, we should unify them into a single
tool. We create symlinks for backward compatiblity and provide a way to
get the old vendor specific behavior with `--amdgpu-only` and
`--nvptx-only`.
2025-04-08 07:27:12 -05:00
David Spickett
db7fb704f6 [lldb][test] Explain why TestExprFromNonZeroFrame is disabled on Windows
It's not scientific but I think the PDB we produce on the Windows on Arm
bot simply doesn't have the information needed. Could also be that clang
is producing some DWARF, but link.exe is dropping it from the final executable,
the effect is the same.
2025-04-08 12:17:07 +00:00
Kajetan Puchalski
25e08c0b9c
Revert "[CMake] Fix using precompiled headers with ccache" (#134848)
Reverts llvm/llvm-project#131397

Reverting for now on account of build bot failures on certain platforms.
2025-04-08 13:13:49 +01:00
Florian Hahn
a51e282784
[LV] Check if plan has an early exit via plan's exit blocks. (NFC) (#134720)
Add a dedicated function to check if a plan is for a loop with an early
exit. This can easily be determined by checking the exit blocks.

This allows removing a use of Legal->hasUncountableEarlyExit() from
InnerLoopVectorizer.

PR: https://github.com/llvm/llvm-project/pull/134720
2025-04-08 12:52:38 +01:00
Michael Klemm
69c4e172d9
[Flang][OpenMP] Add semantic tests for threadprivate variables with host assoc (#134680) 2025-04-08 13:22:05 +02:00
Omair Javaid
c2c1031e90
[Flang][Windows] Fix test_errors.py by enforcing UTF-8 encoding (#134625)
This patch fixes UnicodeDecodeError on Windows in test_errors.py. This
issue was observed on the flang-arm64-windows-msvc buildbot.
Semantics/OpenMP/interop-construct.f90 was crashing due to Python
defaulting to the cp1252 codec on Windows.

I have fixed this by explicitly setting encoding="utf-8" when reading
source files and invoking subprocess.run() in test_errors.py

flang-arm64-windows-msvc was running on stagging master which resulted
in this issue not being fixed earlier.
https://lab.llvm.org/staging/#/builders/206
2025-04-08 16:16:26 +05:00
Kajetan Puchalski
e8dc8add3c
[CMake] Fix using precompiled headers with ccache (#131397)
Using precompiled headers with ccache requires special accommodations.
Add the required ccache options, clang and gcc compiler flags to CMake.
Refactor ccache configuration to pass options directly on the command line for versions of ccache that support it.

---------

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2025-04-08 12:09:52 +01:00
Paul Walker
e06a9ca2cb
[LLVM][CodeGen][SVE] Improve lowering of fixed length masked mem ops. (#134402)
Converting fixed length masks, as used by MLOAD, to scalable vectors is
done by comparing the mask to zero. When the mask is the result of a
compare we can instead promote the operands and regenerate the original
compare. At worst this reduces the dependecy chain and in most cases
removes the need for multiple compares.
2025-04-08 12:09:10 +01:00
Nikolas Klauser
483edfeeb5
[libc++] Use __add_pointer and __remove_pointer builtins when they are fixed (#134147) 2025-04-08 13:05:24 +02:00
Nathan Gauër
739062d2c3
[SPIR-V] Add spv.gep support for ptrcast legal (#134388)
Adds support the the spv.gep intrinsic to the spv ptrcast legalization
step. Those intrinsics are generated by the backend thus not directly
visible in the tests.
This is a pre-requisite to implement addrspacecast legalization for
logical SPIR-V.
2025-04-08 12:55:37 +02:00
Jonathan Thackray
204d8c0d58
[clang][llvm] Fix AArch64 MOP4{A/S} intrinsic tests (NFC) (#134746)
Fix some of the recently-added tests (PRs #127797, #128854, #129226 and
#129230) which were incorrectly defined.
2025-04-08 11:45:47 +01:00
Simon Tatham
7af2b51e76
[AArch64][v8.5A] Omit BTI for non-addr-taken static fns on Linux (#134669)
This is a conditional revert of cca40aa8d8aa732, which made LLVM's
branch-target-enforcement mode generate BTI at the start of _every_
function, even in the case where the function has internal linkage and
its address is never taken for use in an indirect call.

The rationale was that it might turn out at link time that a direct call
to the function spanned a larger distance than the range of a BL
instruction (say, if the translation unit generated multiple code
sections and the linker put them a very long way apart). Then the linker
might insert a long-branch thunk using an indirect call instruction.

SYSVABI64 has now clarified that in this situation the static linker may
not assume that the target function is safe to call directly. If it
needs to use this strategy, it's responsible for also generating a
'landing pad' near the target function, with a BTI followed by a direct
branch, and using that as the target of the long-distance indirect call.

606ce44fe4

LLD complies with this spec as of commit 098b0d18add97de.

So if we're compiling in a mode that respects SYSVABI64, such as
targeting Linux, it's safe to leave out the BTI at the start of a
function with internal linkage if we can prove that its address isn't
either used in an indirect call in _this_ translation unit or passed out
of the object.

Therefore, this patch goes back to the behavior before cca40aa8d8aa732,
leaving out BTIs in functions that can't be called indirectly, but only
if the target triple is Linux. (I wasn't able to find a more precise
query for "is this a SYSVABI64-compliant platform?", but Linux certainly
is, and this check at least fails in the safe direction - if in doubt,
we put in all the BTIs that might be necessary.)
2025-04-08 11:44:12 +01:00
Paul Walker
1997073a54
[LLVM][InstCombine][SVE] Refactor sve.mul/fmul combines. (#134116)
After https://github.com/llvm/llvm-project/issues/126928 it's now
possible to rewrite the existing combines, which mostly only handle
cases where a operand is an identity value, to use existing simplify
code to unlock general constant folding.
2025-04-08 11:38:27 +01:00
Simon Pilgrim
83fbe67986
[X86] combineX86ShufflesRecursively - iteratively peek through bitcasts to free subvector widening/narrowing sources. (#134701)
Generalizes the existing code to repeatedly peek though mixed bitcast/insert_subvector/extract_subvector chains to find the source of the shuffle operand.
2025-04-08 11:28:40 +01:00
Anatoly Trosinenko
8521bd2424
[BOLT][AArch64] Handle PAuth call instructions in isIndirectCall (#133227)
Handle `BLRA*` opcodes in AArch64MCPlusBuilder::isIndirectCall, update
getRegUsedAsCallDest accordingly.
2025-04-08 13:23:10 +03:00
MisakaVan
ff5b649a84
[libc++] Fix a comment typo in __tree (#134831)
"Returns true **is** __root is a proper red black tree"
->
"Returns true **if** __root is a proper red black tree"
2025-04-08 12:17:43 +02:00
Ramkumar Ramachandra
6a42fb8fbf
[LV] Clarify code in isPredicatedInst (NFC) (#134251) 2025-04-08 10:46:17 +01:00
Jay Foad
6f93c0676f
[AMDGPU] Make a few WaitcntBrackets methods const. NFC. (#134824) 2025-04-08 10:44:02 +01:00
Jakub Ficek
a5509d62a7
[clang] fp options fix for __builtin_convertvector (#134102)
Add missing CGFPOptionsRAII for fptoi and itofp cases
2025-04-08 11:36:48 +02:00
Tom Eccles
4c09ae0b2e
[flang][OpenMP] Lowering for CANCEL and CANCELLATIONPOINT (#134248)
These will still hit TODOs in OpenMPToLLVMIRConversion.cpp
2025-04-08 10:29:18 +01:00
Tom Eccles
446d4f51eb
[flang][OpenMP][Lower] fix statement context cleanup insertion point (#133891)
The statement context is used for lowering clauses for openmp operations
using generalised helpers from flang lowering. The statement context
stores closures which generate code for cleaning up temporary values
generated by the lowering helper. These closures are run when the
statement construct is destroyed. Keeping the statement context local to
the clause or operation being lowered without any special handling was
not correct because any cleanup code would be generated at the insertion
point when that statement context went out of scope (which would in
general be inside of the newly created container operation). It would be
better to generate the cleanup code after the newly created operation
(clause processing is synchronous even for deferred tasks).

Currently supported clauses are mostly populated with simple scalar
values that require no cleanup. Even the simple array sections added by
#132994 needed no cleanup because indexing the right values of the array
did not create any temporaries. Supporting array sections with vector
indexing will generate hlfir.destroy operations for cleanup. This patch
fixes where those will be created. Those hlfir.destroy operations don't
generate any FIR (or LLVM) code, but the issue still exists
theoretically.

I wasn't able to find any clauses which have any cleanup to use to test
this PR. It is probably NFC for the current lowering. This will be
tested in [the PR adding vector subscripting of array
sections](https://github.com/llvm/llvm-project/pull/133892).
2025-04-08 10:27:27 +01:00
Nathan Gauër
fe4f666363
[CI] Always upload queue/running count (#134814)
Before this commit, we only pushed a queue/running count when the value
was not zero. This makes building Grafana alerting a bit harder.
Changing this to always upload a value for watched workflows.
2025-04-08 11:16:24 +02:00
David Green
c23e1cb936
[BasicAA] Treat ExtractValue(Argument) similar to Argument in relation to function-local objects. (#134716)
This is a much smaller, technically orthogonal patch similar to #134505. It
states that a extractvalue(Argument) can be treated like an Argument for alias
analysis, where the extractelement acts like a phi / copy. No inttoptr here.
2025-04-08 10:05:58 +01:00
David Green
9d82ab8a82 [BasicAA] Add some test cases for coerced function args 2025-04-08 10:02:24 +01:00
Stephen Tozer
93505f8e0e
[DebugInfo][InstCombine] Propagate DILocation when noop-ing invoke (#134678)
In InstCombine we may decide that an alloc is removable, and the alloc
fn is called by an InvokeInst, we replace that InvokeInst with a invoke
of a noop intrinsic; this patch has us also copy the original invoke's
DILocation to the new noop invoke.

Found using https://github.com/llvm/llvm-project/pull/107279.
2025-04-08 09:56:26 +01:00
Benjamin Maxwell
e1fc118f3a
[CI] Reduce false positives in undef checker (#134687)
Only check for diffs containing "undef" in .ll files, this prevents
comments like `// We should not have undef values...` triggering the
undef checker bot.
2025-04-08 09:53:33 +01:00
Pedro Lobo
bb5006169f
[CodeGen] Change placeholder from undef to poison (#134731)
Fill default values of a map with `poison` instead of `undef`. There
should be no functional difference as the default values are overridden
later.
2025-04-08 09:50:48 +01:00
Jerry-Ge
f0bdeb4b6a
[mlir][tosa] Cleanup ops.mlir (#134751)
* add missing CHECK-LABEL
* removed whitespace for consistency

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-08 09:34:40 +01:00
Jerry-Ge
f4328d0d3a
[mlir][tosa] Remove out_shape attribute from transpose_2d attributes (#134743)
out_shape is no longer an attribute

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-08 09:33:35 +01:00
Jerry-Ge
ccdc44f643
[mlir][tosa] Remove perms input for tosa.transpose tests (#134740)
Perms is now an attribute, not input.

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-08 09:32:45 +01:00
tianleliu
0df0906af6
[JumpThreading] Use [BB->SuccIndx] to get probability when updating BB info. (#134585)
In case the same src BB targets to the same dest BB in different
conditions/edges, such as switch-cases, we should use
prob[SrcBB->SuccIndx] instead of prob[SrcBB->DstBB] to get probability.
2025-04-08 16:32:34 +08:00
lorenzo chelini
e7365d3143
[MLIR][NFC] Retire let constructor for Reducer (#134786)
let constructor is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.
2025-04-08 10:31:15 +02:00
lorenzo chelini
87a187cedf
[MLIR][NFC] Retire let constructor for Tosa (#134784)
`let constructor` is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.
2025-04-08 10:30:47 +02:00
Orlando Cazalet-Hyams
308654608c [Clang][NFC] Move some static functions into CodeGenFunction (#134634)
Patches in the Key Instructions (KeyInstr) stack need to access CGF in these
functions. 2 CGF fields are passed to these functions already; at this point it
felt natural to promote them to CGF methods.
2025-04-08 08:44:10 +01:00
Shoreshen
8a53cc8ce5
remove failed test (#134793)
function `bitcast_v64i16_to_v128i8` in newly added test file
`llvm-project/llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.1024bit.ll` from
PR:https://github.com/llvm/llvm-project/pull/133052 failed in expansive
check. (passes normal lit check)

remove it for now
2025-04-08 15:39:12 +08:00
Nikita Popov
03f21e2ba3
[LangRef] Update initializes definition (#134370)
Specify the initializes attribute in terms of an "initialized" shadow
state, such that:

* Loads prior to initialization return poison.
* Bytes that are not explicitly initialized are written with undef on
function return.

This is intended to preserve the core semantics of the attribute, but
adjusts the wording in a way that is compatible with existing
optimizations, such as insertion of spurious loads and removal of
uninitialized writes.

Fixes https://github.com/llvm/llvm-project/issues/133038.
Fixes https://github.com/llvm/llvm-project/issues/133059.
2025-04-08 09:30:44 +02:00
Csanád Hajdú
2c1bdd4a08
[LLD][ELF] Allow merging XO and RX sections, and add --[no-]xosegment flag (#132412)
Following from the discussion in #132224, this seems like the best
approach to deal with a mix of XO and RX output sections in the same
binary. This change will also simplify the implementation of the
PURECODE section flag for AArch64.

To control this behaviour, the `--[no-]xosegment` flag is added to LLD
(similarly to `--[no-]rosegment`), which determines whether to allow
merging XO and RX sections in the same segment. The default value is
`--no-xosegment`, which is a breaking change compared to the previous
behaviour.

Release notes are also added, since this will be a breaking change.
2025-04-08 08:47:51 +02:00
Mingming Liu
0d19efa9d5
[NFC]In codegen pipeline, turn static-data-splitter pass on/off with its own option (#134752)
Per discussion in
https://github.com/llvm/llvm-project/pull/129781#discussion_r2017489088,
we'd like to refactor out the requirement of MFS.
2025-04-07 22:22:08 -07:00
Aniket Lal
642481a428
[Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (#115821)
This feature is currently not supported in the compiler.
To facilitate this we emit a stub version of each kernel
function body with different name mangling scheme, and
replaces the respective kernel call-sites appropriately.
    
Fixes https://github.com/llvm/llvm-project/issues/60313
    
D120566 was an earlier attempt made to upstream a solution
for this issue.

---------

Co-authored-by: anikelal <anikelal@amd.com>
2025-04-08 10:29:30 +05:30
Timm Baeder
65cede26a6
[clang][bytecode] Fix emitting dtors of zero-sized arrays (#134672)
Desc->getNumElems() returning 0 made us underflow here.
2025-04-08 06:09:21 +02:00
Timm Baeder
fb9915a391
[clang][bytecode] Fix emitDestruction() for dummy descriptors (#134665)
This might happen if the referenced declaration is invalid and thus gets
a dummy descriptor. We ran into an assertion later on.
2025-04-08 06:00:35 +02:00
Timm Baeder
bdd087023f
[clang][bytecode] Fix various issues with multidimensional arrays (#134628)
This issue is very convoluted, but in essence, in the new version:

For a Pointer P that points to the root of a multidimensional, primitive
array:

`P.narrow()` does nothing.
`P.atIndex(0)` points `P[0]`
`P.atIndex(0).atIndex(0)` is the same as `P.atIndex(0)` (as before)
`P.atIndex(0).narrow().atIndex(0)` points to `P[0][0]`
`P.atIndex(0).narrow().narrow()` is the same as `P.atIndex(0).narrow()`.
2025-04-08 05:48:55 +02:00
Shoreshen
49d6e39eba
[AMDGPU] add tests for loop definition of bitconvert (#133052)
This PR add test cases for all types of bit conversation, it prepares
for PR: https://github.com/llvm/llvm-project/pull/132899



All tests passed due to:
1. For DAG, pattern will not separate SReg and VReg. One of the sample
is:
    ```
define <2 x double> @v_bitcast_v4f32_to_v2f64(<4 x float> inreg %a, i32
%b) {
     %cmp = icmp eq i32 %b, 0
     br i1 %cmp, label %cmp.true, label %cmp.false
   
   cmp.true:
     %a1 = fadd <4 x float> %a, splat (float 1.000000e+00)
     %a2 = bitcast <4 x float> %a1 to <2 x double>
     br label %end
   
   cmp.false:
     %a3 = bitcast <4 x float> %a to <2 x double>
     br label %end
   
   end:
     %phi = phi <2 x double> [ %a2, %cmp.true ], [ %a3, %cmp.false ]
     ret <2 x double> %phi
   }
   ```
It suppose to select from scalar register patterns. But the Vreg pattern
is matched is as follow:
    ```
   Debug log:
   ISEL: Starting selection on root node: t3: v2f64 = bitcast t2
   ISEL: Starting pattern match
     Initial Opcode index to 440336
Skipped scope entry (due to false predicate) at index 440339, continuing
at 440367
Skipped scope entry (due to false predicate) at index 440368, continuing
at 440396
Skipped scope entry (due to false predicate) at index 440397, continuing
at 440435
Skipped scope entry (due to false predicate) at index 440436, continuing
at 440467
Skipped scope entry (due to false predicate) at index 440468, continuing
at 440499
Skipped scope entry (due to false predicate) at index 440500, continuing
at 440552
Skipped scope entry (due to false predicate) at index 440553, continuing
at 440587
Skipped scope entry (due to false predicate) at index 440588, continuing
at 440622
Skipped scope entry (due to false predicate) at index 440623, continuing
at 440657
Skipped scope entry (due to false predicate) at index 440658, continuing
at 440692
Skipped scope entry (due to false predicate) at index 440693, continuing
at 440727
Skipped scope entry (due to false predicate) at index 440728, continuing
at 440769
Skipped scope entry (due to false predicate) at index 440770, continuing
at 440798
Skipped scope entry (due to false predicate) at index 440799, continuing
at 440836
Skipped scope entry (due to false predicate) at index 440837, continuing
at 440870
     TypeSwitch[v2f64] from 440873 to 440892
   
   Patterns:
   /*440892*/    OPC_CompleteMatch, 1, 0, 
// Src: (bitconvert:{ *:[v2f64] } VReg_128:{ *:[v4f32] }:$src0) -
Complexity = 3
                  // Dst: VReg_128:{ *:[v2f64] }:$src0
    ```
2. Global isel will use `Select_COPY` to select bitcast
2025-04-08 11:40:38 +08:00
Naveen Seth Hanig
ac42b083f1
[clang][modules] Guard against bad -fmodule-file mappings (#132059) (#133462)
Fix https://github.com/llvm/llvm-project/issues/132059.

Providing incorrect mappings via `-fmodule-file=<name>=<path/to/bmi>`
can crash the compiler when loading a module that imports an
incorrectly mapped module.

The crash occurs during AST body deserialization, when the compiler
attempts to resolve remappings using the `ModuleFile` from the
incorrectly mapped module's BMI file.
The cause is an invalid access into an incorrectly loaded
`ModuleFile`.

This commit fixes the issue by verifying the identity of the imported
module.
2025-04-08 11:02:57 +08:00
Mircea Trofin
f1bb2fe356
[ctxprof] Use isInSpecializedModule as criteria for using contextual profile (#134468)
After #134340, the availability of contextual profile isn't in itself an indication of compiling the module containing all the functions covered by that profile.
2025-04-07 19:55:00 -07:00
Mircea Trofin
6a3e5f89bb
[ctxprof] Only prune the profile in modules containing only context trees (#134340)
We will subsequently treat the whole profile as "flat" in the frontend, (i.e flatten and combine with the flat profile section), so we can have a profile for ThinLTO for parts of the application that don't come under the contextual profile. After ThinLTO, we will treat the module(s) containing contextual trees differently: they'll have only the contextual profile pertinent to them. The rest of the modules (non-contextual) will proceed "as usual", off the flattened profile.

This patch implements pruning of the contextual profile to enable the above.
2025-04-07 19:52:03 -07:00
Congcong Cai
5aae0ee660
[clang-tidy] give dummy path when create ClangTidyContext (#134670)
#121323 changed the way the absolute path is computed. Empty file name
will cause absolute path ignore current folder.
This patch add "dummy" file name to avoid this issue
Fixed: #134502
2025-04-08 10:47:39 +08:00
Peter Collingbourne
499930e38a gn build: Spell arm64 correctly. 2025-04-07 19:37:33 -07:00
Matheus Izvekov
d057811655
[clang] fix diagnostic printing of expressions ignoring LangOpts (#134693)
Currently when printing a template argument of expression type, the
expression is converted immediately into a string to be sent to the
diagnostic engine, unsing a fake LangOpts.

This makes the expression printing look incorrect for the current
language, besides being inneficient, as we don't actually need to print
the expression if the diagnostic would be ignored.

This fixes a nastiness with the TemplateArgument constructor for
expressions being implicit, and all current users just passing an
expression to a diagnostic were implicitly going through the template
argument path.

The expressions are also being printed unquoted. This will be fixed in a
subsequent patch, as the test churn is much larger.
2025-04-07 23:19:32 -03:00