Commit Graph

541582 Commits

Author SHA1 Message Date
Justin King
f780955e1d lsan: fix macos build after #144604 (#144818)
Fixes build failures on macOS, including

https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/

llvm-project/compiler-rt/lib/lsan/lsan_interceptors.cpp:579:3: error: use of undeclared identifier 'LSAN_MAYBE_INTERCEPT_FREE_SIZED'
13:23:58    579 |   LSAN_MAYBE_INTERCEPT_FREE_SIZED;
13:23:58        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13:23:58  /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/compiler-rt/lib/lsan/lsan_interceptors.cpp:580:3: error: use of undeclared identifier 'LSAN_MAYBE_INTERCEPT_FREE_ALIGNED_SIZED'
13:23:58    580 |   LSAN_MAYBE_INTERCEPT_FREE_ALIGNED_SIZED;
13:23:58        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13:23:58  2 errors generated.
2025-06-19 18:38:45 +01:00
Abhishek Kaushik
0b8179b2ad [ValueTracking] Improve Bitcast handling to match SDAG (#125935)
Closes #125228
2025-06-19 18:35:40 +01:00
Slava Zakharin
c0c71463f6 [InstCombine] Optimize sub(sext(add(x,y)),sext(add(x,z))). (#144174)
This pattern can be often met in Flang generated LLVM IR,
for example, for the counts of the loops generated for array
expressions like: `a(x:x+y)` or `a(x+z:x+z)` or their variations.

In order to compute the loop count, Flang needs to subtract
the lower bound of the array slice from the upper bound
of the array slice. To avoid the sign wraps, it sign extends
the original values (that may be of any user data type)
to `i64`.

This peephole is really helpful in CPU2017/548.exchange2,
where we have multiple following statements like this:
```
block(row+1:row+2, 7:9, i7) = block(row+1:row+2, 7:9, i7) - 10
```

While this is just a 2x3 iterations loop nest, LLVM cannot
figure it out, ending up vectorizing the inner loop really
hard (with a vector epilog and scalar remainder). This, in turn,
causes problems for LSR that ends up creating too many loop-carried
values in the loop containing the above statement, which are then
causing too many spills/reloads.

Alive2: https://alive2.llvm.org/ce/z/gLgfYX

Related to #143219.
2025-06-19 10:13:58 -07:00
Slava Zakharin
6ce86538c1 [mlir][cf] Preserve branch weights during cf.cond_br canonicalization. (#144822) 2025-06-19 10:09:10 -07:00
Florian Hahn
0816bb32ac [Matrix] Fix heap-use-after-free after 0fa373c77d.
We need to skip instructions in FusedInsts, as they may have been
deleted. Fixes a heap-use-after-free after #141681.
2025-06-19 17:52:31 +01:00
Andrzej Warzyński
3fe62682ef [mlir][vector] Use result consistently as the result argument name (#144739)
This patch updates the following ops to use `result` (instead of `res`)
as the name for their result argument:
  * `vector.scalable.insert`
  * `vector.scalable.extract`
  * `vector.insert_strided_slice`

This change ensures naming consistency with other ops in the `vector`
dialect. It addresses part of:
* https://github.com/llvm/llvm-project/issues/131602
2025-06-19 17:34:08 +01:00
Rahul Joshi
c0cc81cdc0 [NFC][Clang] Adopt simplified getTrailingObjects in ASTReader (#144438) 2025-06-19 09:25:32 -07:00
Rahul Joshi
5cf7d871b0 [NFC][Clang][AST] Adopt simplified getTrailingObjects in AST (#144432)
Adopt simplified `getTrailingObjects` API in several places in clag/AST
that were missed by earlier changes.
2025-06-19 09:25:04 -07:00
lntue
b8337349d9 [libc][math] Skip setting errno and floating point exception for math functions when LIBC_MATH flag has LIBC_MATH_NO_ERRNO and LIBC_MATH_NO_EXCEPT. (#144920) 2025-06-19 12:18:39 -04:00
lntue
c1ac87b327 [libc] Fix setjmp build order. (#144917)
Fix build order issue from
https://github.com/llvm/llvm-project/pull/139555.
2025-06-19 12:05:58 -04:00
Steven Perron
01d648a429 [HLSL][SPIRV] Reapply "[HLSL][SPIRV] Add vk::constant_id attribute." (#144902)
- **Reapply "[HLSL][SPIRV] Add vk::constant_id attribute." (#144812)**
- **Fix memory leak.**
2025-06-19 11:52:55 -04:00
Nikita Popov
f4db14229c [SCCP] Move logic for removing ssa.copy into Solver (NFC)
So it can be reused between IPSCCP and SCCP.

Make the implementation a bit more efficient by only lookup the
PredicateInfo once.
2025-06-19 17:28:39 +02:00
Stephen Tozer
36af7345df Reapply "[Clang] Enable -fextend-variable-liveness at -Og (#118026)"
Relands this feature after several fixes:

* Force fake uses to be emitted before musttail calls (#136867)
* Added soften-float legalization for fake uses (#142714)
* Treat fake uses as size-less instructions in a SystemZ assert (#144390)

If further issues with fake uses are found then this may be reverted again,
but all currently-known issues are resolved.

This reverts commit 2dc6e98169.
2025-06-19 16:22:50 +01:00
Karlo Basioli
3de01d07c3 Fix bazel build after #144594, mark variable as potentially unused (#144910) 2025-06-19 16:16:03 +01:00
Craig Topper
5eb24fde11 [SelectionDAG][RISCV] Preserve nneg flag when folding (trunc (zext X))->(zext X). (#144807)
If X is known non-negative, that's still true if we fold the truncate
to create a smaller zext.
    
In the i128 tests, SelectionDAGBuilder aggressively truncates the
`zext nneg` to i64 to match `getShiftAmountTy`. If we don't preserve
the `nneg` we can't see that the shift amount argument being `signext`
means we don't need to do any extension
2025-06-19 08:06:07 -07:00
Karlo Basioli
fdb572681d Fix bazel build after #144594 (#144904) 2025-06-19 15:50:53 +01:00
Mikhail R. Gadelha
3516ad05df [RISCV] Update SpacemiT X60 scheduling latencies based on hardware measurements (#144730)
This patch updates the RISC-V SpacemiT X60 scheduling model with latency
values collected from the X60 hardware. The previous values were
empirically derived but were slightly off.

  Changes:
  - LoadLatency (baseline for load instructions): 5 --> 3 cycles
  - Memory operations: unified at 4 cycles
  - Atomic loads/stores: 5 --> 8 cycles
  - Atomic RMW operations: 5 --> 12 cycles

Hardware-measured values provide more accurate instruction scheduling
for the in-order X60 core. Testing shows NFC across benchmarks except
for 523.xalancbmk_r (known to be noisy).

https://lnt.lukelau.me/db_default/v4/nts/663?compare_to=657
2025-06-19 11:42:50 -03:00
Tobias Gysi
eb694b2846 [mlir][arith] Delete mul ext canonicalizations (#144844)
The Arith dialect includes patterns that canonicalize a sequence of:

- trunci(shrui(mul(sext(x), sext(y)), c)) -> mulsi_extended(x, y)
- trunci(shrui(mul(zext(x), zext(y)), c)) -> mului_extended(x, y)

These patterns return the high word of an extended multiplication, which
assumes that the shift amount is equal to the bit width of the original
operands. This check was missing, leading to incorrect canonicalizations
when the shift amount was less than the bit width.

For example, the following code:
```
  %x = arith.extui %a: i32 to i33
  %y = arith.extui %b: i32 to i33
  %m = arith.muli %x, %y: i33
  %c1 = arith.constant 1: i33
  %sh = arith.shrui %m, %c1 : i33
  %hi = arith.trunci %sh: i33 to i32
```
would incorrectly be canonicalized to:
```
_, %hi = arith.mului_extended %a, %b : i32
```
This commit removes the faulty canonicalizations since they are not
believed to be generally beneficial (c.f., the discussion of the
alternative https://github.com/llvm/llvm-project/pull/144787 which fixes
the canonicalizations).
2025-06-19 16:32:48 +02:00
Jack Styles
89efae916a [Flang][OpenMP] Update default MapType for Map Clauses and OpenMP 5.2 (#144715)
In OpenMP 5.2, the `target enter data` and `target exit data` constructs
now have default map types if the user does not define them in the Map
clause. For `target enter data`, this is `to` and `target exit data`
this is `from`. This behaviour is now enabled when OpenMP 5.2 or greater
is used when compiling. To enable this, the default value is now set in
the `processMap` clause, with any previous behaviour being maintained
for either older versions of OpenMP or other directives.

See also #110008
2025-06-19 15:32:27 +01:00
Nico Weber
19360e62d0 [gn build] port bf79d4819e (ppc -gen-target-features) 2025-06-19 10:25:35 -04:00
Joseph Huber
4c6f398b86 [Clang] Add standalone AMDGPU SPIR-V toolchain (#144576)
Summary:
The AMDGPU toolchain uses a different set of tools than the standard
SPIR-V toolchain. The linker wrapper prefers to invoke a linker via a
clang toolchain. To make that work we introduce
`--target=spirv64-amd-amdhsa` so that it creates the linking phases that
HIP prefers. Additionally, this can be used to make LLVM-IR / SPIR-V
from C/C++ that can be linked with the HIP output.
2025-06-19 09:23:57 -05:00
Siu Chi Chan
7e8f1f5f72 [HIP] Remove dots in HIP runtime path (#143792)
Remove the dots in the HIP path before passing to the rpath flag
2025-06-19 14:23:23 +00:00
Nikita Popov
802fa92aee [PredicateInfo] Avoid duplicate hash lookup (NFC)
Use try_emplace to either look up the existing entry or insert it.
2025-06-19 16:18:29 +02:00
Matthias Springer
a4e4527c4b [mlir][Transforms] Fix replaceUsesOfBlockArgument API (#144706)
Before this PR, users had to pass the "old" block argument when
replacing the uses of a block argument in a newly converted block. Users
can now pass the actual block argument that should be replaced.

Note for LLVM integration: Make sure to pass the current block argument
instead of the old one.
2025-06-19 15:39:06 +02:00
Abhishek Kaushik
278ece7c80 [InstCombine][NFC] Pre-commit tests for #125935 (#144111)
Pre-commit tests for #125935

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-06-19 14:29:05 +01:00
Brox Chen
e75e2485f2 [AMDGPU][True16][Codegen] keep srcmod/clamp/omod from v_s_xxx_f16 when moved to VALU (#144781)
https://github.com/llvm/llvm-project/pull/141152 causes an issue in
v_s_xxx_f16 lowering in both true16/fake16 flow.

V_S_XXX_F16 are special insts which has scalar input/output but in VALU
VOP3 format. Need to keep the srcmod/clamp/omod when lower it to its
corresponding VALU inst with vector input/output.
2025-06-19 09:26:45 -04:00
Abdul Raheem
f87b6625d6 [MLIR][NFC] Fixed some Typos (#144263)
-- Fixed some typos in Operation.h

Signed-off: Abdul Raheem Beigh abdulraheembeigh@gmail.com
2025-06-19 06:24:34 -07:00
zhijian lin
bf79d4819e [Reland] [PowerPC] frontend get target feature from backend with cpu name (#144594)
1. The PR proceeds with a backend target hook to allow front-ends to
determine what target features are available in a compilation based on
the CPU name.
2. Fix a backend target feature bug that supports HTM for
Power8/9/10/11. However, HTM is only supported on Power8/9 according to
the ISA.
3. All target features that are hardcoded in PPC.cpp can be retrieved
from the backend target feature. I have double-checked that the
hardcoded logic for inferring target features from the CPU in the
frontend(PPC.cpp) is the same as in PPC.td.

The reland patch addressed the comment
https://github.com/llvm/llvm-project/pull/137670#discussion_r2143541120
2025-06-19 09:22:16 -04:00
Aly ElAshram
5645d67109 Implement sigsetjmp and siglongjmp for darwin/aarch64 (#139555) 2025-06-19 09:15:59 -04:00
Ilia Kuklin
83381ba832 [LLDB] Add negative number parsing to DIL (#144557) 2025-06-19 18:10:56 +05:00
David Spickett
493a359237 [lldb][AArch64] Fix live process test for Linux's mte_ctrl register
I forgot to update this when I changed the presentation of the
"TCF" field.
2025-06-19 12:58:57 +00:00
Anatoly Trosinenko
e873fd157e [BOLT] Gadget scanner: do not crash on debug-printing CFI instructions (#136151)
Some instruction-printing code used under LLVM_DEBUG does not handle CFI
instructions well. While CFI instructions seem to be harmless for the
correctness of the analysis results, they do not convey any useful
information to the analysis either, so skip them early.
2025-06-19 15:52:54 +03:00
Joseph Huber
09e794c4bb [HIP] Emit the CUID value in the module with the new driver (#144570)
Summary:
This is a weird point of divergence that was not updated when the new
driver
switched to using the CUID method, which is also apparently critical
for SPIR-V compilation not failing? Somehow if we don't emit this global
than the `llvm.compiler.used` global uses AS(0) which makes SPIR-V
unhappy, but with this global it's AS(4) which makes it happy. Either
way, this should be fixed.
2025-06-19 07:47:03 -05:00
Charles Zablit
c079040eea [lldb] add has methods to all DemangledNameInfo attributes (#144549)
Add `hasX` methods to all the attributes of `DemangledNameInfo`.
2025-06-19 13:44:41 +01:00
Michael Buch
dae5104eed [lldb][DWARFASTParserClang] Make GetCXXObjectParameter public and call it from unit-tests (#144879)
My goal is to remove the `object_pointer` member on
`ParsedDWARFTypeAttributes` since it's duplicating information that we
retrieve with `GetCXXObjectParameter` anyway. To continue having
coverage for the `DW_AT_object_pointer` code-paths, instead of checking
the
`attrs.object_pointer` I'm now calling `GetCXXObjectParameter` directly.
We could find some very roundabout way to go via the Clang AST to check
that the object parameter was parsed correctly, but that quickly became
quite painful.

Depends on https://github.com/llvm/llvm-project/pull/144876
2025-06-19 13:42:23 +01:00
Karlo Basioli
5148e08538 Fix build issue caused by commit #0fe78c4 (#144888)
Noticed internally in blaze build.
2025-06-19 13:30:20 +01:00
Florian Hahn
c4c2d777f4 [VPlan] Fix handling of ReductionStartVector for rdxs when unrolling.
Update handling of ReductionStartVector in VPlanUnroll for partial
reductions. The new code makes sure all parts are properly set to the
cloned ReductionStartVector.

Fixes a mis-compile reported for
https://github.com/llvm/llvm-project/pull/142290.
2025-06-19 13:26:19 +01:00
Paul Walker
e478a22d54 [LLVM][IRBuilder] Use NUW arithmetic for Create{ElementCount,TypeSize}. (#143532)
This put the onus on the caller to ensure the result type is big enough.
In the unlikely event a cropped result is required then explicitly
truncate a safe value.
2025-06-19 13:24:39 +01:00
Krzysztof Parzyszek
936c5566db [flang][OpenMP] Handle REQUIRES ADMO in lowering (#144362)
The previous approach rewrote the atomic constructs in the AST based on
the REQUIRES ATOMIC_DEFAULT_MEM_ORDER directives. The new approach
checks for incorrect uses of REQUIRED ADMO in the semantic analysis, and
applies it in lowering, eliminating the need for a separate
tree-rewriting procedure.
2025-06-19 07:18:21 -05:00
Anatoly Trosinenko
2b4d757290 [BOLT] Gadget scanner: detect authentication oracles (#135663)
Implement the detection of authentication instructions whose results can
be inspected by an attacker to know whether authentication succeeded.

As the properties of output registers of authentication instructions are
inspected, add a second set of analysis-related classes to iterate over
the instructions in reverse order.
2025-06-19 15:15:26 +03:00
Donát Nagy
b73720cf6c [analyzer] Conversion to CheckerFamily: DynamicTypePropagation (#144735)
This commit converts the class DynamicTypePropagation to a very simple
checker family, which has only one checker frontend -- but also supports
enabling the backend ("modeling checker") without the frontend.

As a tangentially related change, this commit adds the backend of
DynamicTypePropagation as a dependency of alpha.core.DynamicTypeChecker
in Checkers.td, because the header comment of DynamicTypeChecker.cpp
claims that it depends on DynamicTypePropagation and the source code
seems to confirm this.

(The lack of this dependency relationship didn't cause problems, because
'core.DynamicTypePropagation' is in the group 'core', so it is
practically always active. However, explicitly declaring the dependency
clarifies the fact that the separate existence of the modeling checker
is warranted.)
2025-06-19 14:00:36 +02:00
Matthias Springer
e33f13ba48 [mlir][arith] Add overflow flags to arith.trunci (#144863)
LLVM already supports overflow flags on `llvm.trunc` for a while. This
commit adds support for these flags to `arith.trunci`.
2025-06-19 13:59:22 +02:00
Florian Hahn
046e2f545e [LV] Add interleaving test with partial reductions and non-const start.
Add test coverage for mis-compile after
https://github.com/llvm/llvm-project/pull/142290.
2025-06-19 12:55:16 +01:00
Michael Buch
30824c449a [lldb][DWARFASTParserClang] GetCXXObjectParameter to take DeclContext DIE parameter (#144876)
I'm trying to call `GetCXXObjectParameter` from unit-tests in a
follow-up patch and taking a `DWARFDIE` instead of `clang::DeclContext`
makes that much simpler. These should be equivalent, since all we're
trying to check is that the parent context is a record type.
2025-06-19 12:48:39 +01:00
Ramkumar Ramachandra
74054cab7a [HashRecognize] Make it a non-PM analysis (#144742)
Make HashRecognize a non-PassManager analysis that can be called to get
the result on-demand, creating a new getResult() entry-point. The issue
was discovered when attempting to use the analysis to perform a
transform in LoopIdiomRecognize.
2025-06-19 12:29:58 +01:00
Matt Arsenault
1c35fe4e6b RuntimeLibcalls: Pass in exception handling type (#144696)
All of the ABI options that influence libcall decisions need
to be passed in.
2025-06-19 19:08:52 +09:00
Matt Arsenault
305953a32d MC: Move ExceptionHandling enum to Support (#144692)
Similar to b5967264b0, we need
to use this in RuntimeLibcalls to compute the set of library
calls.
2025-06-19 19:05:56 +09:00
Matt Arsenault
5bee2c34bd RuntimeLibcalls: Pass in FloatABI and EABI type (#144691)
We need the full set of ABI options to accurately compute
the full set of libcalls. This partially resolves missing
information required to compute the set of ARM calls.
2025-06-19 19:02:42 +09:00
Chuanqi Xu
0fe78c4a29 [NFC] [Serialization] Some Code Cleanups for Name lookup table things 2025-06-19 17:54:07 +08:00
David Sherwood
af51c9d9df [LV][NFC] Add branch weight test showing incorrect behaviour (#144682)
This patch adds a test that shows incorrect branch weights being set in
function

EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck
2025-06-19 10:49:40 +01:00