525794 Commits

Author SHA1 Message Date
Takuto Ikuta
424c2d9b7e [libcxx] Add a missing include for __bit_iterator (#127015)
This is to fix compile error with explicit Clang modules like
```
../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required
   85 |   typedef __bit_iterator<vector, false> pointer;
      |           ^
../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable
   23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
      |                                                                    ^
```

(cherry picked from commit 672e3858a4e4b9e155adb72426074ea2af0dd922)
llvmorg-20.1.1
2025-03-18 16:15:15 -07:00
Yingwei Zheng
2cc53628fb [SCEV] Check whether the start is non-zero in ScalarEvolution::howFarToZero (#131522)
https://github.com/llvm/llvm-project/pull/94525 assumes that the loop
will be infinite when the stride is zero. However, it doesn't hold when
the start value of addrec is also zero.

Closes https://github.com/llvm/llvm-project/issues/131465.

(cherry picked from commit c5a491e9ea22014b65664b6e09134b4f055933e2)
2025-03-18 15:59:51 -07:00
yonghong-song
0619bbcbbd
[BPF] Add default cpu change in ReleaseNotes (#131691)
The pull request [1] changed bpf default cpu from -mcpu=v1 to
-mcpu=v3 in clang20. Recently in [1], Yuval Deutscher suggested
to add an entry to clang20 ReleaseNotes so users can easily find
the change from documentation.

  [1] https://github.com/llvm/llvm-project/pull/107008

Co-authored-by: Yonghong Song <yonghong.song@linux.dev>
2025-03-18 15:41:30 -07:00
Corentin Jabot
2dc152fb40 fix abi (again) 2025-03-18 15:39:47 -07:00
Corentin Jabot
2044b18af0 fix abi 2025-03-18 15:39:47 -07:00
cor3ntin
e3f0ce3ef8 [Clang] Do not emit nodiscard warnings for the base expr of static member access (#131450)
For an expression `nodiscard_function().static_member(), the nodiscard
warnings added by #120223, are not useful or actionable, and are
disruptive to some library implementations; we just remove them.

Fixes #131410

(cherry picked from commit 9a1e39062b2ab445f1f4424ecdc5ffb46e8cb9e0)
2025-03-18 15:39:47 -07:00
Yaxun (Sam) Liu
0ceb4efefe [CUDA][HIP] fix virtual dtor host/device attr (#128926)
When inferring host device attr of virtual dtor of explicit
template class instantiation, clang should be conservative.
This guarantees dtors that may call host functions not to
have implicit device attr, therefore will not be emitted
on device side.

Backports: 0f0665db067f d37a39207bc1

Fixes: #108548
2025-03-18 14:14:50 -07:00
A. Jiang
1058e693f0 [libc++][test] Skip a is_virtual_base_of test for apple-clang-17 (#131438)
It seems that Apple Clang 17 starts to be used for CI, while it hasn't
supported `__builtin_is_virtual_base_of` yet. And thus we need to skip
the test for `is_virtual_base_of`.

Follows up #131302.
2025-03-18 13:55:00 -07:00
Louis Dionne
1f9d00524b [libc++] Forward-proof some tests for AppleClang 17 2025-03-18 13:55:00 -07:00
Florian Hahn
1515c4ac20 [LAA] Consider accessed addrspace when mapping underlying obj to access. (#129087)
In some cases, it is possible for the same underlying object to be
accessed via pointers to different address spaces. This could lead to
pointers from different address spaces ending up in the same dependency
set, which isn't allowed (and triggers an assertion).

Update the mapping from underlying object -> last access to also include
the accessing address space.

Fixes https://github.com/llvm/llvm-project/issues/124759.

PR: https://github.com/llvm/llvm-project/pull/129087
2025-03-18 13:46:42 -07:00
Younan Zhang
1cfbb9f334 Backport/20.x: [Clang] Fix an incorrect assumption on getTemplatedDecl()
This backports d9110858ee because it fixes a regression introduced in 19
and we don't want it to persist in 20
2025-03-18 12:54:25 +08:00
yonghong-song
0fcfeacd8b [BPF] Fix BitCast Assertion with NonZero AddrSpace
Alexei reported a bpf selftest failure with recent llvm for bpf prog
file progs/arena_spin_lock.c. The failure only happens when clang is
built with cmake option LLVM_ENABLE_ASSERTIONS=ON.

The error message looks like:
```
 clang: /home/yhs/work/yhs/llvm-project/llvm/lib/IR/Instructions.cpp:3460:
   llvm::BitCastInst::BitCastInst(Value *, Type *, const Twine &, InsertPosition):
   Assertion `castIsValid(getOpcode(), S, Ty) && "Illegal BitCast"' failed.
```
Further investigation shows that the problem is triggered in
  BPF/BPFAbstractMemberAccess.cpp
for code
```
  auto *BCInst =
      new BitCastInst(Base, PointerType::getUnqual(BB->getContext()));
```
For the above BitCastInst, Since 'Base' has non-zero AddrSapce, the
compiler expects the type also has the same AddrSpace. But the above
PointerType::getUnqual(...) does not have AddrSpace and hence causes the
assertion failure.

Providing the proper AddrSpace for the BitCast type fixed the issue.

Co-authored-by: Yonghong Song <yonghong.song@linux.dev>
(cherry picked from commit 5686786c550c6da6d1169b9bffc31cece1161902)
2025-03-17 16:19:38 -07:00
higher-performance
0b23d98dce Reduce memory usage in AST parent map generation by lazily checking if nodes have been seen (#129934)
This mitigates a regression introduced in #87824.

The mitigation here is to store pointers the deduplicated AST nodes, rather than copies of the nodes themselves. This allows a pointer-optimized set to be used and saves a lot of memory because `clang::DynTypedNode` is ~5 times larger than a pointer.

Fixes #129808.

(cherry picked from commit 8c7f0eaa6ee3f84e3d8260535cced234bed4fa28)
2025-03-17 14:46:32 -07:00
Matt Arsenault
073ae08864
AMDGPU: Fix broken broken negative test for gfx950 assembler (#129667) (#129686)
Fix's not rejecting global_load_lds_dwordx3 and x4 on other targets.
The encoded versions of instructions should not touch
SubtargetPredicate,
and only AssemblerPredicate.
    
(cherry picked from commit f319a6546613d65661e1ad1ef1a2a648cefee84b)
2025-03-17 12:50:18 -07:00
Daniel Rodríguez Troitiño
cb50aaf8a1 [llvm-objcopy] Apply encryptable offset to first segment, not section (#130517)
Bug introduced #120995. The LLD code calculates the "size" of the Mach-O
headers, and then uses that size to place the segments, but the `__TEXT`
section stays at `fileoff` zero. When I wrote the code into llvm-objcopy
I calculated the extra space into the initial offset, which moved all
the sections back 1 page.

Besides the modified test checking for the right `fileoff` values of the
sections and the segments, I also manually checked the generated
binaries after `llvm-objcopy` using `dyld_info`, as the bug report
suggested.

Fixes #130472

(cherry picked from commit 8413f4d837a96458104f63bab72c751b8285a458)
2025-03-14 21:45:15 +00:00
Younan Zhang
63e63f3061 [Clang] Fix an integer overflow issue in computing CTAD's parameter depth (#128704)
Backports b8d1f3d62.

This fixes a potential integer overflow bug that has been around for
many versions and was exposed by my patch recently. So we think it
warrants a backport
2025-03-13 10:25:51 -07:00
Nikita Popov
b09b05b8e7 [MemCpyOpt] Fix clobber check in fca2memcpy optimization
This effectively reverts #108535. The old AA code was looking for
the *first* clobber between the load and store and then trying to
move all the way up there. The new MSSA based code instead found
the *last* clobber. There might still be an earlier clobber that
has not been accounted for.

Fixes #130632.

(cherry picked from commit 5da9044c40840187330526ca888290a95927a629)
2025-03-13 10:23:43 -07:00
Jonas Paulsson
64ae641355 [SystemZ] Move disabling of arg verification to before isFullyInternal(). (#130693)
It has found to be quite a slowdown to traverse the users of a
function from each call site when it is called many (~70k)
times. This patch fixes this for now as long as this verification
is disabled by default, but there is still a need to eventually
cache the results to avoid recomputation.

Fixes #130541

(cherry picked from commit 378739f18208165f9831571a57f34d82f6663bc6)
2025-03-12 17:50:33 +00:00
Simon Pilgrim
548d057ebc [VectorCombine] scalarizeLoadExtract - don't create scalar loads if any extract is waiting to be erased (#129375)
If any extract is waiting to be erased, then bail out as this will distort the cost calculation and possibly lead to infinite loops.

Fixes #129373

(cherry picked from commit 5ddf40fa78705384966c22da78e12134df7bd723)
2025-03-11 17:14:40 -07:00
Joseph Huber
7c154dad4d [Clang] Fix GPU intrinsic helpers incorrectly sign extending (#129560)
Summary:
These return values are actually signed, meaning that casting will
extend it and then all the bits will be one.

(cherry picked from commit 4ca8ea8c972ae05a891687eda6704ec607184fae)
2025-03-11 17:13:45 -07:00
Paul Osmialowski
946780474f [libc++][test] extend XFAIL clauses to cover Amazon Linux too (#129377)
The default triple of Amazon Linux on AArch64 is aarch64-amazon-linux,
see issue highlighded by PR #109263, somewhat serious linker issues are
encountered if any other triple is being used.

Unfortunately, this makes XFAIL lines like
`XFAIL: target=aarch64{{.*}}-linux-gnu` ineffective, making it
impossible to complete all of the check-cxx on Amazon Linux without
failing.

(cherry picked from commit 8f4ee42d59976a9343d7576ef9a1fe2cf482a057)
2025-03-11 17:12:48 -07:00
Lu Weining
f09bcfbdc9 [LoongArch] Relax the restrictions of inlineasm operand modifier 'u' and 'w' (#129864)
- Allow 'u' and 'w' on LASX, LSX or floating point register operands.
- Also add missing description in LangRef.

Fixes #129863.

(cherry picked from commit bae6644e1227b2555f92b1962dac6c2444eaaaf2)
2025-03-11 17:09:56 -07:00
DianQK
f62b50e0e8 [ValueTracking] Skip incoming values that are the same as the phi in isGuaranteedNotToBeUndefOrPoison (#130111)
Fixes (keep it open) #130110.

If the incoming value is PHI itself, we can skip this. If we can
guarantee that the other incoming values are neither undef nor poison,
then we can also guarantee that the value isn't either. If we cannot
guarantee that, it makes no sense in calculating it.

(cherry picked from commit 462eb7e28ef4507b16a4b45efb356bc6a3523615)
2025-03-11 17:09:10 -07:00
aankit-ca
50343e5179 [HEXAGON] Fix hvx-isel for extract_subvector op (#129672)
Fixes a crash with extract_subvectors in Hexagon backend seen when the
source vector is a vector-pair and result vector is not hvx vector size.

LLVM Issue: https://github.com/llvm/llvm-project/issues/128775
Fixes #128775
---------

Co-authored-by: aankit-quic <aankit@quicinc.com>
(cherry picked from commit 29d3fc3f11d272a72ac255af9277c740f26c3dfc)
2025-03-11 17:08:06 -07:00
DianQK
0412f708c3 [TailDuplicator] Do not restrict the computed gotos (#114990)
Fixes #106846.

This is what I learned from GCC. I found that GCC does not duplicate the
BB that has indirect jumps with the jump table. I believe GCC has
provided a clear explanation here:

> Duplicate the blocks containing computed gotos. This basically
unfactors computed gotos that were factored early on in the compilation
process to speed up edge based data flow. We used to not unfactor them
again, which can seriously pessimize code with many computed jumps in
the source code, such as interpreters.

(cherry picked from commit dd21aacd76e36d4db157a5d7a7b5370d456426e6)
2025-03-11 14:02:51 -07:00
David Spickett
72c4a3f419 [clang][test] Don't require specific alignment in test case (#130589)
https://github.com/llvm/llvm-project/pull/129952 /
42d49a77241df73a17cb442973702fc460e7fb90 added this test which is
failing on 32-bit ARM because the alignment chosen is 4 not 8. Which
would make sense if this is a 32/64 bit difference

https://lab.llvm.org/buildbot/#/builders/154/builds/13059
```
<stdin>:34:30: note: scanning from here
define dso_local void @_Z1fv(ptr dead_on_unwind noalias writable sret(%struct.B) align 4 %agg.result) #0 {
                             ^
<stdin>:38:2: note: possible intended match here
 %0 = load ptr, ptr @x, align 4
 ^
```
The other test does not check alignment, so I'm assuming that it is not
important here.
2025-03-11 14:01:29 -07:00
Eli Friedman
fbb2a7e74d [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-11 14:01:29 -07:00
Yingwei Zheng
9010db1b84 [Clang] Treat constexpr-unknown value as invalid in EvaluateAsInitializer (#128409)
It is an alternative to
https://github.com/llvm/llvm-project/pull/127525.
Close https://github.com/llvm/llvm-project/issues/127475.
2025-03-11 14:01:29 -07:00
David Green
32ce5b043c [AArch64] Fix BE popcount casts. (#129879)
A bitcast, being defined as a load and a store, can change the lane
order. We need to use a NVCAST instead to keep the lanes out of the
VADDV the same in big-endian. The extracting from a v2i64 vector is
to keep the types of the nvcast legal, but also allow us to replace a
lane mov with a mov 0.

Fixes #129843

(cherry picked from commit ab811e75734a77247dae6df1579fa6f29394f200)
2025-03-11 13:52:07 -07:00
David Green
05be3ca72e [AArch64] Add BE test coverage for popcount. NFC
For #129843

(cherry picked from commit b673a59c9ae5583aa08a8d34a48f9409b660d826)
2025-03-11 13:52:07 -07:00
Yingwei Zheng
0e96713a3b [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.

(cherry picked from commit 029e10289a02b438f1a22f401c94ed60ab4bb704)
2025-03-11 13:51:06 -07:00
Phoebe Wang
0fda7e6332 [X86][AVX10.2] Fix unexpected larger scope (#130767)
https://godbolt.org/z/oM6bcqEnr
(cherry picked from commit fcce3084cb43a12f2e6e19b8e5b655f3df8739d6)
2025-03-11 13:49:56 -07:00
Owen Pan
f7a4e3a4d4 [clang-format] Don't remove parentheses separated from ellipsis by comma (#130471)
Also clean up `case tok::r_paren` in
`UnwrappedLineParser::parseParens()`.

Fix #130359

(cherry picked from commit 7d4d8509cbec7eecd8aaf2510015b54bc5c173e1)
2025-03-11 13:47:19 -07:00
David Green
1d4d84c89b [AArch64] Don't try to custom lower fp16 selects with nofp (#129492)
If we do not have fp then we do not need to try and custom lower fp16
selects.

Fixes #129394.

(cherry picked from commit cb850fef2a564ea330e8a4878fafb4f5b4a7a98e)
2025-03-11 13:44:48 -07:00
Yingwei Zheng
0064565bce [DAGCombiner] Don't ignore N2's undef elements in foldVSelectOfConstants (#129272)
Since N2 will be reused in the fold, we cannot skip N2's undef elements
if the corresponding element in N1 is well-defined.
For example:
```
t2: v4i32 = BUILD_VECTOR Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>
t24: v4i32 = BUILD_VECTOR undef:i32, undef:i32, Constant:i32<1>, undef:i32
t11: v4i32 = vselect t8, t2, t10
```
Before this patch, we fold t11 into:
```
t26: v4i32 = sign_extend t8
t27: v4i32 = add t26, t24
```
The last element of t27 is incorrect.

Closes https://github.com/llvm/llvm-project/issues/129181.

(cherry picked from commit 2709366f75b054e2cba4f61310de5a9605f4aa24)
2025-03-11 13:42:26 -07:00
Jordan R AW
54c90e4cdf [lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245)
(cherry picked from commit bb6a273d9ab9ee90dbb957e541f4d810fffb22ee)
2025-03-11 13:41:08 -07:00
Jordan R AW
712d3c7f09 [lldb] Add terminfo dependency for ncurses support (#126810)
For some operating systems (e.g. chromiumos), terminfo is a separate
package and library from ncurses. Both are still requirements for curses
support in lldb, individually.

This is a rework of this original spack commit:

9ea2612650

Instead though, this PR uses CMake to detect whether the symbol is
present and defined in the curses library, and only falls back to a separate
tinfo if not found.

Without this fix, LLDB cannot be built on these systems.

Fixes #101368

(cherry picked from commit 8fff0c181f26a5e8b2344c061ebf2559118b1160)
2025-03-11 13:41:08 -07:00
pkarveti
6525b151fe [Hexagon] Handle Call Operand vxi1 in Hexagon Backend (#128027)
This commit updates the Hexagon backend to handle
vxi1 call operands. It ensures compatibility for
vector types of sizes 4, 8, 16, 32, 64, and 128 x i1 when HVX is
enabled.

~Fixes #59009 and #118879~

(cherry picked from commit 37559c8401cf9236d561eebd75bd3d70be6ab723)
2025-03-11 13:37:00 -07:00
Louis Dionne
dcc378e862 [libc++] Guard <codecvt> contents on _LIBCPP_HAS_LOCALIZATION (#129112)
The codecvt class is defined in <locale> and the contents of the
<codecvt> header don't work when localization is disabled. Without this
guard, builds with localization disabled that happen to include
<codecvt> could be broken because they would try to include <__locale>,
which ends up trying to include the locale base API and eventually
platform headers like <xlocale.h> that may not exist.

(cherry picked from commit fda7373daf5790833101c504be1c749bbb0fceb8)
2025-03-11 13:26:09 -07:00
Jonathan Albrecht
0f5e7e86e3 [SystemZ] Add header guard macros to vecintrin.h (#129170)
Add header guard macros to clang/lib/Headers/vecintrin.h. Found while
compiling the latest numpy with clang 19 on s390x which ends up
including vecintrin.h twice. The gcc version of this file has header
guards so numpy compiles fine with gcc.

Signed-off-by: Jonathan Albrecht <jonathan.albrecht@ibm.com>
(cherry picked from commit ddaa5b3bfb2980f79c6f277608ad33a6efe8d554)
2025-03-11 13:24:25 -07:00
Elvis Wang
5b552d780a [LV][VPlan] Prevent calculate cost for skiped instructions in precomputeCosts(). (#127966)
Skip calculating instruction costs for exit conditions in
precomputeCosts() when it should be skipped.

Reported from:
https://github.com/llvm/llvm-project/issues/115744#issuecomment-2670479463
Godbolt for reduced test cases: https://godbolt.org/z/fr4YMeqcv

(cherry picked from commit 8009c1fd81ad0b6ac65724d2b134a92db48f8fbf)
2025-03-11 13:14:52 -07:00
Martin Storsjö
20adce8710 [libc++][ci] Update the Windows toolchains to Clang 19 (#129232)
This also fixes test failures in the clang-cl build configs that started
a couple days ago. It seems like the failures were triggered by an update
to the base image on the Github provided runners.

There were failures in test/libcxx/system_reserved_names.gen.py, due to
an issue in an Clang intrinsics header (avx512fp16intrin.h); this issue
was observed and fixed for Clang 19 in 6f04f46927c. The test does
    #define A SYSTEM_RESERVED_NAME
which clashes with a parameter with the name `A` in that header.

By upgrading the toolchain to Clang 19, we get fixed version of this
intrinsics header.

Also update the llvm-mingw toolchains to a version with Clang 19.1.7.

(cherry picked from commit e6a0ee3d1d12c9c02c1a361109e282d18dd2430c)
2025-03-11 12:58:47 -07:00
Tom Stellard
0e537474ea
Bump version to 20.1.1 (#130806) 2025-03-11 12:58:18 -07:00
Tom Stellard
24a30daaa5 Bump version to 20.1.0 (final) llvmorg-20.1.0 2025-03-04 11:51:43 -08:00
Nathan Ridge
794ba171a4
[clangd] Add clangd 20 release notes (#127358) 2025-03-04 07:01:18 -08:00
Owen Pan
f88a294673 [clang-format] Fix a bug that changes keyword or to an identifier (#128410)
Backports ffc61dc393e4 0968df9c3a55 2d585ccecc45

Fixes #105482
2025-03-04 06:59:18 -08:00
Tom Stellard
b23c3cc933 workflows/release-binaries: Fix macos-14 build (#127157)
This was broken when pgo was enabled by
0572580dd040a81dc69b798e202550d51d17204a.

(cherry picked from commit d595d5a770d93c9564268fc631d85f3a6ce1f505)
2025-03-04 06:58:05 -08:00
Tom Stellard
83058aadee workflows/release-binaries-all: Add missing secret input (#126921)
Since d194c6b9a7fdda7a61abcd6bfe39ab465bf0cc87 this workflow was missing
the secret input which was causing it to fail.

(cherry picked from commit a684e0ea57ebb93c81506c066afb25cb496dcc11)
2025-02-26 14:50:42 +00:00
Tom Stellard
a69568efe6 Bump version to 20.1.0-rc3 llvmorg-20.1.0-rc3 2025-02-25 18:02:43 -08:00
Tom Stellard
560ac756cb [CMake][Release] Statically link ZSTD on all OSes (#128554)
This will make the binaries more portable.

(cherry picked from commit 09832777d830e0fddff84bf36793ec4e453656b0)
2025-02-25 17:08:20 -08:00