Update to LLVM 22.1.8

This also removes the compatibility libraries.

Bugs fixed by this release:
---------------------------

Resolves: RHEL-165049
s390x data corruption after `concat_vectors(trunc(scalar), undef)`

Resolves: RHEL-171564
clang-22 crashes when building systemd

Backported fixes from LLVM 23:
------------------------------

Resolves: RHEL-210749
Backport important fixes from upstream [rhel-10]

Housekeeping issues:
--------------------

Relates: RHEL-140398
[DEV Task]: Update LLVM Toolset to 22.1.8 [rhel-10]

Resolves: RHEL-140393
Update LLVM Toolset to 22.1.8 [rhel-10]

Resolves: RHEL-140389
Remove llvm21 compat package from the buildroot [rhel-10]

Relates: RHEL-140394
[DEV Task]: Remove llvm21 compat package from the buildroot [rhel-10]
This commit is contained in:
Konrad Kleine 2026-06-24 15:30:15 +02:00
parent 139ad2dd03
commit e9a7d3c404
20 changed files with 9226 additions and 853 deletions

View File

@ -1,9 +0,0 @@
# List of files and directories that are not needed on CentOS/RHEL.
/centos-sync.sh
/ci.fmf
/prepare-copr.sh
/tests/kernel-ark-build.fmf
/Makefile
/.copr
/.git-blame-ignore-revs
/.packit.yaml

View File

