529994 Commits

Author SHA1 Message Date
Gergely Futo
3acfef56b1
[libunwind][RISCV] Make asm statement volatile (#130286)
Compiling with `O3`, the `early-machinelicm` pass hoisted the asm
statement to a path that has been executed unconditionally during stack
unwinding. On hardware without vector extension support, this resulted
in reading a nonexistent register.
2025-03-10 10:13:33 +01:00
Maksim Levental
0264d42dc7
[mlir][CAPI][python] bind CallSiteLoc, FileLineColRange, FusedLoc, NameLoc (#129351)
This PR extends the python bindings for CallSiteLoc, FileLineColRange,
FusedLoc, NameLoc with field accessors. It also adds the missing
`value.location` accessor.

I also did some "spring cleaning" here (`cast` -> `dyn_cast`) after
running into some of my own illegal casts.
2025-03-10 05:10:34 -04:00
Boaz Brickner
e0442bdfa5
[Clang] Fix segmentation fault caused by VarBypassDetector stack overflow on deeply nested expressions (#124128)
This happens when using `-O2`.

Similarly to #111701
([test](93e4a7386e/clang/test/CodeGen/deeply-nested-expressions.cpp)),
not adding a test that reproduces since this test is slow and likely to
be hard to maintained as discussed here and in [previous
discussion](1a63281b6c (r1795518779)).
Test that was reverted here:
d6b5576940
2025-03-10 09:33:00 +01:00
Timm Baeder
35f273ab07
[clang][NFC] Clean up Expr::EvaluateAsConstantExpr (#130498)
The Info.EnableNewConstInterp case is already handled above.
2025-03-10 08:56:23 +01:00
Adrian Kuegel
6e8d7e2e7f [mlir] Apply ClangTidy finding (NFC)
loop variable is copied but only used as const reference; consider making it a const reference
2025-03-10 07:43:40 +00:00
Ryosuke Niwa
c8ec8073aa
[alpha.webkit.NoUnretainedMemberChecker] Add a new WebKit checker for unretained member variables and ivars. (#128641)
Add a new WebKit checker for member variables and instance variables of
NS and CF types. A member variable or instance variable to a CF type
should be RetainPtr regardless of whether ARC is enabled or disabled,
and that of a NS type should be RetainPtr when ARC is disabled.
2025-03-09 23:30:08 -07:00
Kazu Hirata
b2b267ea7a
[CodeGen] Avoid repeated hash lookups (NFC) (#130543) 2025-03-09 23:15:32 -07:00
Kazu Hirata
5addbf0c60
[AArch64] Avoid repeated hash lookups (NFC) (#130542) 2025-03-09 23:15:22 -07:00
Sushant Gokhale
c4808741e8
[AArch64][CostModel] Alter sdiv/srem cost where the divisor is constant (#123552)
This patch revises the cost model for sdiv/srem and draws its inspiration from the udiv/urem patch #122236

The typical codegen for the different scenarios has been mentioned as notes/comments in the code itself( this is done owing to lot of scenarios such that it would be difficult to mention them here in the patch description).
2025-03-09 22:26:39 -07:00
Craig Topper
58fc4b13cb [RISCV] Remove Predicates from classes in RISCVInstrInfoXTHead.td. NFC
All of instantiations of these classes also specify Predicates
making the base class redundant or unnecessary. The Predicates on the
instantiations aren't always the same as the base class so those
are needed.

Also move the DecoderNamespace to the instantiations for consistency
with the Predicates.
2025-03-09 21:48:21 -07:00
Diana Picus
3e94eae746
[AMDGPU] Add GFX12 S_ALLOC_VGPR instruction (#130018)
This patch only adds the instruction for disassembly support.

We neither have an instrinsic nor codegen support, and it is unclear
whether we actually want to ever have an intrinsic, given the fragile
semantics.

For now, it will be generated only by the backend in very specific
circumstances.

---------

Co-authored-by: Jannik Silvanus <jannik.silvanus@amd.com>
2025-03-10 05:07:56 +01:00
Changpeng Fang
fa45bf4300
InstCombine: Fix a crash in PointerReplacer when constructing a new PHI (#130256)
When constructing a PHI node in `PointerReplacer::replace`, the incoming
operands are expected to have already been replaced and in the
replacement map. However, when one of the incoming operands is a load,
the search of the map is unsuccessful, and a nullptr is returned from
`getReplacement`. The reason is that, when a load is replaced, all the
uses of the load has been actually replaced by the new load. It is
useless to insert the original load into the map. Instead, we should
place the new load into the map to meet the expectation of the later map
search.

Fixes: SWDEV-516420
2025-03-09 20:21:36 -07:00
Zhaoxin Yang
64c73d5c71 Reland [lld][LoongArch] Relax call36/tail36: R_LARCH_CALL36
Instructions with relocation `R_LARCH_CALL36` may be relax as follows:
```
From:
   pcaddu18i $dest, %call36(foo)
     R_LARCH_CALL36, R_LARCH_RELAX
   jirl $r, $dest, 0
To:
   b/bl foo  # bl if r=$ra, b if r=$zero
     R_LARCH_B26
```

This patch fixes the buildbots failuer of lld tests.
Changes: Modify test files: from `sym@plt` to `%plt(sym)`.
2025-03-10 11:02:23 +08:00
Aiden Grossman
de132b2a0c
[Clang][CodeGen] Fix demangler invariant comment assertion (#130522)
This patch makes the assertion (that is currently in a comment) that
validates that names mangled by clang can be demangled by LLVM actually
compile/work. There were some minor issues that needed to be fixed (like
starts_with not being available on std::string and needing to call
getDecl() on GD), and a logic issue that should be fixed in this patch.
This enables just uncommenting the assertion to enable it within the
compiler (minus needing to add the header file).
2025-03-09 19:56:40 -07:00
beetrees
8b9c91ec7d
[APFloat] Fix IEEEFloat::addOrSubtractSignificand and IEEEFloat::normalize (#98721)
Fixes #63895
Fixes #104984

Before this PR, `addOrSubtractSignificand` presumed that the loss came
from the side being subtracted, and didn't handle the case where lhs ==
rhs and there was loss. This can occur during FMA. This PR fixes the
situation by correctly determining where the loss came from and handling
it appropriately.

Additionally, `normalize` failed to adjust the exponent when the
significand is zero but `lost_fraction != lfExactlyZero`. This meant
that the test case from #63895 was rounded incorrectly as the loss
wasn't adjusted to account for the exponent being below the minimum
exponent. This PR fixes this by only skipping the exponent adjustment if
the significand is zero and there was no lost fraction.

(Note to reviewer: I don't have commit access)
2025-03-10 09:44:27 +07:00
Ruoyu Qiu
82f2b66110
[llvm-objdump][ELF]Fix crash when reading strings from .dynstr (#125679)
This change introduces a check for the strtab offset to prevent
llvm-objdump from crashing when processing malformed ELF files.
It provide a minimal reproduce test for
https://github.com/llvm/llvm-project/issues/86612#issuecomment-2035694455.
Additionally, it modifies how llvm-objdump handles and outputs malformed
ELF files with invalid string offsets.(More info:
https://discourse.llvm.org/t/should-llvm-objdump-objdump-display-actual-corrupted-values-in-malformed-elf-files/84391)

Fixes: #86612

Co-authored-by: James Henderson <James.Henderson@sony.com>
2025-03-09 19:39:58 -07:00
Eli Friedman
42d49a7724
[clang] Reject constexpr-unknown values as constant expressions more consistently (#129952)
Perform the check for constexpr-unknown values in the same place we
perform checks for other values which don't count as constant
expressions.

While I'm here, also fix a rejects-valid with a reference that doesn't
have an initializer. This diagnostic was also covering up some of the
bugs here.

The existing behavior with -fexperimental-new-constant-interpreter seems
to be correct, but the diagnostics are slightly different; it would be
helpful if someone could check on that as a followup.

Followup to #128409.

Fixes #129844. Fixes #129845.
2025-03-09 18:38:55 -07:00
Ryan Mansfield
d111e6481a
[clang] Fix typos in options text. (#130129) 2025-03-10 09:37:21 +08:00
Jim Lin
f62ab334c6
[RISCV] Fix incorrect mask of shuffle vector in the test. (NFC) (#130244)
The mask of shuffle vector should be <u, u, 4, 6, 8, 10, 12, 14>, not
<u, u, 4, 6, *6, 10, 12, 14> for steps of 2.

And the mask of suffle vector with an undef initial element has been
supported by https://github.com/llvm/llvm-project/pull/118509.
2025-03-10 09:29:51 +08:00
Andrei Safronov
69527b0013
[Xtensa] Implement Xtensa MAC16 Option. (#130004) 2025-03-10 03:26:33 +03:00
Oleksandr T.
bfdeb58730
[Clang] use constant evaluation context for constexpr if conditions (#123667)
Fixes #123524

---

This PR addresses the issue of immediate function expressions not
properly evaluated in `constexpr` if conditions. Adding the
`ConstantEvaluated` context for expressions in `constexpr` if statements
ensures that these expressions are treated as manifestly
constant-evaluated and parsed correctly.
2025-03-10 01:53:20 +02:00
Ryosuke Niwa
5c3b05996f
[alpha.webkit.UnretainedLambdaCapturesChecker] Add a WebKit checker for lambda capturing NS or CF types. (#128651)
Add a new WebKit checker for checking that lambda captures of CF types
use RetainPtr either when ARC is disabled or enabled, and those of NS
types use RetainPtr when ARC is disabled.
2025-03-09 14:59:46 -07:00
LLVM GN Syncbot
2e7a509237 [gn build] Port e85e29c2992b 2025-03-09 21:10:04 +00:00
Jakub Kuderski
9764659fb4
[ADT] Use adl_being/end in hasSingleElement (#130506)
This is to make sure that ADT helpers consistently use argument
dependent lookup when dealing with input ranges.

This was a part of #87936 but reverted due to buildbot failures. Now
that I have a threadripper system, I'm landing this piece-by-piece.
2025-03-09 17:08:08 -04:00
Chris B
e85e29c299
[HLSL] select scalar overloads for vector conditions (#129396)
This PR adds scalar/vector overloads for vector conditions to the
`select` builtin, and updates the sema checking and codegen to allow
scalars to extend to vectors.

Fixes #126570
2025-03-09 16:01:12 -05:00
Craig Topper
74ca5799ca [X86] Use Register in FastISel. NFC
Replace 'Reg == 0' with '!Reg'
2025-03-09 12:06:47 -07:00
Adrian Prantl
2317a72489 [lldb] Add missing converstion to optional 2025-03-09 12:04:22 -07:00
Craig Topper
bd64f313a5 Recommit "[ARM] Change FastISel Address from a struct to a class. NFC"
With clang-format this time.

Original message:
This allows us to use Register in the interface, but store an
unsigned internally in a union.
2025-03-09 11:38:56 -07:00
Craig Topper
bc02802675 Revert "[ARM] Change FastISel Address from a struct to a class. NFC"
This reverts commit d47bc6fd93f9f439a54fd7cf55cdcb2e2ca0cfcb.

I forgot to commit clang-format cleanup before I pushed this.
2025-03-09 11:37:47 -07:00
Artem Pianykh
29129be632
[NFC][Cloning] Add a helper to collect debug info from instructions (#129145)
Summary:
Just moving around. This helper will be used for further refactoring.

Test Plan:
ninja check-llvm-unit check-llvm
2025-03-09 18:35:42 +00:00
Florian Hahn
437d587e48
[LV] Add outer loop test with different successor orders in inner latch. 2025-03-09 18:13:06 +00:00
David Green
e44e24dfe6
[AArch64] Improve vector funnel shift by constant costs. (#130044)
We now have better codegen, and can have better costs to match. The
generated code should now produce a shl+usra and can be seen in
testcases such as:
7e5821bae8/llvm/test/CodeGen/AArch64/fsh.ll (L3941).
2025-03-09 18:01:45 +00:00
Mariusz Borsa
62a6d63d63
[Sanitizers][Darwin] Correct iterating of MachO load commands (#130161)
The condition to stop iterating so far was to look for load command cmd
field == 0. The iteration would continue past the commands area, and
would finally find lc->cmd ==0, if lucky. Or crash with bus error, if
out of luck.

Correcting this by limiting the number of iterations to the count
specified in mach_header(_64) ncmds field.

rdar://143903403

---------

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2025-03-09 10:58:46 -07:00
Artem Pianykh
df570dadcb
[NFC][Cloning] Simplify the flow in FindDebugInfoToIdentityMap (#129144)
Summary:
The new flow should make it more clear what is happening in cases of
Different of Cloned modules.

Test Plan:
ninja check-llvm-unit check-llvm
2025-03-09 17:49:24 +00:00
Chris B
a7d5b3f711
[HLSL] Disallow virtual inheritance and functions (#127346)
This PR disallows virtual inheritance and virtual functions in HLSL.
2025-03-09 12:18:44 -05:00
Mark de Wever
b6bb9dc5ab
[libc++][CI] Update action runner base image. (#130433)
Updates to the latest release. The side effect of this change is
updating all compilers to the latest upstream version.
2025-03-09 17:36:10 +01:00
Mark de Wever
fd973d2512
[libc++] Protect more code against -Wdeprecated. (#130419)
This seems needed when updating the CI Docker image.
2025-03-09 17:33:59 +01:00
Artem Pianykh
7c4ef498e1
[NFC][Cloning] Make ClonedModule case more obvious in CollectDebugInfoForCloning (#129143)
Summary:
The code's behavior is unchanged, but it's more obvious right now.

Test Plan:
ninja check-llvm-unit check-llvm
2025-03-09 15:49:04 +00:00
LLVM GN Syncbot
3a727549ef [gn build] Port fd267082ee6d 2025-03-09 15:06:16 +00:00
Florian Hahn
fd267082ee
[VPlan] Refactor VPlan creation, add transform introducing region (NFC). (#128419)
Create an empty VPlan first, then let the HCFG builder create a plain
CFG for the top-level loop (w/o a top-level region). The top-level
region is introduced by a separate VPlan-transform. This is instead of
creating the vector loop region before building the VPlan CFG for the
input loop.

This simplifies the HCFG builder (which should probably be renamed) and
moves along the roadmap ('buildLoop') outlined in [1].

As follow-up, I plan to also preserve the exit branches in the initial
VPlan out of the CFG builder, including connections to the exit blocks.

The conversion from plain CFG with potentially multiple exits to a
single entry/exit region will be done as VPlan transform in a follow-up.

This is needed to enable VPlan-based predication. Currently early exit
support relies on building the block-in masks on the original CFG,
because exiting branches and conditions aren't preserved in the VPlan.
So in order to switch to VPlan-based predication, we will have to
preserve them in the initial plain CFG, so the exit conditions are
available explicitly when we convert to single entry/exit regions.

Another follow-up is updating the outer loop handling to also introduce
VPRegionBlocks for nested loops as transform. Currently the existing
logic in the builder will take care of creating VPRegionBlocks for
nested loops, but not the top-level loop.

[1]
https://llvm.org/devmtg/2023-10/slides/techtalks/Hahn-VPlan-StatusUpdateAndRoadmap.pdf

PR: https://github.com/llvm/llvm-project/pull/128419
2025-03-09 15:05:35 +00:00
Nico Weber
f3dd9c99d1 Revert "[lld][LoongArch] Relax call36/tail36: R_LARCH_CALL36 (#123576)"
This reverts commit 6fbe491e1776f6598790a844bf4e743de956b42d.
Broke check-lld, see the many bot comments on
https://github.com/llvm/llvm-project/pull/123576
2025-03-09 10:19:16 -04:00
Yingwei Zheng
029e10289a
[ValueTracking] Bail out on x86_fp80 when computing fpclass with knownbits (#130477)
In https://github.com/llvm/llvm-project/pull/97762, we assume the
minimum possible value of X is NaN implies X is NaN. But it doesn't hold
for x86_fp80 format. If the knownbits of X are
`?'011111111111110'????????????????????????????????????????????????????????????????`,
the minimum possible value of X is NaN/unnormal. However, it can be a
normal value.

Closes https://github.com/llvm/llvm-project/issues/130408.
2025-03-09 21:10:35 +08:00
Phoebe Wang
107aa6a3d3
[X86] Combine bitcast(v1Ty insert_vector_elt(X, Y, 0)) to Y (#130475)
Though it only happens in v1i1 when we generate llvm.masked.load/store
intrinsics for APX cload/cstore.

https://godbolt.org/z/vjsrofsqx
2025-03-09 20:10:08 +08:00
Andrewyuan34
2a3e782f40
[clang-tidy] Fix invalid fixit from modernize-use-ranges for nullptr used with std::unique_ptr (#127162)
This PR fixes issue #124815 by correcting the handling of `nullptr` with
`std::unique_ptr` in the `modernize-use-ranges` check.

Updated the logic to suppress warnings for `nullptr` in `std::find`.
2025-03-09 20:09:59 +08:00
Simon Pilgrim
22a45c43db [X86] combineConcatVectorOps - use all_of to check for matching PSHUFD/PSHUFLW/PSHUFHW shuffle mask.
Prep work before adding 512-bit support.
2025-03-09 12:04:39 +00:00
Timm Baeder
0f732481ac
[clang][bytecode] Fix getting pointer element type in __builtin_memcmp (#130485)
When such a pointer is heap allocated, the type we get is a pointer
type. Take the pointee type in that case.
2025-03-09 12:57:42 +01:00
Simon Pilgrim
d84dc8ff93
[InstCombine] Add handling for (or (zext x), (shl (zext (ashr x, bw/2-1))), bw/2) -> (sext x) fold (#130316)
Minor tweak to #129363 which handled all the cases where there was a sext for the original source value, but not for cases where the source is already half the size of the destination type

Another regression noticed in #76524
2025-03-09 10:34:30 +00:00
Zhaoxin Yang
6fbe491e17
[lld][LoongArch] Relax call36/tail36: R_LARCH_CALL36 (#123576)
Instructions with relocation `R_LARCH_CALL36` may be relax as follows:
```
From:
   pcaddu18i $dest, %call36(foo)
     R_LARCH_CALL36, R_LARCH_RELAX
   jirl $r, $dest, 0
To:
   b/bl foo  # bl if r=$ra, b if r=$zero
     R_LARCH_B26
```
2025-03-09 17:21:27 +08:00
Kazu Hirata
99d2b3b0aa
[llvm-profgen] Avoid repeated hash lookups (NFC) (#130466) 2025-03-09 00:49:37 -08:00
Kazu Hirata
573df34ea0
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#130465) 2025-03-09 00:49:13 -08:00