533385 Commits

Author SHA1 Message Date
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
Matt Arsenault
3a0c95fb50
llvm-reduce: Fix introducing unreachable code in simplify conditionals (#133842)
After replacing the branch condition, this was calling simplifyCFG to
perform the cleanups of the branch. This is far too heavy of a hammer.
We do not want all of the extra optimizations in simplifyCFG, and
this could also leave behind dead code. Instead, minimally fold the
terminator and try to delete the newly dead code.

This is pretty much a direct copy of what bugpoint does.
2025-04-08 08:51:20 +07:00
Valentin Clement (バレンタイン クレメン)
3f4e4e0a12
[flang][cuda] Add on_device interface to cudadevice (#134747) 2025-04-07 18:21:07 -07:00
Rahul Joshi
bb1f32ded0
[NFC][LLVM] Change initialize<PassName>PassOnce to return void (#134500)
- The return value of these functions (called using `llvm::call_once`)
is never used, so make these functions return void.
2025-04-07 18:10:06 -07:00
Rahul Joshi
20eb60d3f2
[NFC][LLVM] Cleanup pass initialization for wasm/LoongArch (#134452)
- Remove calls to pass initialization from pass constructors.
- https://github.com/llvm/llvm-project/issues/111767
2025-04-07 18:09:46 -07:00
Rahul Joshi
80fde75dc6
[NFC][LLVM][SystemZ] Cleanup pass initialization for SystemZ (#134450)
- Remove calls to pass initialization from pass constructors.
- https://github.com/llvm/llvm-project/issues/111767
2025-04-07 18:08:55 -07:00
Bruno Cardoso Lopes
a168ddc470
[MLIR][LLVM] Block address support (#134335)
Add support for import and translate.

MLIR does not support using basic block references outside a function
(like LLVM does), This PR does not consider changes to MLIR to that
respect. It instead introduces two new ops: `llvm.blockaddress` and
`llvm.blocktag`. Here's an example:

```
llvm.func @ba() -> !llvm.ptr {
  %0 = llvm.blockaddress <function = @ba, tag = <id = 1>> : !llvm.ptr
  llvm.br ^bb1
^bb1:  // pred: ^bb0
  llvm.blocktag <id = 1>
  llvm.return %0 : !llvm.ptr
}
```

Value `%0` hold the address of block tagged as `id = 1` in function
`@ba`. Block tags need to be unique within a function and use of
`llvm.blockaddress` requires a matching tag in a `llvm.blocktag`.
2025-04-07 17:53:18 -07:00
Matt Arsenault
1a9928442b
SeparateConstOffsetFromGEP: Avoid looking at constant uses (#134685)
We could be more aggressive and inspect uses of global variables,
if the use context instruction is in the same function.
2025-04-08 07:44:45 +07:00
Matt Arsenault
76e219d9c3
SeparateConstOffsetFromGEP: Add more tests with lower-gep (#134684)
I didn't see any failures while trying to break hasMoreThanOneUseInLoop
or other paths here.
2025-04-08 07:40:57 +07:00
Matt Arsenault
8286b804d5
OMPIRBuilder: Do not try to expand uses of ConstantData (#134584) 2025-04-08 07:36:55 +07:00
Matt Arsenault
87afe4de22
OMPIRBuilder: Cleanup checking for GlobalValue (#134583)
GlobalValue already subsumes GlobalObject and GlobalVariable,
plus make use of the std::get<0> already copied to a variable
above.
2025-04-08 07:33:07 +07:00
Rahul Joshi
7073676216
[NFC][LLVM][DirectX] Cleanup pass initialization for DirectX (#134419)
- Remove calls to pass initialization from pass constructors.
- https://github.com/llvm/llvm-project/issues/111767
2025-04-07 17:28:26 -07:00
Rahul Joshi
a3754ade63
[NFC][LLVM][AMDGPU] Cleanup pass initialization for AMDGPU (#134410)
- Remove calls to pass initialization from pass constructors.
- https://github.com/llvm/llvm-project/issues/111767
2025-04-07 17:27:50 -07:00
Rahul Joshi
1356e202b2
[NFC][LLVM][BPF] Cleanup pass initialization for BPF (#134414)
- Remove calls to pass initialization from pass constructors and move
them to target initialization.
- https://github.com/llvm/llvm-project/issues/111767
2025-04-07 17:27:26 -07:00
Matheus Izvekov
735f5b1cb4
[clang] fix DependentTemplateSpecializationType transform (#134748)
This changes the transform for DTST so it rebuilds the node if any of
the template arguments changed.

This fixes a regression reported here:
https://github.com/llvm/llvm-project/pull/133610#issuecomment-2784576267
which was introduced by https://github.com/llvm/llvm-project/pull/133610

There are no release notes since the regression was never released.
2025-04-07 21:25:37 -03:00
Matt Arsenault
1f359610b0
ObjCARC: Drop pointer bitcast handling (#134274)
There is more in the file to drop, but this looks like the easier
part.
2025-04-08 07:23:00 +07:00
Han-Kuan Chen
d7354e337a
[SLP][REVEC] Fix ShuffleVector does not consider alternate instruction. (#134599) 2025-04-08 08:04:43 +08:00
Jorge Gorbe Moya
99d12ac172 [bazel] Fix build after 65813e0e94c0403dad61e8365b39d76d7b3bfc14 2025-04-07 17:03:30 -07:00
Justin Bogner
0afa872a0d
[DirectX] Scalarize the dx.saturate intrinsic (#134381)
The DXIL Saturate op only takes scalars.

Fixes #134378.
2025-04-08 08:54:10 +09:00
Tom Yang
65813e0e94
Control Darwin parallel image loading with target.parallel-module-load (#134437)
A requested follow-up from
https://github.com/llvm/llvm-project/pull/130912 by @JDevlieghere to
control Darwin parallel image loading with the same
`target.parallel-module-load` that controls the POSIX dyld parallel
image loading. Darwin parallel image loading was introduced by
https://github.com/llvm/llvm-project/pull/110646.

This small change:
* removes
`plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load`
and associated code.
* changes setting call site in
`DynamicLoaderDarwin::PreloadModulesFromImageInfos` to use the new
setting.

Tested by running `ninja check-lldb` and loading some targets.

Co-authored-by: Tom Yang <toyang@fb.com>
2025-04-07 16:33:48 -07:00
Jerry-Ge
a38ad6e2a2
[mlir][tosa] Check empty Concat input for inferReturnTypeComponents (#134728)
Signed-off-by: Jerry Ge <jerry.ge@arm.com>
2025-04-07 16:27:08 -07:00
Mingming Liu
ddb32a67c2
[NFC] Add a precommit test for aarch64 jump table partitioning (#125987) 2025-04-07 16:21:12 -07:00
Andres Chavarria
9b63a92ca7
Implement areInlineCompatible for SystemZ using feature bitset (#132976)
## What?
Implement `areInlineCompatible` for the SystemZ target using
FeatureBitset comparison.

## Why?
The default implementation in `TargetTransformInfoImpl.h` makes a string
comparison and only inlines when the target-cpu and the target-features
for caller and callee are the same. We are missing out on optimizations
when the callee has a subset of features of the caller.

## How?
Get the FeatureBitset of the caller and callee and check when callee is
a subset or equal to the caller's features. It's a similar
implementation to ARM, PowerPC...

## Testing?
Test cases check for when the callee is a subset of the caller, when
it's not a subset and when both are equals.
2025-04-08 00:50:30 +02:00
Philip Reames
9ce4557978 [RISCV] Add coverage for reported miscompile in shuffle lowering
Derived from the example in https://github.com/llvm/llvm-project/issues/134126
2025-04-07 15:34:00 -07:00
Sarah Spall
01bc672b8a
[HLSL] Desugar ConstantArrayType when calculating cbuffer field layout (#134683)
When calculating the layout for a cbuffer field, if that field is a
ConstantArrayType, desguar it before casting it to a ConstantArrayType.
Closes #134668

---------

Co-authored-by: Eli Friedman <efriedma@quicinc.com>
2025-04-07 15:25:47 -07:00