@ -1,26 +0,0 @@
From ffc7d5ae2d79f98967943fabb2abfbc1b1e047fd Mon Sep 17 00:00:00 2001
From: Douglas Yung <douglas.yung@sony.com>
Date: Tue, 24 Jun 2025 04:08:34 +0000
Subject: [PATCH] Add `REQUIRES: asserts` to test added in #145149 because it
uses the `-debug-only=` flag.
This should fix the test failure when building without asserts.
---
llvm/test/CodeGen/PowerPC/pr141642.ll | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/test/CodeGen/PowerPC/pr141642.ll b/llvm/test/CodeGen/PowerPC/pr141642.ll
index 38a706574786..61bda4dfaf53 100644
--- a/llvm/test/CodeGen/PowerPC/pr141642.ll
+++ b/llvm/test/CodeGen/PowerPC/pr141642.ll
@@ -2,6 +2,7 @@
; RUN: FileCheck %s
; CHECK-NOT: lxvdsx
; CHECK-NOT: LD_SPLAT
+; REQUIRES: asserts
define weak_odr dso_local void @unpack(ptr noalias noundef %packed_in) local_unnamed_addr {
entry:
--
2.49.0

View File

@ -1,131 +0,0 @@
From dde30a47313bf52fef02bbcb1de931a8d725659f Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo@fhahn.com>
Date: Fri, 6 Jun 2025 12:38:30 +0100
Subject: [PATCH] [CGP] Bail out if (Base|Scaled)Reg does not dominate insert
point. (#142949)
(Base|Scaled)Reg may not dominate the chosen insert point, if there are
multiple uses of the address. Bail out if that's the case, otherwise we
will generate invalid IR.
In some cases, we could probably adjust the insert point or hoist the
(Base|Scaled)Reg.
Fixes https://github.com/llvm/llvm-project/issues/142830.
PR: https://github.com/llvm/llvm-project/pull/142949
---
llvm/lib/CodeGen/CodeGenPrepare.cpp | 13 +++-
.../X86/sink-addrmode-reg-does-not-geps.ll | 76 +++++++++++++++++++
2 files changed, 87 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-reg-does-not-geps.ll
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 822ed6283117..32348a899683 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5945,8 +5945,17 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// The current BB may be optimized multiple times, we can't guarantee the
// reuse of Addr happens later, call findInsertPos to find an appropriate
// insert position.
- IRBuilder<> Builder(MemoryInst->getParent(),
- findInsertPos(Addr, MemoryInst, SunkAddr));
+ auto InsertPos = findInsertPos(Addr, MemoryInst, SunkAddr);
+
+ // TODO: Adjust insert point considering (Base|Scaled)Reg if possible.
+ if (!SunkAddr) {
+ auto &DT = getDT(*MemoryInst->getFunction());
+ if ((AddrMode.BaseReg && !DT.dominates(AddrMode.BaseReg, &*InsertPos)) ||
+ (AddrMode.ScaledReg && !DT.dominates(AddrMode.ScaledReg, &*InsertPos)))
+ return Modified;
+ }
+
+ IRBuilder<> Builder(MemoryInst->getParent(), InsertPos);
if (SunkAddr) {
LLVM_DEBUG(dbgs() << "CGP: Reusing nonlocal addrmode: " << AddrMode
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-reg-does-not-geps.ll b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-reg-does-not-geps.ll
new file mode 100644
index 000000000000..1640bafbd0bf
--- /dev/null
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-reg-does-not-geps.ll
@@ -0,0 +1,76 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux"
+
+declare i1 @cond(float)
+
+define void @scaled_reg_does_not_dominate_insert_point(ptr %src) {
+; CHECK-LABEL: define void @scaled_reg_does_not_dominate_insert_point(
+; CHECK-SAME: ptr [[SRC:%.*]]) {
+; CHECK-NEXT: [[BB:.*]]:
+; CHECK-NEXT: br label %[[LOOP:.*]]
+; CHECK: [[LOOP]]:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, %[[BB]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
+; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT: [[SUNKADDR2:%.*]] = mul i64 [[IV_NEXT]], 2
+; CHECK-NEXT: [[SUNKADDR3:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[SUNKADDR2]]
+; CHECK-NEXT: [[SUNKADDR4:%.*]] = getelementptr i8, ptr [[SUNKADDR3]], i64 6
+; CHECK-NEXT: [[L_0:%.*]] = load float, ptr [[SUNKADDR4]], align 4
+; CHECK-NEXT: [[SUNKADDR:%.*]] = mul i64 [[IV]], 2
+; CHECK-NEXT: [[SUNKADDR1:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[SUNKADDR]]
+; CHECK-NEXT: [[L_1:%.*]] = load float, ptr [[SUNKADDR1]], align 4
+; CHECK-NEXT: [[TMP0:%.*]] = call i1 @cond(float [[L_0]])
+; CHECK-NEXT: [[C:%.*]] = call i1 @cond(float [[L_1]])
+; CHECK-NEXT: br i1 [[C]], label %[[LOOP]], label %[[EXIT:.*]]
+; CHECK: [[EXIT]]:
+; CHECK-NEXT: ret void
+;
+bb:
+ %gep.base = getelementptr i8, ptr %src, i64 8
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %bb ], [ %iv.next, %loop ]
+ %iv.shl = shl i64 %iv, 1
+ %gep.shl = getelementptr i8, ptr %gep.base, i64 %iv.shl
+ %gep.sub = getelementptr i8, ptr %gep.shl, i64 -8
+ %iv.next = add i64 %iv, 1
+ %l.0 = load float, ptr %gep.shl, align 4
+ %l.1 = load float, ptr %gep.sub, align 4
+ call i1 @cond(float %l.0)
+ %c = call i1 @cond(float %l.1)
+ br i1 %c, label %loop, label %exit
+
+exit:
+ ret void
+}
+
+define void @check_dt_after_modifying_cfg(ptr %dst, i64 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: define void @check_dt_after_modifying_cfg(
+; CHECK-SAME: ptr [[DST:%.*]], i64 [[X:%.*]], i8 [[Y:%.*]], i8 [[Z:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT: [[OFFSET:%.*]] = lshr i64 [[X]], 2
+; CHECK-NEXT: [[SEL_FROZEN:%.*]] = freeze i8 [[Z]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[SEL_FROZEN]], 0
+; CHECK-NEXT: br i1 [[CMP]], label %[[SELECT_END:.*]], label %[[SELECT_FALSE_SINK:.*]]
+; CHECK: [[SELECT_FALSE_SINK]]:
+; CHECK-NEXT: [[SMIN:%.*]] = tail call i8 @llvm.smin.i8(i8 [[Y]], i8 0)
+; CHECK-NEXT: br label %[[SELECT_END]]
+; CHECK: [[SELECT_END]]:
+; CHECK-NEXT: [[SEL:%.*]] = phi i8 [ 0, %[[ENTRY]] ], [ [[SMIN]], %[[SELECT_FALSE_SINK]] ]
+; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[DST]], i64 [[OFFSET]]
+; CHECK-NEXT: store i8 [[SEL]], ptr [[SUNKADDR]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ %offset = lshr i64 %x, 2
+ %gep.dst = getelementptr i8, ptr %dst, i64 %offset
+ %smin = tail call i8 @llvm.smin.i8(i8 %y, i8 0)
+ %cmp = icmp slt i8 %z, 0
+ %sel = select i1 %cmp, i8 0, i8 %smin
+ store i8 %sel, ptr %gep.dst, align 1
+ ret void
+}
+
+declare i8 @llvm.smin.i8(i8, i8) #0
--
2.50.1

View File

@ -1,143 +0,0 @@
From c76137f1cfd5758f6889236d49a65f059e6432ff Mon Sep 17 00:00:00 2001
From: weiguozhi <57237827+weiguozhi@users.noreply.github.com>
Date: Thu, 15 May 2025 09:27:25 -0700
Subject: [PATCH] [CodeGenPrepare] Make sure instruction get from SunkAddrs is
before MemoryInst (#139303)
Function optimizeBlock may do optimizations on a block for multiple
times. In the first iteration of the loop, MemoryInst1 may generate a
sunk instruction and store it into SunkAddrs. In the second iteration of
the loop, MemoryInst2 may use the same address and then it can reuse the
sunk instruction stored in SunkAddrs, but MemoryInst2 may be before
MemoryInst1 and the corresponding sunk instruction. In order to avoid
use before def error, we need to find appropriate insert position for the
sunk instruction.
Fixes #138208.
(cherry picked from commit 59c6d70ed8120b8864e5f796e2bf3de5518a0ef0)
---
llvm/lib/CodeGen/CodeGenPrepare.cpp | 41 ++++++++++++++---
.../CodeGenPrepare/X86/sink-addr-reuse.ll | 44 +++++++++++++++++++
2 files changed, 80 insertions(+), 5 deletions(-)
create mode 100644 llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 088062afab17..f779f4b782ae 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5728,6 +5728,35 @@ static bool IsNonLocalValue(Value *V, BasicBlock *BB) {
return false;
}
+// Find an insert position of Addr for MemoryInst. We can't guarantee MemoryInst
+// is the first instruction that will use Addr. So we need to find the first
+// user of Addr in current BB.
+static BasicBlock::iterator findInsertPos(Value *Addr, Instruction *MemoryInst,
+ Value *SunkAddr) {
+ if (Addr->hasOneUse())
+ return MemoryInst->getIterator();
+
+ // We already have a SunkAddr in current BB, but we may need to insert cast
+ // instruction after it.
+ if (SunkAddr) {
+ if (Instruction *AddrInst = dyn_cast<Instruction>(SunkAddr))
+ return std::next(AddrInst->getIterator());
+ }
+
+ // Find the first user of Addr in current BB.
+ Instruction *Earliest = MemoryInst;
+ for (User *U : Addr->users()) {
+ Instruction *UserInst = dyn_cast<Instruction>(U);
+ if (UserInst && UserInst->getParent() == MemoryInst->getParent()) {
+ if (isa<PHINode>(UserInst) || UserInst->isDebugOrPseudoInst())
+ continue;
+ if (UserInst->comesBefore(Earliest))
+ Earliest = UserInst;
+ }
+ }
+ return Earliest->getIterator();
+}
+
/// Sink addressing mode computation immediate before MemoryInst if doing so
/// can be done without increasing register pressure. The need for the
/// register pressure constraint means this can end up being an all or nothing
@@ -5852,11 +5881,6 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
return Modified;
}
- // Insert this computation right after this user. Since our caller is
- // scanning from the top of the BB to the bottom, reuse of the expr are
- // guaranteed to happen later.
- IRBuilder<> Builder(MemoryInst);
-
// Now that we determined the addressing expression we want to use and know
// that we have to sink it into this block. Check to see if we have already
// done this for some other load/store instr in this block. If so, reuse
@@ -5867,6 +5891,13 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
Value *SunkAddr = SunkAddrVH.pointsToAliveValue() ? SunkAddrVH : nullptr;
Type *IntPtrTy = DL->getIntPtrType(Addr->getType());
+
+ // The current BB may be optimized multiple times, we can't guarantee the
+ // reuse of Addr happens later, call findInsertPos to find an appropriate
+ // insert position.
+ IRBuilder<> Builder(MemoryInst->getParent(),
+ findInsertPos(Addr, MemoryInst, SunkAddr));
+
if (SunkAddr) {
LLVM_DEBUG(dbgs() << "CGP: Reusing nonlocal addrmode: " << AddrMode
<< " for " << *MemoryInst << "\n");
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll
new file mode 100644
index 000000000000..019f31140655
--- /dev/null
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-reuse.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -p 'require<profile-summary>,codegenprepare' -cgpp-huge-func=0 < %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+declare void @g(ptr)
+
+; %load and %load5 use the same address, %load5 is optimized first, %load is
+; optimized later and reuse the same address computation instruction. We must
+; make sure not to generate use before def error.
+
+define void @f(ptr %arg) {
+; CHECK-LABEL: define void @f(
+; CHECK-SAME: ptr [[ARG:%.*]]) {
+; CHECK-NEXT: [[BB:.*:]]
+; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr i8, ptr [[ARG]], i64 -64
+; CHECK-NEXT: call void @g(ptr [[GETELEMENTPTR]])
+; CHECK-NEXT: [[SUNKADDR1:%.*]] = getelementptr i8, ptr [[ARG]], i64 -64
+; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[SUNKADDR1]], align 8
+; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[ARG]], i64 -56
+; CHECK-NEXT: [[LOAD4:%.*]] = load i32, ptr [[SUNKADDR]], align 8
+; CHECK-NEXT: [[LOAD5:%.*]] = load ptr, ptr [[SUNKADDR1]], align 8
+; CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 1, i32 0)
+; CHECK-NEXT: [[MATH:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
+; CHECK-NEXT: ret void
+;
+bb:
+ %getelementptr = getelementptr i8, ptr %arg, i64 -64
+ %getelementptr1 = getelementptr i8, ptr %arg, i64 -56
+ call void @g(ptr %getelementptr)
+ br label %bb3
+
+bb3:
+ %load = load ptr, ptr %getelementptr, align 8
+ %load4 = load i32, ptr %getelementptr1, align 8
+ %load5 = load ptr, ptr %getelementptr, align 8
+ %add = add i32 1, 0
+ %icmp = icmp eq i32 %add, 0
+ br i1 %icmp, label %bb7, label %bb7
+
+bb7:
+ ret void
+}
--
2.49.0

View File

@ -0,0 +1,47 @@
From e710ff28456c1accbeb3a7e503163233bc615b16 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Wed, 11 Feb 2026 21:23:34 -0800
Subject: [PATCH] [ELF] Simplify AArch64::relocateAlloc. NFC
---
lld/ELF/Arch/AArch64.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 55434ae2151c..3c0d4ca64555 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -931,9 +931,10 @@ static bool needsGotForMemtag(const Relocation &rel) {
void AArch64::relocateAlloc(InputSection &sec, uint8_t *buf) const {
uint64_t secAddr = sec.getOutputSection()->addr + sec.outSecOff;
- AArch64Relaxer relaxer(ctx, sec.relocs());
- for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) {
- const Relocation &rel = sec.relocs()[i];
+ const ArrayRef<Relocation> relocs = sec.relocs();
+ AArch64Relaxer relaxer(ctx, relocs);
+ for (size_t i = 0, size = relocs.size(); i != size; ++i) {
+ const Relocation &rel = relocs[i];
if (rel.expr == R_NONE) // See finalizeAddressDependentContent()
continue;
uint8_t *loc = buf + rel.offset;
@@ -947,14 +948,14 @@ void AArch64::relocateAlloc(InputSection &sec, uint8_t *buf) const {
switch (rel.expr) {
case RE_AARCH64_GOT_PAGE_PC:
if (i + 1 < size &&
- relaxer.tryRelaxAdrpLdr(rel, sec.relocs()[i + 1], secAddr, buf)) {
+ relaxer.tryRelaxAdrpLdr(rel, relocs[i + 1], secAddr, buf)) {
++i;
continue;
}
break;
case RE_AARCH64_PAGE_PC:
if (i + 1 < size &&
- relaxer.tryRelaxAdrpAdd(rel, sec.relocs()[i + 1], secAddr, buf)) {
+ relaxer.tryRelaxAdrpAdd(rel, relocs[i + 1], secAddr, buf)) {
++i;
continue;
}
--
2.50.1

View File

@ -0,0 +1,416 @@
From 8d590969badd9f3fed18a99fffbd9afdf3a975c6 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Fri, 10 Jul 2026 09:09:08 +0200
Subject: [PATCH] [LLD][AArch64] Make adrp+ldr relaxation per-symbol
all-or-nothing (#208396)
We can't relax only some adrp+ldr pairs for a symbol, because there may
be a branch target between the adrp and ldr of this form:
adrp x1, :got:sym
.Lfoo:
ldr x1, [x1, :got_lo12:sym]
# ...
adrp x1, :got:sym
ldr x2, [x1, :got_lo12:sym]
b .Lfoo
Relaxing the first adrp+ldr here would be invalid. This was clarified in
the ARM ABI in:
https://github.com/ARM-software/abi-aa/commit/11fb4ef42898060189d6a34ee96966e696ecbd20.
The implementation already performed a pre-scan to check that the
relevant relocations occur in pairs. Change this scan to a) check all
the preconditions for the relaxation and b) make the decision per
symbol.
Fixes https://github.com/llvm/llvm-project/issues/138254.
---
bolt/test/AArch64/got-load-symbolization.s | 11 ++-
bolt/test/AArch64/lite-mode.s | 17 +++--
lld/ELF/Arch/AArch64.cpp | 83 +++++++++++++--------
lld/test/ELF/aarch64-adrp-ldr-got.s | 84 +++++++++++++++++++---
4 files changed, 149 insertions(+), 46 deletions(-)
diff --git a/bolt/test/AArch64/got-load-symbolization.s b/bolt/test/AArch64/got-load-symbolization.s
index b4d682688758..399859fd7bfd 100644
--- a/bolt/test/AArch64/got-load-symbolization.s
+++ b/bolt/test/AArch64/got-load-symbolization.s
@@ -38,9 +38,9 @@ _start:
# CHECK-NEXT: adrp x2, __BOLT_got_zero
# CHECK-NEXT: nop
# CHECK-NEXT: ldr x2, [x2, :lo12:__BOLT_got_zero{{.*}}]
- adrp x2, :got:near
+ adrp x2, :got:near2
nop
- ldr x2, [x2, :got_lo12:near]
+ ldr x2, [x2, :got_lo12:near2]
## Load data object with local visibility. Relaxable into adrp+add.
# CHECK-NEXT: adrp x3, "local_far_data/1"
@@ -58,6 +58,7 @@ _start:
.size _start, .-_start
.weak near
+.weak near2
.weak far
.weak far_data
@@ -77,6 +78,12 @@ near:
ret
.size near, .-near
+ .globl near2
+ .type near2, @function
+near2:
+ ret
+.size near2, .-near2
+
#--- far.s
.text
diff --git a/bolt/test/AArch64/lite-mode.s b/bolt/test/AArch64/lite-mode.s
index f2d06219f7a2..24c31772b847 100644
--- a/bolt/test/AArch64/lite-mode.s
+++ b/bolt/test/AArch64/lite-mode.s
@@ -24,12 +24,12 @@
# CHECK-COMPACT-NOT: <_start.org.0>
## Verify that the number of FDEs matches the number of functions in the output
-## binary. There are three original functions and two optimized.
+## binary. There are four original functions and three optimized.
## NOTE: at the moment we are emitting extra FDEs for patched functions, thus
## there is one more FDE for _start.
# RUN: llvm-readelf -u %t.bolt | grep -wc FDE \
# RUN: | FileCheck --check-prefix=CHECK-FDE %s
-# CHECK-FDE: 6
+# CHECK-FDE: 8
## In lite mode, optimized code will be separated from the original .text by
## over 128MB, making it impossible for call/bl instructions in cold functions
@@ -106,9 +106,9 @@ cold_function:
# CHECK-NEXT: add x4
## Check that non-relaxable GOT load is left intact.
- adrp x5, :got:far_func
+ adrp x5, :got:far_func2
nop
- ldr x5, [x5, #:got_lo12:far_func]
+ ldr x5, [x5, #:got_lo12:far_func2]
# CHECK-INPUT-NEXT: adrp x5
# CHECK-INPUT-NEXT: nop
# CHECK-INPUT-NEXT: ldr x5
@@ -155,3 +155,12 @@ far_func:
ret x30
.cfi_endproc
.size far_func, .-far_func
+
+ .globl far_func2
+ .type far_func2, %function
+far_func2:
+# FDATA: 0 [unknown] 0 1 far_func2 0 0 100
+ .cfi_startproc
+ ret x30
+ .cfi_endproc
+ .size far_func2, .-far_func2
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index ed6d42fd4c05..11c3dca1a358 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -106,13 +106,17 @@ private:
struct AArch64Relaxer {
Ctx &ctx;
- bool safeToRelaxAdrpLdr = false;
+ SmallPtrSet<Symbol *, 32> unsafeToRelaxAdrpLdr;
- AArch64Relaxer(Ctx &ctx, ArrayRef<Relocation> relocs);
+ AArch64Relaxer(Ctx &ctx, ArrayRef<Relocation> relocs, uint64_t secAddr,
+ uint8_t *buf);
bool tryRelaxAdrpAdd(const Relocation &adrpRel, const Relocation &addRel,
uint64_t secAddr, uint8_t *buf) const;
bool tryRelaxAdrpLdr(const Relocation &adrpRel, const Relocation &ldrRel,
uint64_t secAddr, uint8_t *buf) const;
+ bool isLegalAdrpLdrRelaxationCandidate(const Relocation &adrpRel,
+ const Relocation &ldrRel,
+ uint64_t secAddr, uint8_t *buf) const;
};
} // namespace
@@ -896,26 +900,30 @@ void AArch64::relaxTlsIeToLe(uint8_t *loc, const Relocation &rel,
llvm_unreachable("invalid relocation for TLS IE to LE relaxation");
}
-AArch64Relaxer::AArch64Relaxer(Ctx &ctx, ArrayRef<Relocation> relocs)
+AArch64Relaxer::AArch64Relaxer(Ctx &ctx, ArrayRef<Relocation> relocs,
+ uint64_t secAddr, uint8_t *buf)
: ctx(ctx) {
if (!ctx.arg.relax)
return;
- // Check if R_AARCH64_ADR_GOT_PAGE and R_AARCH64_LD64_GOT_LO12_NC
- // always appear in pairs.
+ // For a given symbol R_AARCH64_ADR_GOT_PAGE and R_AARCH64_LD64_GOT_LO12_NC
+ // relaxation is all-or-nothing. We can't relax only some of them, as there
+ // may be a jump destination between the two relocations.
size_t i = 0;
const size_t size = relocs.size();
for (; i != size; ++i) {
if (relocs[i].type == R_AARCH64_ADR_GOT_PAGE) {
- if (i + 1 < size && relocs[i + 1].type == R_AARCH64_LD64_GOT_LO12_NC) {
+ if (i + 1 < size && relocs[i + 1].type == R_AARCH64_LD64_GOT_LO12_NC &&
+ !unsafeToRelaxAdrpLdr.contains(relocs[i].sym) &&
+ isLegalAdrpLdrRelaxationCandidate(relocs[i], relocs[i + 1], secAddr,
+ buf)) {
++i;
continue;
}
- break;
+ unsafeToRelaxAdrpLdr.insert(relocs[i].sym);
} else if (relocs[i].type == R_AARCH64_LD64_GOT_LO12_NC) {
- break;
+ unsafeToRelaxAdrpLdr.insert(relocs[i].sym);
}
}
- safeToRelaxAdrpLdr = i == size;
}
bool AArch64Relaxer::tryRelaxAdrpAdd(const Relocation &adrpRel,
@@ -966,23 +974,9 @@ bool AArch64Relaxer::tryRelaxAdrpAdd(const Relocation &adrpRel,
return true;
}
-bool AArch64Relaxer::tryRelaxAdrpLdr(const Relocation &adrpRel,
- const Relocation &ldrRel, uint64_t secAddr,
- uint8_t *buf) const {
- if (!safeToRelaxAdrpLdr)
- return false;
-
- // When the definition of sym is not preemptible then we may
- // be able to relax
- // ADRP xn, :got: sym
- // LDR xn, [ xn :got_lo12: sym]
- // to
- // ADRP xn, sym
- // ADD xn, xn, :lo_12: sym
-
- if (adrpRel.type != R_AARCH64_ADR_GOT_PAGE ||
- ldrRel.type != R_AARCH64_LD64_GOT_LO12_NC)
- return false;
+bool AArch64Relaxer::isLegalAdrpLdrRelaxationCandidate(
+ const Relocation &adrpRel, const Relocation &ldrRel, uint64_t secAddr,
+ uint8_t *buf) const {
// Check if the relocations apply to consecutive instructions.
if (adrpRel.offset + 4 != ldrRel.offset)
return false;
@@ -1022,10 +1016,37 @@ bool AArch64Relaxer::tryRelaxAdrpLdr(const Relocation &adrpRel,
if (val != llvm::SignExtend64(val, 33))
return false;
+ return true;
+}
+
+bool AArch64Relaxer::tryRelaxAdrpLdr(const Relocation &adrpRel,
+ const Relocation &ldrRel, uint64_t secAddr,
+ uint8_t *buf) const {
+ // When the definition of sym is not preemptible then we may
+ // be able to relax
+ // ADRP xn, :got: sym
+ // LDR xn, [ xn :got_lo12: sym]
+ // to
+ // ADRP xn, sym
+ // ADD xn, xn, :lo_12: sym
+
+ if (!ctx.arg.relax || adrpRel.type != R_AARCH64_ADR_GOT_PAGE ||
+ ldrRel.type != R_AARCH64_LD64_GOT_LO12_NC)
+ return false;
+
+ Symbol *sym = adrpRel.sym;
+ if (unsafeToRelaxAdrpLdr.contains(sym))
+ return false;
+
+ assert(isLegalAdrpLdrRelaxationCandidate(adrpRel, ldrRel, secAddr, buf) &&
+ "Should have been marked as unsafe");
+
+ uint32_t adrpInstr = read32le(buf + adrpRel.offset);
+ uint32_t adrpDestReg = adrpInstr & 0x1f;
Relocation adrpSymRel = {RE_AARCH64_PAGE_PC, R_AARCH64_ADR_PREL_PG_HI21,
- adrpRel.offset, /*addend=*/0, &sym};
+ adrpRel.offset, /*addend=*/0, sym};
Relocation addRel = {R_ABS, R_AARCH64_ADD_ABS_LO12_NC, ldrRel.offset,
- /*addend=*/0, &sym};
+ /*addend=*/0, sym};
// adrp x_<dest_reg>
write32le(buf + adrpSymRel.offset, 0x90000000 | adrpDestReg);
@@ -1034,11 +1055,11 @@ bool AArch64Relaxer::tryRelaxAdrpLdr(const Relocation &adrpRel,
ctx.target->relocate(
buf + adrpSymRel.offset, adrpSymRel,
- SignExtend64(getAArch64Page(sym.getVA(ctx)) -
+ SignExtend64(getAArch64Page(sym->getVA(ctx)) -
getAArch64Page(secAddr + adrpSymRel.offset),
64));
ctx.target->relocate(buf + addRel.offset, addRel,
- SignExtend64(sym.getVA(ctx), 64));
+ SignExtend64(sym->getVA(ctx), 64));
tryRelaxAdrpAdd(adrpSymRel, addRel, secAddr, buf);
return true;
}
@@ -1052,7 +1073,7 @@ static bool needsGotForMemtag(const Relocation &rel) {
void AArch64::relocateAlloc(InputSection &sec, uint8_t *buf) const {
uint64_t secAddr = sec.getOutputSection()->addr + sec.outSecOff;
const ArrayRef<Relocation> relocs = sec.relocs();
- AArch64Relaxer relaxer(ctx, relocs);
+ AArch64Relaxer relaxer(ctx, relocs, secAddr, buf);
for (size_t i = 0, size = relocs.size(); i != size; ++i) {
const Relocation &rel = relocs[i];
if (rel.expr == R_NONE) // See finalizeAddressDependentContent()
diff --git a/lld/test/ELF/aarch64-adrp-ldr-got.s b/lld/test/ELF/aarch64-adrp-ldr-got.s
index 56a90aac3876..a8216da9f20c 100644
--- a/lld/test/ELF/aarch64-adrp-ldr-got.s
+++ b/lld/test/ELF/aarch64-adrp-ldr-got.s
@@ -4,6 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/unpaired.s -o %t/unpaired.o
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/lone-ldr.s -o %t/lone-ldr.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/all-or-nothing.s -o %t/all-or-nothing.o
# RUN: ld.lld %t/a.o -T %t/out-of-adr-range.t -o %t/a
# RUN: llvm-objdump --no-show-raw-insn -d %t/a | FileCheck %s
@@ -49,7 +50,8 @@
# RUN: llvm-objdump --no-show-raw-insn -d %t/out-of-range | \
# RUN: FileCheck --check-prefix=X1-NO-RELAX %s
-## Relocations do not appear in pairs, no relaxations should be applied.
+## Relocations do not appear in pairs, no relaxations should be applied for
+## that symbol. We can still relax other symbols.
# RUN: ld.lld %t/unpaired.o -o %t/unpaired
# RUN: llvm-objdump --no-show-raw-insn -d %t/unpaired | \
# RUN: FileCheck --check-prefix=UNPAIRED %s
@@ -58,6 +60,9 @@
# UNPAIRED-NEXT: b
# UNPAIRED-NEXT: adrp x0
# UNPAIRED: ldr x0
+## This is a different symbol.
+# UNPAIRED: nop
+# UNPAIRED: adr x1
## Relocations do not appear in pairs, no relaxations should be applied.
# RUN: ld.lld %t/lone-ldr.o -o %t/lone-ldr
@@ -66,6 +71,26 @@
# LONE-LDR: ldr x0
+## Make sure that relaxation is not applied if not all adrp+ldr pairs for
+## a given symbol can be relaxed. This is not legal, because there may be
+## a branch destination between the adrp and ldr instructions. We can still
+## perform the relaxation for other symbols, or the same symbol in a different
+## section.
+# RUN: ld.lld %t/all-or-nothing.o -o %t/all-or-nothing
+# RUN: llvm-objdump --no-show-raw-insn -d %t/all-or-nothing | \
+# RUN: FileCheck --check-prefix=ALL-OR-NOTHING %s
+
+# ALL-OR-NOTHING-LABEL: <_start>:
+# ALL-OR-NOTHING: adrp x1
+# ALL-OR-NOTHING: ldr x1
+# ALL-OR-NOTHING: adrp x1
+# ALL-OR-NOTHING: ldr x2
+# ALL-OR-NOTHING: nop
+# ALL-OR-NOTHING: adr x1
+# ALL-OR-NOTHING-LABEL: <foo>:
+# ALL-OR-NOTHING: nop
+# ALL-OR-NOTHING: adr x1
+
## This linker script ensures that .rodata and .text are sufficiently (>1M)
## far apart so that the adrp + ldr pair cannot be relaxed to adr + nop.
#--- out-of-adr-range.t
@@ -95,25 +120,40 @@ SECTIONS {
.hidden x
x:
.word 10
+.hidden y
+y:
+.word 10
+.hidden z
+z:
+.word 10
+.hidden u
+u:
+.word 10
+.hidden v
+v:
+.word 10
.text
.global _start
_start:
adrp x1, :got:x
ldr x1, [x1, #:got_lo12:x]
- adrp x2, :got:x+1
- ldr x2, [x2, #:got_lo12:x]
- adrp x3, :got:x
- ldr x3, [x3, #:got_lo12:x+8]
- adrp x4, :got:x
- ldr x5, [x4, #:got_lo12:x]
- adrp x6, :got:x
- ldr x6, [x0, #:got_lo12:x]
+ adrp x2, :got:y+1
+ ldr x2, [x2, #:got_lo12:y]
+ adrp x3, :got:z
+ ldr x3, [x3, #:got_lo12:z+8]
+ adrp x4, :got:u
+ ldr x5, [x4, #:got_lo12:u]
+ adrp x6, :got:v
+ ldr x6, [x0, #:got_lo12:v]
#--- unpaired.s
.text
.hidden x
x:
nop
+.hidden y
+y:
+ nop
.global _start
_start:
adrp x0, :got:x
@@ -121,6 +161,8 @@ _start:
adrp x0, :got:x
L:
ldr x0, [x0, #:got_lo12:x]
+ adrp x1, :got:y
+ ldr x1, [x1, #:got_lo12:y]
#--- lone-ldr.s
.text
@@ -130,3 +172,27 @@ x:
.global _start
_start:
ldr x0, [x0, #:got_lo12:x]
+
+#--- all-or-nothing.s
+.rodata
+.hidden x
+x:
+.word 10
+.hidden y
+y:
+.word 10
+.text
+.global _start
+_start:
+ adrp x1, :got:x
+ ldr x1, [x1, #:got_lo12:x]
+ adrp x1, :got:x
+ ldr x2, [x1, #:got_lo12:x]
+ adrp x1, :got:y
+ ldr x1, [x1, #:got_lo12:y]
+
+.section .text.foo
+.global foo
+foo:
+ adrp x1, :got:x
+ ldr x1, [x1, #:got_lo12:x]
--
2.50.1

View File

@ -0,0 +1,88 @@
From 7bb9626d5ab901e5c1a8e9acbbb1684c982401b4 Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Fri, 10 Jul 2026 15:45:02 -0300
Subject: [PATCH] [LLVM][Verifier] Fix buffer overflow when verifying
gc.statepoint (#208278)
When a negative base index is passed, the verification detects the
out-of-bounds value and start printing information that helps to
identify what caused the error. In order to print all the information,
it tries to dereference the Base pointer at
GCRelocateInst::getBasePtr(), causing the buffer overflow. Add a bounds
check to getBasePTR() and getDerivedPtr() in order to avoid this.
Improve the test in order to validate negative values passed as indexes.
They're based on the reproducer from issue #199191.
Fixes #199191
---
llvm/lib/IR/AsmWriter.cpp | 10 ++++++++--
llvm/lib/IR/IntrinsicInst.cpp | 19 ++++++++++++++++---
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index e90630a8cae5..6752d6aa344d 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4372,9 +4372,15 @@ void AssemblyWriter::printInstructionLine(const Instruction &I) {
/// intrinsic indicating base and derived pointer names.
void AssemblyWriter::printGCRelocateComment(const GCRelocateInst &Relocate) {
Out << " ; (";
- writeOperand(Relocate.getBasePtr(), false);
+ if (Value *BasePtr = Relocate.getBasePtr())
+ writeOperand(BasePtr, false);
+ else
+ Out << "invalid";
Out << ", ";
- writeOperand(Relocate.getDerivedPtr(), false);
+ if (Value *DerivedPtr = Relocate.getDerivedPtr())
+ writeOperand(DerivedPtr, false);
+ else
+ Out << "invalid";
Out << ")";
}
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 3e9f3257956a..eb964d566f29 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -867,10 +867,16 @@ Value *GCRelocateInst::getBasePtr() const {
auto Statepoint = getStatepoint();
if (isa<UndefValue>(Statepoint))
return UndefValue::get(Statepoint->getType());
-
+ // Handle too few (bundle) arguments to avoid crashes when printing invalid
+ // IR, e.g. in the verifier.
auto *GCInst = cast<GCStatepointInst>(Statepoint);
- if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live))
+ if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) {
+ if (getBasePtrIndex() > Opt->Inputs.size())
+ return nullptr;
return *(Opt->Inputs.begin() + getBasePtrIndex());
+ }
+ if (getBasePtrIndex() > GCInst->arg_size())
+ return nullptr;
return *(GCInst->arg_begin() + getBasePtrIndex());
}
@@ -879,9 +885,16 @@ Value *GCRelocateInst::getDerivedPtr() const {
if (isa<UndefValue>(Statepoint))
return UndefValue::get(Statepoint->getType());
+ // Handle too few (bundle) arguments to avoid crashes when printing invalid
+ // IR, e.g. in the verifier.
auto *GCInst = cast<GCStatepointInst>(Statepoint);
- if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live))
+ if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) {
+ if (getDerivedPtrIndex() > Opt->Inputs.size())
+ return nullptr;
return *(Opt->Inputs.begin() + getDerivedPtrIndex());
+ }
+ if (getDerivedPtrIndex() > GCInst->arg_size())
+ return nullptr;
return *(GCInst->arg_begin() + getDerivedPtrIndex());
}
--
2.50.1

View File

@ -1,67 +0,0 @@
From 735d721de451067c3a618b309703d0b8beb9cacc Mon Sep 17 00:00:00 2001
From: Wael Yehia <wmyehia2001@yahoo.com>
Date: Mon, 23 Jun 2025 13:22:33 -0400
Subject: [PATCH] [PowerPC] Fix handling of undefs in the
PPC::isSplatShuffleMask query (#145149)
Currently, the query assumes that a single undef byte implies the rest of
the `EltSize - 1` bytes are undefs, but that's not always true.
e.g. isSplatShuffleMask(
<0,1,2,3,4,5,6,7,undef,undef,undef,undef,0,1,2,3>, 8) should return
false.
---------
Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
---
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 13 +++++++++----
llvm/test/CodeGen/PowerPC/pr141642.ll | 13 +++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
create mode 100644 llvm/test/CodeGen/PowerPC/pr141642.ll
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 421a808de667..88c6fe632d26 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -2242,10 +2242,15 @@ bool PPC::isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize) {
return false;
for (unsigned i = EltSize, e = 16; i != e; i += EltSize) {
- if (N->getMaskElt(i) < 0) continue;
- for (unsigned j = 0; j != EltSize; ++j)
- if (N->getMaskElt(i+j) != N->getMaskElt(j))
- return false;
+ // An UNDEF element is a sequence of UNDEF bytes.
+ if (N->getMaskElt(i) < 0) {
+ for (unsigned j = 1; j != EltSize; ++j)
+ if (N->getMaskElt(i + j) >= 0)
+ return false;
+ } else
+ for (unsigned j = 0; j != EltSize; ++j)
+ if (N->getMaskElt(i + j) != N->getMaskElt(j))
+ return false;
}
return true;
}
diff --git a/llvm/test/CodeGen/PowerPC/pr141642.ll b/llvm/test/CodeGen/PowerPC/pr141642.ll
new file mode 100644
index 000000000000..38a706574786
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/pr141642.ll
@@ -0,0 +1,13 @@
+; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -O0 -debug-only=selectiondag -o - < %s 2>&1 | \
+; RUN: FileCheck %s
+; CHECK-NOT: lxvdsx
+; CHECK-NOT: LD_SPLAT
+
+define weak_odr dso_local void @unpack(ptr noalias noundef %packed_in) local_unnamed_addr {
+entry:
+ %ld = load <2 x i32>, ptr %packed_in, align 2
+ %shuf = shufflevector <2 x i32> %ld, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 0>
+ %ie = insertelement <4 x i32> %shuf, i32 7, i32 2
+ store <4 x i32> %shuf, ptr %packed_in, align 2
+ ret void
+}
--
2.49.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
From a04c1eced55f2f3ea8dbd3d17db0b6df271c0809 Mon Sep 17 00:00:00 2001
From: Stefan Weigl-Bosker <stefan@s00.xyz>
Date: Mon, 18 May 2026 10:47:14 -0400
Subject: [PATCH] [X86] Fix EVEX compression for VPMOV*2M + KMOV with tied mask
use (#198220)
When scanning uses of the mask produced by `VPMOV*2M`, we previously bailed out as soon as we encountered a write. For tied read/write mask instructions such as `KSHIFTR*`, which both read and write the same mask register, the pass could miss the use, fold the earlier `KMOV`, and erase the `VPMOV*2M` def even though the mask was still live.
Disclaimer: LLM came up with the MIR tests and explained this pass to me.
Fixes #198197
(cherry picked from commit f0fc9d0abf7024ceb5cb827b16f02c10e54fe0fd)
---
llvm/lib/Target/X86/X86CompressEVEX.cpp | 12 ++++++------
llvm/test/CodeGen/X86/evex-to-vex-compress.mir | 12 ++++++++++++
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/X86/X86CompressEVEX.cpp b/llvm/lib/Target/X86/X86CompressEVEX.cpp
index c1faf7d1aa1e..b8fbcd2582de 100644
--- a/llvm/lib/Target/X86/X86CompressEVEX.cpp
+++ b/llvm/lib/Target/X86/X86CompressEVEX.cpp
@@ -271,12 +271,6 @@ static bool tryCompressVPMOVPattern(MachineInstr &MI, MachineBasicBlock &MBB,
for (MachineInstr &CurMI : llvm::make_range(
std::next(MachineBasicBlock::iterator(MI)), MBB.end())) {
- if (CurMI.modifiesRegister(MaskReg, TRI)) {
- if (!KMovMI)
- return false; // Mask clobbered before use
- break;
- }
-
if (CurMI.readsRegister(MaskReg, TRI)) {
if (KMovMI)
return false; // Fail: Mask has MULTIPLE uses
@@ -295,6 +289,12 @@ static bool tryCompressVPMOVPattern(MachineInstr &MI, MachineBasicBlock &MBB,
}
}
+ if (CurMI.modifiesRegister(MaskReg, TRI)) {
+ if (!KMovMI)
+ return false; // Mask clobbered before use
+ break;
+ }
+
if (!KMovMI && CurMI.modifiesRegister(SrcVecReg, TRI)) {
return false; // SrcVecReg modified before it could be used by MOVMSK
}
diff --git a/llvm/test/CodeGen/X86/evex-to-vex-compress.mir b/llvm/test/CodeGen/X86/evex-to-vex-compress.mir
index b33a1d571c81..575f0c7d6a4f 100644
--- a/llvm/test/CodeGen/X86/evex-to-vex-compress.mir
+++ b/llvm/test/CodeGen/X86/evex-to-vex-compress.mir
@@ -914,6 +914,12 @@ body: |
$k0 = VPMOVD2MZ256kr $ymm0
$eax = KMOVBrk $k0
$ebx = KMOVBrk $k0
+ ; CHECK: $k0 = VPMOVD2MZ256kr $ymm0
+ ; CHECK: $eax = KMOVBrk $k0
+ ; CHECK: $k0 = KSHIFTRBki $k0, 2
+ $k0 = VPMOVD2MZ256kr $ymm0
+ $eax = KMOVBrk $k0
+ $k0 = KSHIFTRBki $k0, 2
; CHECK: $k0 = VPMOVB2MZ256kr $ymm0
; CHECK: $eax = KMOVWrk $k0
$k0 = VPMOVB2MZ256kr $ymm0
@@ -1803,6 +1809,12 @@ body: |
$k0 = VPMOVD2MZ128kr $xmm0
$eax = KMOVBrk $k0
$ebx = KMOVBrk $k0
+ ; CHECK: $k0 = VPMOVD2MZ128kr $xmm0
+ ; CHECK: $eax = KMOVBrk $k0
+ ; CHECK: $k0 = KSHIFTRBki $k0, 2
+ $k0 = VPMOVD2MZ128kr $xmm0
+ $eax = KMOVBrk $k0
+ $k0 = KSHIFTRBki $k0, 2
; CHECK: $k0 = VPMOVB2MZ128kr $xmm0
; CHECK: $eax = KMOVBrk $k0
$k0 = VPMOVB2MZ128kr $xmm0
--
2.50.1

View File

@ -1,39 +0,0 @@
From 06774eb8a7dc0bc36b59e53310c7f5b5d89f6c29 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Tue, 28 Jan 2025 12:31:49 +0100
Subject: [PATCH] [cmake] Resolve symlink when finding install prefix
When determining the install prefix in LLVMConfig.cmake etc resolve
symlinks in CMAKE_CURRENT_LIST_FILE first. The motivation for this
is to support symlinks like `/usr/lib64/cmake/llvm` to
`/usr/lib64/llvm19/lib/cmake/llvm`. This only works correctly if
the paths are relative to the resolved symlink.
It's worth noting that this *mostly* already works out of the box,
because cmake automatically does the symlink resolution when the
library is found via CMAKE_PREFIX_PATH. It just doesn't happen
when it's found via the default prefix path.
---
cmake/Modules/FindPrefixFromConfig.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmake/Modules/FindPrefixFromConfig.cmake b/cmake/Modules/FindPrefixFromConfig.cmake
index 22211e4b72f2..3daff607ff84 100644
--- a/cmake/Modules/FindPrefixFromConfig.cmake
+++ b/cmake/Modules/FindPrefixFromConfig.cmake
@@ -39,10 +39,10 @@ function(find_prefix_from_config out_var prefix_var path_to_leave)
# install prefix, and avoid hard-coding any absolute paths.
set(config_code
"# Compute the installation prefix from this LLVMConfig.cmake file location."
- "get_filename_component(${prefix_var} \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
+ "get_filename_component(${prefix_var} \"\${CMAKE_CURRENT_LIST_FILE}\" REALPATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
- string(REGEX REPLACE "/" ";" _count "${path_to_leave}")
+ string(REGEX REPLACE "/" ";" _count "${path_to_leave}/plus_one")
foreach(p ${_count})
list(APPEND config_code
"get_filename_component(${prefix_var} \"\${${prefix_var}}\" PATH)")
--
2.48.1

View File

@ -0,0 +1,87 @@
From 2119e359b1f968da94ff27a4078d569e18903aef Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Mon, 13 Jul 2026 09:08:54 +0200
Subject: [PATCH] [lld][ELF] Concatenate .gnu.build.attributes.* sections
(#208737)
ld.bfd/ld.gold have been concatenating the GNU build attribute sections
since 2018:
https://gitlab.com/gnutools/binutils-gdb/-/commit/7d8a31665739412395f6dd370d2279acd322e78e
Do the same in LLD. These do not have a dedicated section type or flags,
so this is handled by the name-based logic. (Peculiarly, there used to
be SHF_GNU_BUILD_NOTE, but it was removed again.)
Not concatenating these results in a huge number of sections, which
breaks tools like `file`.
---
lld/ELF/LinkerScript.cpp | 2 +-
lld/test/ELF/gnu-build-attributes.s | 42 +++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 lld/test/ELF/gnu-build-attributes.s
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 1c0a49a73962..64fb717e17d9 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -119,7 +119,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
".init_array", ".fini_array", ".tbss",
".tdata", ".ARM.exidx", ".ARM.extab",
".ctors", ".dtors", ".sbss",
- ".sdata", ".srodata"})
+ ".sdata", ".srodata", ".gnu.build.attributes"})
if (isSectionPrefix(v, s->name))
return v;
diff --git a/lld/test/ELF/gnu-build-attributes.s b/lld/test/ELF/gnu-build-attributes.s
new file mode 100644
index 000000000000..79ad6c40ae50
--- /dev/null
+++ b/lld/test/ELF/gnu-build-attributes.s
@@ -0,0 +1,42 @@
+# REQUIRES: x86
+
+## Check that .gnu.build.attributes.* sections are concatenated into a single
+## .gnu.build.attributes section.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-linux-gnu %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-readobj -n %t | FileCheck %s
+
+# CHECK: NoteSections [
+# CHECK-NEXT: NoteSection {
+# CHECK-NEXT: Name: .gnu.build.attributes
+# CHECK-NEXT: Offset: 0x120
+# CHECK-NEXT: Size: 0x28
+# CHECK-NEXT: Notes [
+# CHECK-NEXT: {
+# CHECK-NEXT: Owner: GA${{.*}}:a1
+# CHECK-NEXT: Data size: 0x0
+# CHECK-NEXT: Type: OPEN
+# CHECK-NEXT: }
+# CHECK-NEXT: {
+# CHECK-NEXT: Owner: GA${{.*}}:b1
+# CHECK-NEXT: Data size: 0x0
+# CHECK-NEXT: Type: OPEN
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.section ".gnu.build.attributes.text.foo", "", @note
+.balign 4
+.long 8
+.long 0
+.long 0x100
+.asciz "GA$\x03:a1"
+
+.section ".gnu.build.attributes.text.bar", "", @note
+.balign 4
+.long 8
+.long 0
+.long 0x100
+.asciz "GA$\x03:b1"
--
2.50.1

70
0b6a1ef429.patch Normal file
View File

@ -0,0 +1,70 @@
From 0b6a1ef4297bb839fe26041602d32411358e0032 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 26 May 2026 01:41:01 +0200
Subject: [PATCH] [lit] Normalize RLIM_INFINITY to "infinity" in
print_limits.py for Python 3.15+ (#190953)
Python 3.15 changed resource.getrlimit() to return the platform's
maximum value (e.g., 18446744073709551615 on 64-bit systems) instead of
-1 for RLIM_INFINITY. This breaks lit tests that expect -1 for unlimited
resource limits.
This patch normalizes the return value to "infinity" when it equals
RLIM_INFINITY to maintain compatibility with existing tests across all
Python versions.
Fixes test failure: shtest-ulimit-nondarwin.py
Expected: RLIMIT_FSIZE=-1
Got: RLIMIT_FSIZE=18446744073709551615
Reference:
https://github.com/python/cpython/commit/0324c726dea702282a0300225e989b19ae23b759
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=2448969
Analysis and testing assisted by AI.
Assisted-by: Claude Sonnet 4.5
---------
Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
Co-authored-by: Tulio Magno Quites Machado Filho <tuliom@quites.com.br>
---
.../tests/Inputs/shtest-ulimit/print_limits.py | 17 +++++++++++++----
llvm/utils/lit/tests/shtest-ulimit-nondarwin.py | 2 +-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py b/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
index c732c0429e661..6c03721baf36d 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
@@ -1,6 +1,15 @@
import resource
-print("RLIMIT_AS=" + str(resource.getrlimit(resource.RLIMIT_AS)[0]))
-print("RLIMIT_NOFILE=" + str(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
-print("RLIMIT_STACK=" + str(resource.getrlimit(resource.RLIMIT_STACK)[0]))
-print("RLIMIT_FSIZE=" + str(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
+
+def normalize_limit(limit_value):
+ """Normalize RLIM_INFINITY to "infinity" for consistency across Python versions.
+
+ Python 3.15+ returns the platform's max value (e.g., 2^64-1) instead of -1.
+ """
+ return "infinity" if limit_value == resource.RLIM_INFINITY else str(limit_value)
+
+
+print("RLIMIT_AS=" + normalize_limit(resource.getrlimit(resource.RLIMIT_AS)[0]))
+print("RLIMIT_NOFILE=" + normalize_limit(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
+print("RLIMIT_STACK=" + normalize_limit(resource.getrlimit(resource.RLIMIT_STACK)[0]))
+print("RLIMIT_FSIZE=" + normalize_limit(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
diff --git a/llvm/utils/lit/tests/shtest-ulimit-nondarwin.py b/llvm/utils/lit/tests/shtest-ulimit-nondarwin.py
index 43811db750f80..80844d1d79460 100644
--- a/llvm/utils/lit/tests/shtest-ulimit-nondarwin.py
+++ b/llvm/utils/lit/tests/shtest-ulimit-nondarwin.py
@@ -18,4 +18,4 @@
# CHECK: ulimit -f 5
# CHECK: RLIMIT_FSIZE=5
# CHECK: ulimit -f unlimited
-# CHECK: RLIMIT_FSIZE=-1
+# CHECK: RLIMIT_FSIZE=infinity

View File

@ -1,28 +0,0 @@
From e43271ec7438ecb78f99db134aeca274a47f6c28 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine@redhat.com>
Date: Thu, 13 Mar 2025 09:12:24 +0100
Subject: [PATCH] Filter out configuration file from compile commands
The commands to run the compilation when printed with `-###` contain
various irrelevant lines for the perf-training. Most of them are
filtered out already but when configured with
`CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is
added and needs to be filtered out:
`Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg`
---
clang/utils/perf-training/perf-helper.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py
index 80c6356d0497c..29904aded5ab0 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -237,6 +237,7 @@ def get_cc1_command_for_args(cmd, env):
or ln.startswith("InstalledDir:")
or ln.startswith("LLVM Profile Note")
or ln.startswith(" (in-process)")
+ or ln.startswith("Configuration file:")
or " version " in ln
):
continue

View File

@ -1,94 +0,0 @@
From eba58195932f37fb461ae17c69fc517181b99c9a Mon Sep 17 00:00:00 2001
From: Paul Murphy <paumurph@redhat.com>
Date: Mon, 30 Jun 2025 10:13:37 -0500
Subject: [PATCH] [PowerPC] fix lowering of SPILL_CRBIT on pwr9 and pwr10
If a copy exists between creation of a crbit and a spill, machine-cp
may delete the copy since it seems unaware of the relation between a cr
and crbit. A fix was previously made for the generic ppc64 lowering. It
should be applied to the pwr9 and pwr10 variants too.
Likewise, relax and extend the pwr8 test to verify pwr9 and pwr10
codegen too.
This fixes #143989.
---
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 17 +++++++++++------
.../PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir | 8 +++++++-
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 76dca4794e05..78d254a55fd9 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -1102,13 +1102,20 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II,
SpillsKnownBit = true;
break;
default:
+ // When spilling a CR bit, The super register may not be explicitly defined
+ // (i.e. it can be defined by a CR-logical that only defines the subreg) so
+ // we state that the CR field is undef. Also, in order to preserve the kill
+ // flag on the CR bit, we add it as an implicit use.
+
// On Power10, we can use SETNBC to spill all CR bits. SETNBC will set all
// bits (specifically, it produces a -1 if the CR bit is set). Ultimately,
// the bit that is of importance to us is bit 32 (bit 0 of a 32-bit
// register), and SETNBC will set this.
if (Subtarget.isISA3_1()) {
BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::SETNBC8 : PPC::SETNBC), Reg)
- .addReg(SrcReg, RegState::Undef);
+ .addReg(SrcReg, RegState::Undef)
+ .addReg(SrcReg, RegState::Implicit |
+ getKillRegState(MI.getOperand(0).isKill()));
break;
}
@@ -1122,16 +1129,14 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II,
SrcReg == PPC::CR4LT || SrcReg == PPC::CR5LT ||
SrcReg == PPC::CR6LT || SrcReg == PPC::CR7LT) {
BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::SETB8 : PPC::SETB), Reg)
- .addReg(getCRFromCRBit(SrcReg), RegState::Undef);
+ .addReg(getCRFromCRBit(SrcReg), RegState::Undef)
+ .addReg(SrcReg, RegState::Implicit |
+ getKillRegState(MI.getOperand(0).isKill()));
break;
}
}
// We need to move the CR field that contains the CR bit we are spilling.
- // The super register may not be explicitly defined (i.e. it can be defined
- // by a CR-logical that only defines the subreg) so we state that the CR
- // field is undef. Also, in order to preserve the kill flag on the CR bit,
- // we add it as an implicit use.
BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg)
.addReg(getCRFromCRBit(SrcReg), RegState::Undef)
.addReg(SrcReg,
diff --git a/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir b/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir
index 41e21248a3f0..2796cdb3ae87 100644
--- a/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir
+++ b/llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir
@@ -1,6 +1,12 @@
# RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
# RUN: -o - | FileCheck %s
+# RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
+# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
+# RUN: -o - | FileCheck %s
+# RUN: llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
+# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
+# RUN: -o - | FileCheck %s
--- |
; ModuleID = 'a.ll'
@@ -30,7 +36,7 @@
; Function Attrs: nounwind
declare void @llvm.stackprotector(ptr, ptr) #1
- attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+vsx,-power9-vector" "unsafe-fp-math"="false" "use-soft-float"="false" }
+ attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
--
2.49.0

View File

@ -1,86 +0,0 @@
From f463bef09be73ae9a415fcd3fd49689bd95b0f0a Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907@163.com>
Date: Fri, 20 Feb 2026 07:03:27 +0800
Subject: [PATCH] [SimplifyCFG] process prof data when remove case in umin
(#182261)
In #164097, we introduce a optimization for umin. But it does not handle
profile data correctly.
This PR remove profile data when remove cases.
Fixed: #181837
(cherry picked from commit 31e5f86a3cdc960ef7b2f0a533c4a37cf526cacd)
---
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 +-
.../Transforms/SimplifyCFG/switch-umin.ll | 43 +++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5f4807242581d..a16f274a4ed5a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -7724,7 +7724,7 @@ static bool simplifySwitchWhenUMin(SwitchInst *SI, DomTreeUpdater *DTU) {
BasicBlock *DeadCaseBB = I->getCaseSuccessor();
DeadCaseBB->removePredecessor(BB);
Updates.push_back({DominatorTree::Delete, BB, DeadCaseBB});
- I = SIW->removeCase(I);
+ I = SIW.removeCase(I);
E = SIW->case_end();
}
diff --git a/llvm/test/Transforms/SimplifyCFG/switch-umin.ll b/llvm/test/Transforms/SimplifyCFG/switch-umin.ll
index 44665365dc222..ff958e4d04147 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch-umin.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch-umin.ll
@@ -239,8 +239,51 @@ case4:
}
+define void @switch_remove_dead_cases(i32 %x) {
+; CHECK-LABEL: define void @switch_remove_dead_cases(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 4)
+; CHECK-NEXT: switch i32 [[X]], label %[[COMMON_RET:.*]] [
+; CHECK-NEXT: i32 2, label %[[CASE_A:.*]]
+; CHECK-NEXT: i32 3, label %[[CASE_B:.*]]
+; CHECK-NEXT: ], !prof [[PROF1:![0-9]+]]
+; CHECK: [[COMMON_RET]]:
+; CHECK-NEXT: ret void
+; CHECK: [[CASE_A]]:
+; CHECK-NEXT: call void @a()
+; CHECK-NEXT: br label %[[COMMON_RET]]
+; CHECK: [[CASE_B]]:
+; CHECK-NEXT: call void @b()
+; CHECK-NEXT: br label %[[COMMON_RET]]
+;
+ %min = call i32 @llvm.umin.i32(i32 %x, i32 4)
+ switch i32 %min, label %unreachable [
+ i32 2, label %case_a
+ i32 3, label %case_b
+ i32 4, label %case_ret
+ i32 5, label %case_ret
+ ], !prof !1
+
+case_a:
+ call void @a()
+ ret void
+
+case_b:
+ call void @b()
+ ret void
+
+case_ret:
+ ret void
+
+unreachable:
+ unreachable
+}
!0 = !{!"branch_weights", i32 1, i32 2, i32 3, i32 99, i32 5}
;.
; CHECK: [[PROF0]] = !{!"branch_weights", i32 5, i32 2, i32 3, i32 99}
;.
+!1 = !{!"branch_weights", i32 11, i32 12, i32 13, i32 14, i32 15}
+;.
+; CHECK: [[PROF1]] = !{!"branch_weights", i32 14, i32 12, i32 13}
+;.

View File

@ -1,55 +0,0 @@
From ccf0ee68b86f65a6a4e83756f717faad7c779cb1 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Wed, 11 Mar 2026 18:03:05 +0100
Subject: [PATCH] [SystemZ] Limit depth of findCCUse()
The recursion here has potentially exponential complexity. Avoid
this by limiting the depth of recursion.
An alternative would be to memoize the results. I went with the
simpler depth limit on the assumption that we don't particularly
care about very deep value chains here.
---
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 2a9cb903f3921..84d66f88a812d 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -8692,7 +8692,12 @@ SDValue SystemZTargetLowering::combineSETCC(
return SDValue();
}
-static std::pair<SDValue, int> findCCUse(const SDValue &Val) {
+static std::pair<SDValue, int> findCCUse(const SDValue &Val,
+ unsigned Depth = 0) {
+ // Limit depth of potentially exponential walk.
+ if (Depth > 5)
+ return std::make_pair(SDValue(), SystemZ::CCMASK_NONE);
+
switch (Val.getOpcode()) {
default:
return std::make_pair(SDValue(), SystemZ::CCMASK_NONE);
@@ -8705,7 +8710,7 @@ static std::pair<SDValue, int> findCCUse(const SDValue &Val) {
SDValue Op4CCReg = Val.getOperand(4);
if (Op4CCReg.getOpcode() == SystemZISD::ICMP ||
Op4CCReg.getOpcode() == SystemZISD::TM) {
- auto [OpCC, OpCCValid] = findCCUse(Op4CCReg.getOperand(0));
+ auto [OpCC, OpCCValid] = findCCUse(Op4CCReg.getOperand(0), Depth + 1);
if (OpCC != SDValue())
return std::make_pair(OpCC, OpCCValid);
}
@@ -8722,10 +8727,10 @@ static std::pair<SDValue, int> findCCUse(const SDValue &Val) {
case ISD::SHL:
case ISD::SRA:
case ISD::SRL:
- auto [Op0CC, Op0CCValid] = findCCUse(Val.getOperand(0));
+ auto [Op0CC, Op0CCValid] = findCCUse(Val.getOperand(0), Depth + 1);
if (Op0CC != SDValue())
return std::make_pair(Op0CC, Op0CCValid);
- return findCCUse(Val.getOperand(1));
+ return findCCUse(Val.getOperand(1), Depth + 1);
}
}

473
llvm.spec
View File

@ -2,7 +2,7 @@
#region version
%global maj_ver 22
%global min_ver 1
%global patch_ver 1
%global patch_ver 8
#global rc_ver rc3
%bcond_with snapshot_build
@ -28,6 +28,7 @@
%define bcond_override_default_offload 0
%define bcond_override_default_mlir 0
%define bcond_override_default_flang 0
%define bcond_override_default_libclc 0
%define bcond_override_default_build_bolt 0
%define bcond_override_default_polly 0
%define bcond_override_default_pgo 0
@ -41,7 +42,7 @@
%bcond_with compat_build
# Bundle compat libraries for a previous LLVM version, as part of llvm-libs and
# clang-libs. Used on RHEL.
%bcond_without bundle_compat_lib
%bcond_with bundle_compat_lib
%bcond_without check
%if %{with bundle_compat_lib}
@ -56,6 +57,14 @@
%bcond_without python_lit
%endif
%if %{maj_ver} >= 23
%global build_docs 0
%global build_docs_toggle OFF
%else
%global build_docs 1
%global build_docs_toggle ON
%endif
%bcond_without lldb
%ifarch ppc64le
@ -77,7 +86,7 @@
# MLIR version 22 started to require nanobind >= 2.9, which is only available
# on Fedora >= 44.
%if %{without compat_build} && %{defined fedora} && (%{maj_ver} < 22 || 0%{?fedora} >= 44)
%if %{without compat_build} && %{defined fedora} && 0%{?fedora} >= 44
%ifarch %{ix86}
%bcond_with mlir
%else
@ -88,7 +97,7 @@
%endif
#region flang
%if %{without compat_build} && %{defined fedora} && (%{maj_ver} >= 22 && 0%{?fedora} >= 44)
%if %{without compat_build} && %{defined fedora} && 0%{?fedora} >= 44
# Link error on i686.
# s390x is not supported upstream yet.
%ifarch i686 s390x
@ -109,6 +118,8 @@
# Set Fortran build flags to nil because they contain flags that don't apply to flang.
%global build_fflags %{nil}
%endif
#endregion flang
%{lua:
@ -145,8 +156,7 @@ function print_max_procs(per_proc_mem)
print(cpu)
end
}
%endif
#endregion flang
# The libcxx build condition also enables libcxxabi and libunwind.
%if %{without compat_build} && %{defined fedora}
@ -207,15 +217,16 @@ end
%endif
%endif
# Historically, LLD was used used at the same combinations that enabled PGO.
# If this changes, we need to update the following lines.
# However, we should be able to link using LLD even if PGO is disabled.
# Reminder: RHEL8 still builds with gcc + ld.bfd.
%if %{with pgo}
%bcond_without use_lld
%else
%if 0%{?rhel} == 8
# RHEL8 still builds with gcc + ld.bfd.
%bcond_with use_lld
%else
%bcond_without use_lld
%endif
%if %{with pgo} && %{without use_lld}
%{error:PGO requires --with=lld}
%endif
# For PGO Disable LTO for now because of LLVMgold.so not found error
@ -224,6 +235,12 @@ end
%global _lto_cflags %nil
%endif
%if %{maj_ver} >= 23 && 0%{undefined rhel} && %{without compat_build} && %{with snapshot_build}
%bcond_without libclc
%else
%bcond_with libclc
%endif
# We are building with clang for faster/lower memory LTO builds.
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_macros
# Reminder: This only works on Fedora and RHEL >= 9.
@ -255,6 +272,12 @@ end
%bcond_without libedit
%endif
%if %{defined rhel} && 0%{?rhel} >= 10
%bcond_with multilib
%else
%bcond_without multilib
%endif
# Opt out of https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer
# https://bugzilla.redhat.com/show_bug.cgi?id=2158587
%undefine _include_frame_pointers
@ -271,8 +294,10 @@ end
# Suffixless tarball name (essentially: basename -s .tar.xz llvm-project-17.0.6.src.tar.xz)
%if %{with snapshot_build}
%global src_tarball_dir llvm-project-%{llvm_snapshot_git_revision}
%global src_manpage_tarball_dir llvm_man_pages-%{llvm_snapshot_yyyymmdd}
%else
%global src_tarball_dir llvm-project-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-%{rc_ver}}.src
%global src_manpage_tarball_dir llvm_man_pages-%{maj_ver}.%{min_ver}.%{patch_ver}
%endif
# LLD uses "fast" as the algortithm for generating build-id
@ -318,6 +343,12 @@ end
%global build_install_prefix %{buildroot}%{install_prefix}
%if %{with compat_build}
%global install_pythondir %{install_prefix}/lib/python%{python3_version}/site-packages
%else
%global install_pythondir %{python3_sitelib}/
%endif
# Lower memory usage of dwz on s390x
%global _dwz_low_mem_die_limit_s390x 1
%global _dwz_max_die_limit_s390x 1000000
@ -399,6 +430,12 @@ end
%global pkg_name_flang flang%{pkg_suffix}
#endregion flang globals
#region libclc globals
%if %{with libclc}
%global pkg_name_libclc libclc%{pkg_suffix}
%endif
#endregion libclc globals
#endregion globals
#region packages
@ -417,9 +454,15 @@ URL: http://llvm.org
%if %{with snapshot_build}
Source0: https://github.com/llvm/llvm-project/archive/%{llvm_snapshot_git_revision}.tar.gz
%if %{build_docs} == 0
Source42: https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/snapshot-version-sync/%{src_manpage_tarball_dir}.tar.xz
%endif
%else
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-%{rc_ver}}/%{src_tarball_dir}.tar.xz
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-%{rc_ver}}/%{src_tarball_dir}.tar.xz.sig
%if %{build_docs} == 0
Source42: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-%{rc_ver}}/%{src_manpage_tarball_dir}.tar.xz
%endif
%endif
Source6: release-keys.asc
@ -471,7 +514,6 @@ Patch2100: 0001-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch
Patch2200: 0001-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch
Patch2300: 0001-23-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch
Patch102: 0003-PATCH-clang-Don-t-install-static-libraries.patch
Patch2002: 20-131099.patch
# Workaround a bug in ORC on ppc64le.
# More info is available here: https://reviews.llvm.org/D159115#4641826
@ -482,21 +524,28 @@ Patch103: 0001-Workaround-a-bug-in-ORC-on-ppc64le.patch
Patch104: 0001-Driver-Give-devtoolset-path-precedence-over-Installe.patch
#endregion CLANG patches
# Fix LLVMConfig.cmake when symlinks are used.
# (https://github.com/llvm/llvm-project/pull/124743 landed in LLVM 21)
Patch2003: 0001-cmake-Resolve-symlink-when-finding-install-prefix.patch
# Fix lit tests for Python 3.15+ https://bugzilla.redhat.com/show_bug.cgi?id=2448969
Patch2209: https://github.com/llvm/llvm-project/commit/0b6a1ef429.patch
# Backport a fix from LLVM 23.
# https://github.com/llvm/llvm-project/pull/185375
Patch2204: 22-185375.patch
# s390x fix for unaligned memory access performance regressions.
Patch2210: 0001-SystemZ-Avoid-unaligned-VL-VST-s-with-memcpy-memmove.patch
# Backport a fix for high CPU usage on s390x from LLVM 23.
# https://github.com/llvm/llvm-project/pull/185922
Patch2205: 22-185922.patch
# Fix a heap buffer overflow.
# https://bugzilla.redhat.com/show_bug.cgi?id=2496390
Patch2211: 0001-LLVM-Verifier-Fix-buffer-overflow-when-verifying-gc..patch
# Fix miscompilation.
# https://bugzilla.redhat.com/show_bug.cgi?id=2499684
Patch2212: 0001-SDAG-Freeze-condition-in-select-of-load-fold-208683.patch
# Fix a vector miscompilation
Patch2213: 0001-X86-Fix-EVEX-compression-for-VPMOV-2M-KMOV-with-tied.patch
#region LLD patches
Patch106: 0001-19-Always-build-shared-libs-for-LLD.patch
Patch2103: 0001-lld-Adjust-compressed-debug-level-test-for-s390x-wit.patch
Patch2214: 0001-ELF-Simplify-AArch64-relocateAlloc.-NFC.patch
Patch2215: 0001-LLD-AArch64-Make-adrp-ldr-relaxation-per-symbol-all-.patch
Patch2216: 0001-lld-ELF-Concatenate-.gnu.build.attributes.-sections-.patch
#endregion LLD patches
#region polly patches
@ -517,20 +566,6 @@ Patch503: 0002-BPF-Remove-unused-weak-symbol-__bpf_trap-166003.patch
Patch504: 0003-BPF-Remove-dead-code-related-to-__bpf_trap-global-va.patch
#endregion RHEL patches
# Fix a pgo miscompilation triggered by building Rust 1.87 with pgo on ppc64le.
# https://github.com/llvm/llvm-project/issues/138208
Patch2004: 0001-CodeGenPrepare-Make-sure-instruction-get-from-SunkAd.patch
# Related CGP fix for domination, rhbz#2388223
Patch2008: 0001-CGP-Bail-out-if-Base-Scaled-Reg-does-not-dominate-in.patch
# Fix Power9/Power10 crbit spilling
# https://github.com/llvm/llvm-project/pull/146424
Patch2007: 21-146424.patch
# Fix for highway package build on ppc64le
Patch2005: 0001-PowerPC-Fix-handling-of-undefs-in-the-PPC-isSplatShu.patch
Patch2006: 0001-Add-REQUIRES-asserts-to-test-added-in-145149-because.patch
# Fix for offload builds: The DeviceRTL libraries target device code and
# don't support the mtls-dialect flag, so we need to patch the clang driver
# to ignore it for these targets.
@ -595,20 +630,22 @@ BuildRequires: lld
%endif
%endif
%if %{build_docs}
# This intentionally does not use python3_pkgversion. RHEL 8 does not have
# python3.12-sphinx, and we are only using it as a binary anyway.
BuildRequires: python3-sphinx
%if 0%{?rhel} != 8
# RHEL 8 does not have these packages for python3.12. However, they are only
# needed for LLDB tests.
BuildRequires: python%{python3_pkgversion}-psutil
BuildRequires: python%{python3_pkgversion}-pexpect
%endif
%if %{undefined rhel}
%if 0%{?rhel} != 8
# RHEL 8 does not have these packages for python3.12.
BuildRequires: python%{python3_pkgversion}-psutil
%endif
%if %{undefined rhel} && %{build_docs}
BuildRequires: python%{python3_pkgversion}-myst-parser
%endif
# Needed for %%multilib_fix_c_header
%if %{with multilib}
BuildRequires: multilib-rpm-config
%endif
%if %{with gold}
BuildRequires: binutils-devel
%if %{undefined rhel} || 0%{?rhel} > 8
@ -929,27 +966,26 @@ Development header files for clang tools.
%package -n git-clang-format%{pkg_suffix}
Summary: Integration of clang-format for git
Requires: %{pkg_name_clang}-tools-extra = %{version}-%{release}
Requires: git
Requires: git-core
Requires: python%{python3_pkgversion}
%description -n git-clang-format%{pkg_suffix}
clang-format integration for git.
%if %{without compat_build}
%package -n python%{python3_pkgversion}-clang
%package -n python%{python3_pkgversion}-%{pkg_name_clang}
Summary: Python3 bindings for clang
Requires: %{pkg_name_clang}-devel%{?_isa} = %{version}-%{release}
Requires: python%{python3_pkgversion}
%if "%{?python3_version}" != ""
Requires: python(abi) = %{python3_version}
%endif
Provides: python%{python3_pkgversion}-clang(major) = %{maj_ver}
%if 0%{?rhel} == 8
# Became python3.12-clang in LLVM 19
Obsoletes: python3-clang < 18.9
%endif
%description -n python%{python3_pkgversion}-clang
%description -n python%{python3_pkgversion}-%{pkg_name_clang}
Python3 bindings for clang.
%endif
#endregion CLANG packages
#region COMPILER-RT packages
@ -1060,6 +1096,9 @@ License: Apache-2.0 WITH LLVM-exception OR NCSA
URL: http://lldb.llvm.org/
Requires: %{pkg_name_clang}-libs%{?_isa} = %{version}-%{release}
%if 0%{?fedora} >= 45
Recommends: yama-ptrace-enable
%endif
%if %{without compat_build}
Requires: python%{python3_pkgversion}-lldb
%endif
@ -1291,6 +1330,51 @@ Flang runtime libraries.
%endif
#endregion flang packages
#region libclc packages
%if %{with libclc}
%package -n %{pkg_name_libclc}
Summary: An open source implementation of the OpenCL 1.1 library requirements
License: Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
URL: https://libclc.llvm.org
Obsoletes: %{pkg_name_libclc}-devel < 23
%description -n %{pkg_name_libclc}
libclc is an open source, BSD licensed implementation of the library
requirements of the OpenCL C programming language, as specified by the
OpenCL 1.1 Specification. The following sections of the specification
impose library requirements:
* 6.1: Supported Data Types
* 6.2.3: Explicit Conversions
* 6.2.4.2: Reinterpreting Types Using as_type() and as_typen()
* 6.9: Preprocessor Directives and Macros
* 6.11: Built-in Functionsj
* 9.3: Double Precision Floating-Point
* 9.4: 64-bit Atomics
* 9.5: Writing to 3D image memory objects
* 9.6: Half Precision Floating-Point
libclc is intended to be used with the Clang compiler's OpenCL frontend.
libclc is designed to be portable and extensible. To this end, it provides
generic implementations of most library requirements, allowing the target
to override the generic implementation at the granularity of individual
functions.
libclc currently only supports the PTX target, but support for more
targets is welcome.
%package -n %{pkg_name_libclc}-spirv
Summary: Spirv subset of %{name}
%description -n %{pkg_name_libclc}-spirv
The %{pkg_name_libclc}-spirv package contains the spirv32-unknown-unknown/libclc.spv and
spirv64-unknown-unknown/libclc.spv files only, which are the subset required for upstream
Mesa OpenCL support with RustiCL.
%endif
#endregion libclc packages
#endregion packages
#region prep
@ -1311,6 +1395,18 @@ Flang runtime libraries.
# automatically apply patches based on LLVM version
%autopatch -m%{compat_maj_ver}00 -M%{compat_maj_ver}99 -p1
%if 0%{?rhel} == 8 && %{compat_maj_ver} < 22
# The following patches have been backported from LLVM 22.
%patch -p1 -P502
%patch -p1 -P503
%patch -p1 -P504
%endif
%endif
# Unpack the man pages first
%if %{build_docs} == 0
%autosetup -N -T -b 42 -n %{src_manpage_tarball_dir}
%endif
# -T : Do Not Perform Default Archive Unpacking (without this, the <n>th source would be unpacked twice)
@ -1329,12 +1425,6 @@ Flang runtime libraries.
%if %{defined rhel} && 0%{?rhel} == 8
%patch -p1 -P501
%if %{maj_ver} < 22
# The following patches have been backported from LLVM 22.
%patch -p1 -P502
%patch -p1 -P503
%patch -p1 -P504
%endif
%endif
#region LLVM preparation
@ -1369,10 +1459,12 @@ Flang runtime libraries.
#endregion COMPILER-RT preparation
#region lldb preparation
%if %{build_docs}
# Compat builds don't build python bindings, but should still build man pages.
%if %{with compat_build}
sed -i 's/LLDB_ENABLE_PYTHON/TRUE/' lldb/docs/CMakeLists.txt
%endif
%endif
#endregion
#region libcxx preparation
@ -1414,6 +1506,8 @@ cd llvm/utils/lit
%global projects clang;clang-tools-extra;lld
%global runtimes compiler-rt;openmp
%global runtime_targets default
%if %{with lldb}
%global projects %{projects};lldb
%endif
@ -1443,6 +1537,14 @@ cd llvm/utils/lit
%global runtimes %{runtimes};offload
%endif
%if %{with libclc} || %{with offload}
%global runtime_targets %{runtime_targets};amdgcn-amd-amdhsa;nvptx64-nvidia-cuda
%endif
%if %{with libclc}
%global runtime_targets %{runtime_targets};spirv32-unknown-unknown;spirv64-unknown-unknown;amdgcn-amd-amdhsa-llvm
%endif
%global gcc_triple --gcc-triple=%{_target_cpu}-redhat-linux
%global cfg_file_content %{gcc_triple}
@ -1514,15 +1616,8 @@ popd
-DLLVM_BUILD_LLVM_DYLIB=ON \\\
-DLLVM_LINK_LLVM_DYLIB=ON \\\
-DCLANG_LINK_CLANG_DYLIB=ON \\\
-DLLVM_ENABLE_FFI:BOOL=ON
%if %{maj_ver} >= 22
%global cmake_common_args %{cmake_common_args} \\\
-DLLVM_ENABLE_FFI:BOOL=ON \\\
-DLLVM_ENABLE_EH=OFF
%else
%global cmake_common_args %{cmake_common_args} \\\
-DLLVM_ENABLE_EH=ON
%endif
%if 0%{?rhel} == 8
# On RHEL 8 we build with gcc, but the runtimes are built with the just built
@ -1565,7 +1660,7 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
-DCLANG_DEFAULT_UNWINDLIB=libgcc \\\
-DCLANG_ENABLE_ARCMT:BOOL=ON \\\
-DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \\\
-DCLANG_INCLUDE_DOCS:BOOL=ON \\\
-DCLANG_INCLUDE_DOCS:BOOL=%{build_docs_toggle} \\\
-DCLANG_INCLUDE_TESTS:BOOL=ON \\\
-DCLANG_PLUGIN_SUPPORT:BOOL=ON \\\
-DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \\\
@ -1592,15 +1687,15 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
# Add all *enabled* documentation targets (no doxygen but sphinx)
%global cmake_config_args %{cmake_config_args} \\\
-DLLVM_ENABLE_DOXYGEN:BOOL=OFF \\\
-DLLVM_ENABLE_SPHINX:BOOL=ON \\\
-DLLVM_BUILD_DOCS:BOOL=ON
-DLLVM_ENABLE_SPHINX:BOOL=%{build_docs_toggle} \\\
-DLLVM_BUILD_DOCS:BOOL=%{build_docs_toggle}
# Configure sphinx:
# Build man-pages but no HTML docs using sphinx
%global cmake_config_args %{cmake_config_args} \\\
-DSPHINX_EXECUTABLE=/usr/bin/sphinx-build-3 \\\
-DSPHINX_OUTPUT_HTML:BOOL=OFF \\\
-DSPHINX_OUTPUT_MAN:BOOL=ON \\\
-DSPHINX_OUTPUT_MAN:BOOL=%{build_docs_toggle} \\\
-DSPHINX_WARNINGS_AS_ERRORS=OFF
#endregion docs options
@ -1612,11 +1707,7 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
%ifarch ppc64le
%global cmake_config_args %{cmake_config_args} -DLLDB_TEST_USER_ARGS=--skip-category=watchpoint
%endif
%if 0%{?rhel} == 8
%global cmake_config_args %{cmake_config_args} -DLLDB_INCLUDE_TESTS:BOOL=OFF
%else
%global cmake_config_args %{cmake_config_args} -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL=ON
%endif
%global cmake_config_args %{cmake_config_args} -DLLDB_INCLUDE_TESTS:BOOL=OFF
%endif
#endregion lldb options
@ -1678,7 +1769,7 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
#region mlir options
%if %{with mlir}
%global cmake_config_args %{cmake_config_args} \\\
-DMLIR_INCLUDE_DOCS:BOOL=ON \\\
-DMLIR_INCLUDE_DOCS:BOOL=%{build_docs_toggle} \\\
-DMLIR_INCLUDE_TESTS:BOOL=ON \\\
-DMLIR_INCLUDE_INTEGRATION_TESTS:BOOL=OFF \\\
-DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF \\\
@ -1693,15 +1784,21 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
-DOPENMP_INSTALL_LIBDIR=%{unprefixed_libdir} \\\
-DLIBOMP_INSTALL_ALIASES=OFF
%if %{maj_ver} >= 22 && %{with offload}
%if %{with offload}
# We reset the cxxflags to "" here because this is compiling for a GPU
# target, where our cflags are either questionable or actively wrong.
%global cmake_config_args %{cmake_config_args} \\\
-DLLVM_RUNTIME_TARGETS='default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda' \\\
-DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=openmp \\\
-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=openmp \\\
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_CXX_FLAGS=""
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_EXE_LINKER_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_EXE_LINKER_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_SHARED_LINKER_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_SHARED_LINKER_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_MODULE_LINKER_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_MODULE_LINKER_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa_CMAKE_STATIC_LINKER_FLAGS="" \\\
-DRUNTIMES_nvptx64-nvidia-cuda_CMAKE_STATIC_LINKER_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES="openmp"
%if 0%{?__isa_bits} == 64
# The following shouldn't be required, but due to a bug, we have to be
@ -1724,7 +1821,7 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
#region flang options
%if %{with flang}
%global cmake_config_args %{cmake_config_args} \\\
-DFLANG_INCLUDE_DOCS:BOOL=ON
-DFLANG_INCLUDE_DOCS:BOOL=%{build_docs_toggle}
# Build both, shared and static flang runtime objects.
# See also https://llvm.org/devmtg/2025-04/slides/quick_talk/kruse_flang-rt.pdf
%global cmake_config_args %{cmake_config_args} \\\
@ -1738,6 +1835,32 @@ CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
%endif
#endregion flang options
#region libclc options
%if %{with libclc}
# Build SPIR-V targets with the SPIR-V backend, reset CXX flags and build libclc
# runtime
%global cmake_config_args %{cmake_config_args} \\\
-DRUNTIMES_spirv32-unknown-unknown_LIBCLC_USE_SPIRV_BACKEND:BOOL=ON \\\
-DRUNTIMES_spirv64-unknown-unknown_LIBCLC_USE_SPIRV_BACKEND:BOOL=ON \\\
-DRUNTIMES_spirv32-unknown-unknown_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_spirv64-unknown-unknown_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_amdgcn-amd-amdhsa-llvm_CMAKE_CXX_FLAGS="" \\\
-DRUNTIMES_spirv32-unknown-unknown_LLVM_ENABLE_RUNTIMES="libclc" \\\
-DRUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES="libclc" \\\
-DRUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES="libclc"
%endif
#endregion libclc options
%if %{with offload} || %{with libclc}
# For the NVIDIA triple we potentially build both, openmp and libclc
%global combined_runtimes %{?with_offload:openmp%{?with_libclc:;}}%{?with_libclc:libclc}
%global cmake_config_args %{cmake_config_args} \\\
-DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES="%{combined_runtimes}"
%global cmake_config_args %{cmake_config_args} \\\
-DLLVM_RUNTIME_TARGETS="%{runtime_targets}"
%endif
#region test options
%global cmake_config_args %{cmake_config_args} \\\
@ -2064,7 +2187,9 @@ install %{build_libdir}/libLLVMTestingSupport.a %{buildroot}%{install_libdir}
install %{build_libdir}/libLLVMTestingAnnotations.a %{buildroot}%{install_libdir}
# Fix multi-lib
%if %{with multilib}
%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h
%endif
%if %{without compat_build}
@ -2138,15 +2263,6 @@ sed -i -e "s|@@CLANG_MAJOR_VERSION@@|%{maj_ver}|" \
-e "s|@@CLANG_PATCH_VERSION@@|%{patch_ver}|" \
%{buildroot}%{_rpmmacrodir}/macros.%{pkg_name_clang}
# install clang python bindings
mkdir -p %{buildroot}%{python3_sitelib}/clang/
# If we don't default to true here, we'll see this error:
# install: omitting directory 'bindings/python/clang/__pycache__'
# NOTE: this only happens if we include the gdb plugin of libomp.
# Remove the plugin with command and we're good: rm -rf %{buildroot}/%{_datarootdir}/gdb
install -p -m644 clang/bindings/python/clang/* %{buildroot}%{python3_sitelib}/clang/
%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/clang
# install scanbuild-py to python sitelib.
mv %{buildroot}%{install_prefix}/lib/{libear,libscanbuild} %{buildroot}%{python3_sitelib}
# Cannot use {libear,libscanbuild} style expansion in py_byte_compile.
@ -2170,6 +2286,15 @@ rm -Rf %{buildroot}%{install_datadir}/clang/*.el
%endif
# install clang python bindings
mkdir -p %{buildroot}%{install_pythondir}/clang/
# If we don't default to true here, we'll see this error:
# install: omitting directory 'bindings/python/clang/__pycache__'
# NOTE: this only happens if we include the gdb plugin of libomp.
# Remove the plugin with command and we're good: rm -rf %{buildroot}/%{_datarootdir}/gdb
install -p -m644 clang/bindings/python/clang/* %{buildroot}%{install_pythondir}/clang/
%py_byte_compile %{__python3} %{buildroot}%{install_pythondir}/clang/
# Create manpage symlink for clang++
ln -s clang-%{maj_ver}.1 %{buildroot}%{install_mandir}/man1/clang++.1
@ -2177,7 +2302,9 @@ ln -s clang-%{maj_ver}.1 %{buildroot}%{install_mandir}/man1/clang++.1
chmod a+x %{buildroot}%{install_datadir}/scan-view/{Reporter.py,startfile.py}
# multilib fix
%if %{with multilib}
%multilib_fix_c_header --file %{install_includedir}/clang/Config/config.h
%endif
# remove editor integrations (bbedit, sublime, emacs, vim)
rm -vf %{buildroot}%{install_datadir}/clang/clang-format-bbedit.applescript
@ -2261,13 +2388,17 @@ rm %{buildroot}%{install_bindir}/llvm-omp-kernel-replay
touch %{buildroot}%{_bindir}/ld
%endif
%if %{build_docs}
install -D -m 644 -t %{buildroot}%{install_mandir}/man1/ lld/docs/ld.lld.1
%endif
#endregion LLD installation
#region LLDB installation
%if %{with lldb}
%if %{with multilib}
%multilib_fix_c_header --file %{install_includedir}/lldb/Host/Config.h
%endif
%if %{without compat_build}
# Move python package out of llvm prefix.
@ -2328,15 +2459,20 @@ rm -v %{buildroot}%{install_libdir}/libFIRAnalysis.a \
%{buildroot}%{install_libdir}/libHLFIRTransforms.a \
%{buildroot}%{install_libdir}/libCUFAttrs.a \
%{buildroot}%{install_libdir}/libCUFDialect.a \
%{buildroot}%{install_libdir}/libFortranDecimal.a
%if %{maj_ver} >= 22
rm -v %{buildroot}%{install_libdir}/libFortranUtils.a \
%{buildroot}%{install_libdir}/libFortranDecimal.a \
%{buildroot}%{install_libdir}/libFortranUtils.a \
%{buildroot}%{install_libdir}/libFIROpenACCAnalysis.a \
%{buildroot}%{install_libdir}/libFIROpenACCTransforms.a \
%{buildroot}%{install_libdir}/libMIFDialect.a
%endif
%if %{maj_ver} < 23
find %{buildroot}%{install_includedir}/flang -type f -a ! -iname '*.mod' -delete
%else
# Remove header files that are only needed for writing plugins.
# TODO: Maybe we should package these in the future.
rm -Rf %{buildroot}%{install_includedir}/flang
%endif
# this is a test binary
rm -v %{buildroot}%{install_bindir}/f18-parse-demo
@ -2389,6 +2525,11 @@ move_and_replace_with_symlinks() {
-exec ln -s --relative "$dest/{}" "$src/{}" \;)
}
%if %{build_docs} == 0
# Install the man pages before the symlinks below are created
cp -v ../%{src_manpage_tarball_dir}/* %{buildroot}%{install_mandir}/man1/
%endif
%if %{without compat_build}
# Move files from the llvm prefix to the system prefix and replace them with
# symlinks. We do it this way around because symlinks between multilib packages
@ -2502,6 +2643,7 @@ function reset_test_opts()
# Set to mark tests as expected to fail.
# See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-xfail
unset LIT_XFAIL
unset LIT_XFAIL_NOT
# Set to mark tests to not even run.
# See https://llvm.org/docs/CommandGuide/lit.html#cmdoption-lit-filter-out
@ -2571,10 +2713,18 @@ reset_test_opts
%cmake_build --target check-lit
#endregion Test LLVM lit
#region Test libclc
%if %{with libclc}
reset_test_opts
%cmake_build --target check-libclc
%endif
#endregion Test libclc
#region Test LLVM
reset_test_opts
# Xfail testing of update utility tools
export LIT_XFAIL="tools/UpdateTestChecks"
%cmake_build --target check-llvm
#endregion Test LLVM
@ -2582,25 +2732,7 @@ export LIT_XFAIL="tools/UpdateTestChecks"
reset_test_opts
export LIT_XFAIL="$LIT_XFAIL;clang/test/CodeGen/profile-filter.c"
%ifarch %ix86
# These tests have been reaching a limit on small i386 servers.
# We don't know exactly which limit is being reached, but python prints
# "RuntimeError: can't start new thread". The issue appears to be related to
# a large number of threads being created very closely while running Sema*
# tests. The failing tests vary from time to time and are usually simple
# tests. The execution appears to recover later, with new threads getting
# created and completing the execution of the remaining tests.
# In order to reduce the number of threads getting created, we split the
# tests in 5 shards, ensuring that less than 5K tests will be executed each
# time.
export LIT_NUM_SHARDS=5
for i in $(seq $LIT_NUM_SHARDS); do
export LIT_RUN_SHARD=$i
%cmake_build --target check-clang
done
%else
%cmake_build --target check-clang
%endif
#endregion Test Clang
#region Test Clang Tools
@ -2860,6 +2992,7 @@ test_list_filter_out+=("MLIR :: python/execution_engine.py")
# if ! LD_SHOW_AUXV=1 /bin/true | grep -q arch_3_00; then
test_list_filter_out+=("MLIR :: python/execution_engine.py")
test_list_filter_out+=("MLIR :: python/multithreaded_tests.py")
test_list_filter_out+=("MLIR :: python/global_constructors.py")
%endif
%if %{with flang}
@ -3078,6 +3211,7 @@ fi
llvm-bcanalyzer
llvm-bitcode-strip
llvm-c-test
llvm-cas
llvm-cat
llvm-cfi-verify
llvm-cgdata
@ -3101,6 +3235,7 @@ fi
llvm-gsymutil
llvm-ifs
llvm-install-name-tool
llvm-ir2vec
llvm-jitlink
llvm-jitlink-executor
llvm-lib
@ -3118,6 +3253,8 @@ fi
llvm-nm
llvm-objcopy
llvm-objdump
llvm-offload-wrapper
llvm-offload-binary
llvm-opt-report
llvm-otool
llvm-pdbutil
@ -3155,17 +3292,10 @@ fi
yaml2obj
}}
%if %{maj_ver} >= 22
%{expand_bins %{expand:
llvm-ir2vec
llvm-offload-wrapper
llvm-offload-binary
}}
%endif
%if %{maj_ver} >= 23
%{expand_bins %{expand:
llubi
llvm-extract-bundle-entry
llvm-gpu-loader
}}
%else
@ -3199,6 +3329,7 @@ fi
llvm-extract
llvm-ifs
llvm-install-name-tool
llvm-ir2vec
llvm-lib
llvm-libtool-darwin
llvm-link
@ -3209,6 +3340,7 @@ fi
llvm-nm
llvm-objcopy
llvm-objdump
llvm-offload-binary
llvm-opt-report
llvm-otool
llvm-pdbutil
@ -3231,16 +3363,10 @@ fi
tblgen
}}
%if %{maj_ver} >= 22
%{expand_mans %{expand:
llvm-ir2vec
llvm-offload-binary
}}
%endif
%if %{maj_ver} >= 23
%{expand_mans %{expand:
llubi
llvm-extract-bundle-entry
}}
%else
%{expand_mans %{expand:
@ -3317,11 +3443,6 @@ fi
llvm-opt-fuzzer
llvm-test-mustache-spec
}}
%if %{maj_ver} >= 22
%{expand_bins %{expand:
llvm-cas
}}
%endif
%{expand_mans %{expand:
llvm-test-mustache-spec
}}
@ -3356,12 +3477,6 @@ fi
}}
%{install_bindir}/clang-%{maj_ver}
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang.cfg
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang++.cfg
%ifarch x86_64
%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-clang.cfg
%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-clang++.cfg
%endif
%{expand_mans clang clang++}
%if 0%{with pgo}
@ -3388,6 +3503,13 @@ fi
%{_libdir}/libclang-cpp.so.%{compat_maj_ver}*
%endif
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang.cfg
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang++.cfg
%ifarch x86_64
%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-clang.cfg
%{_sysconfdir}/%{pkg_name_clang}/i386-redhat-linux-gnu-clang++.cfg
%endif
%files -n %{pkg_name_clang}-devel
%license clang/LICENSE.TXT
%{expand_libs %{expand:
@ -3473,6 +3595,14 @@ fi
offload-arch
}}
%if %{maj_ver} >= 23
%{expand_bins %{expand:
clang-ssaf-analyzer
clang-ssaf-format
clang-ssaf-linker
}}
%endif
%if %{without compat_build}
%{_emacs_sitestartdir}/clang-format.el
%{_emacs_sitestartdir}/clang-include-fixer.el
@ -3495,12 +3625,9 @@ fi
%license clang/LICENSE.TXT
%expand_bins git-clang-format
%if %{without compat_build}
%files -n python%{python3_pkgversion}-clang
%files -n python%{python3_pkgversion}-%{pkg_name_clang}
%license clang/LICENSE.TXT
%{python3_sitelib}/clang/
%endif
%{install_pythondir}/clang/
#endregion CLANG files
#region COMPILER-RT files
@ -3523,14 +3650,9 @@ fi
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtbegin.o
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtend.o
%ifnarch %{ix86} s390x riscv64
%ifnarch %{ix86} riscv64
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a
%endif
%ifarch s390x
%if %{maj_ver} >= 22
%{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a
%endif
%endif
# Additional symlink if two triples are in use.
%if "%{llvm_triple}" != "%{compiler_rt_triple}"
@ -3634,13 +3756,9 @@ fi
lldb-argdumper
lldb-dap
lldb-instr
lldb-mcp
lldb-server
}}
%if %{maj_ver} >= 22
%{expand_bins %{expand:
lldb-mcp
}}
%endif
# Usually, *.so symlinks are kept in devel subpackages. However, the python
# bindings depend on this symlink at runtime.
%{expand_libs %{expand:
@ -3655,12 +3773,10 @@ fi
%files -n %{pkg_name_lldb}-devel
%expand_includes lldb
%if %{maj_ver} >= 22
%{expand_bins %{expand:
lldb-tblgen
yaml2macho-core
}}
%endif
%if %{without compat_build}
%files -n python%{python3_pkgversion}-lldb
@ -3675,6 +3791,7 @@ fi
%files -n %{pkg_name_mlir}
%license LICENSE.TXT
%{expand_libs %{expand:
libmlir_apfloat_wrappers.so.%{maj_ver}*
libmlir_arm_runner_utils.so.%{maj_ver}*
libmlir_arm_sme_abi_stubs.so.%{maj_ver}*
libmlir_async_runtime.so.%{maj_ver}*
@ -3684,12 +3801,6 @@ fi
libMLIR*.so.%{maj_ver}*
}}
%if %{maj_ver} >= 22
%{expand_libs %{expand:
libmlir_apfloat_wrappers.so.%{maj_ver}*
}}
%endif
%files -n %{pkg_name_mlir}-static
%expand_libs libMLIR*.a
@ -3712,6 +3823,7 @@ fi
%expand_includes mlir mlir-c
%{expand_libs %{expand:
cmake/mlir
libmlir_apfloat_wrappers.so
libmlir_arm_runner_utils.so
libmlir_arm_sme_abi_stubs.so
libmlir_async_runtime.so
@ -3721,19 +3833,11 @@ fi
libMLIR*.so
}}
%if %{maj_ver} >= 22
%{expand_libs %{expand:
libmlir_apfloat_wrappers.so
}}
%endif
%files -n python%{python3_pkgversion}-%{pkg_name_mlir}
%{python3_sitearch}/mlir/
%endif
#endregion MLIR files
#region libcxx files
#region flang files
%if %{with flang}
%files -n %{pkg_name_flang}
@ -3748,9 +3852,15 @@ fi
flang-new
}}
%{install_bindir}/flang-%{maj_ver}
%if %{maj_ver} < 23
%{expand_includes %{expand:
flang/*.mod
}}
%else
%{_prefix}/lib/clang/%{maj_ver}/finclude/flang/%{llvm_triple}/*.mod
%{_prefix}/lib/clang/%{maj_ver}/finclude/flang/%{llvm_triple}/omp_lib.h
%endif
%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-flang.cfg
%ifarch x86_64
@ -3767,6 +3877,27 @@ fi
%endif
#region flang files
#region libclc files
%if %{with libclc}
%files -n %{pkg_name_libclc}
%license libclc/LICENSE.TXT
%doc libclc/README.md libclc/CREDITS.TXT
%{_prefix}/lib/clang/%{maj_ver}/lib/amdgcn-amd-amdhsa-llvm/libclc.bc
%{_prefix}/lib/clang/%{maj_ver}/lib/amdgcn-amd-amdhsa-llvm/libclc.a
%{_prefix}/lib/clang/%{maj_ver}/lib/nvptx64-nvidia-cuda/libclc.bc
%{_prefix}/lib/clang/%{maj_ver}/lib/nvptx64-nvidia-cuda/libclc.a
%files -n %{pkg_name_libclc}-spirv
%license libclc/LICENSE.TXT
%doc libclc/README.md libclc/CREDITS.TXT
%{_prefix}/lib/clang/%{maj_ver}/lib/spirv32-unknown-unknown/libclc.spv
%{_prefix}/lib/clang/%{maj_ver}/lib/spirv32-unknown-unknown/libclc.a
%{_prefix}/lib/clang/%{maj_ver}/lib/spirv64-unknown-unknown/libclc.spv
%{_prefix}/lib/clang/%{maj_ver}/lib/spirv64-unknown-unknown/libclc.a
%endif
#endregion libclc files
#region libcxx files
%if %{with libcxx}
%files -n %{pkg_name_libcxx}

View File

@ -1,4 +1,2 @@
SHA512 (llvm-project-21.1.8.src.tar.xz.sig) = 10f58eff58ed6e701d0f123b15e68c82ab8cbdf99b1c86c0d83e3b8553e90ea51055e30327e8e442ded57c8f503e2a2de9ee075e9c28b5ba815a0f8922f8671c
SHA512 (llvm-project-21.1.8.src.tar.xz) = cae4c44e7bf678071723da63ad5839491d717a7233e7f4791aa408207f3ea42f52de939ad15189b112c02a0770f1bb8d59bae6ad31ef53417a6eea7770fe52ab
SHA512 (llvm-project-22.1.1.src.tar.xz) = dddf09651c0e77caa83284788765016b023a9e239cfe35820bab7be64b68218e86bcf39bb07ee14dcddf7b0974b551344d2bff0e109cc9458b0394a3c940917c
SHA512 (llvm-project-22.1.1.src.tar.xz.sig) = 592d603d610e121e7466a342bbf6b95c9a5f689268fad778befbf9e5663b53717c50daab9db07288020e3dcc2ec2bf38d611761a9ff6c3ce10a4340cfc2593c7
SHA512 (llvm-project-22.1.8.src.tar.xz) = 2615b20ba08534f83ab8ecc7b5ba43b5f1dfcf9cdb2534a32fcdbf0ccdd9a008b46276e45ef26ed9377f65b5e4ae89ea798f3863fd034484b5715140f3a7b35c
SHA512 (llvm-project-22.1.8.src.tar.xz.sig) = 99a457b5b1fb409a5fe72b59ebd4ddae5cade3e5f2493e33b44d4f4b4625f7a1743f80106efb1134668842b15ea3400ce2c29263bec8ff986e05040910125e15