From 5cc3babda3e7dc9f9e79c431afe70a3909bbed4c Mon Sep 17 00:00:00 2001 From: liyunfei Date: Thu, 8 May 2025 17:38:28 +0800 Subject: [PATCH 1/9] update to llvm-for-oE-17.0.6-2506.0.1.tar.gz --- .gitattributes | 2 +- ...ckported-test-case-for-CVE-2024-7883.patch | 328 ------------------ ...Fix-for-building-autotuner-with-mlir.patch | 0 ...e-Use-correct-exports-for-MLIR-tools.patch | 39 --- ...r.gz => llvm-for-oE-17.0.6-2506.0.1.tar.gz | 4 +- llvm.spec | 12 +- 6 files changed, 10 insertions(+), 375 deletions(-) delete mode 100644 0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch rename 0007-Fix-for-building-autotuner-with-mlir.patch => 0005-Fix-for-building-autotuner-with-mlir.patch (100%) delete mode 100644 0006-CMake-Use-correct-exports-for-MLIR-tools.patch rename llvm-for-oE-17.0.6-2503.0.2.tar.gz => llvm-for-oE-17.0.6-2506.0.1.tar.gz (32%) diff --git a/.gitattributes b/.gitattributes index 4fceefc..34709aa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -llvm-for-oE-17.0.6-2503.0.2.tar.gz filter=lfs diff=lfs merge=lfs -text +llvm-for-oE-17.0.6-*.tar.gz filter=lfs diff=lfs merge=lfs -text diff --git a/0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch b/0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch deleted file mode 100644 index 5366538..0000000 --- a/0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch +++ /dev/null @@ -1,328 +0,0 @@ -From 2b6df15b2f19ea6cf8186062e496c63637d4753e Mon Sep 17 00:00:00 2001 -From: liyunfei -Date: Wed, 2 Apr 2025 15:39:52 +0800 -Subject: [PATCH] [Bugfix][ARM] fix for backported test case for CVE-2024-7883 - -Fix fail testcase for commit 5188abc4c0ab92102c023b01be26a9ad57492c4b, -which was backported for CVE fix. ---- - .../test/CodeGen/ARM/cmse-clear-float-hard.ll | 68 +++++++++---------- - 1 file changed, 34 insertions(+), 34 deletions(-) - -diff --git a/llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll b/llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll -index f97fc51a0c45..13de25588167 100644 ---- a/llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll -+++ b/llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll -@@ -187,7 +187,7 @@ define float @f2(ptr nocapture %fptr) #2 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-NEXT: bic r1, r1, #159 -@@ -207,7 +207,7 @@ define float @f2(ptr nocapture %fptr) #2 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -245,7 +245,7 @@ define double @d2(ptr nocapture %fptr) #2 { - ; CHECK-8M-LE-NEXT: bic r0, r0, #1 - ; CHECK-8M-LE-NEXT: sub sp, #136 - ; CHECK-8M-LE-NEXT: vmov r11, r12, d0 --; CHECK-8M-LE-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-LE-NEXT: vlstm sp - ; CHECK-8M-LE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-LE-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-LE-NEXT: bic r1, r1, #159 -@@ -264,7 +264,7 @@ define double @d2(ptr nocapture %fptr) #2 { - ; CHECK-8M-LE-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-LE-NEXT: blxns r0 - ; CHECK-8M-LE-NEXT: vmov r11, r12, d0 --; CHECK-8M-LE-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-LE-NEXT: vlldm sp - ; CHECK-8M-LE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-LE-NEXT: add sp, #136 - ; CHECK-8M-LE-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -283,7 +283,7 @@ define double @d2(ptr nocapture %fptr) #2 { - ; CHECK-8M-BE-NEXT: bic r0, r0, #1 - ; CHECK-8M-BE-NEXT: sub sp, #136 - ; CHECK-8M-BE-NEXT: vmov r11, r12, d0 --; CHECK-8M-BE-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-BE-NEXT: vlstm sp - ; CHECK-8M-BE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-BE-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-BE-NEXT: bic r1, r1, #159 -@@ -302,7 +302,7 @@ define double @d2(ptr nocapture %fptr) #2 { - ; CHECK-8M-BE-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-BE-NEXT: blxns r0 - ; CHECK-8M-BE-NEXT: vmov r11, r12, d0 --; CHECK-8M-BE-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-BE-NEXT: vlldm sp - ; CHECK-8M-BE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-BE-NEXT: add sp, #136 - ; CHECK-8M-BE-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -368,7 +368,7 @@ define float @f3(ptr nocapture %fptr) #4 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-NEXT: bic r1, r1, #159 -@@ -388,7 +388,7 @@ define float @f3(ptr nocapture %fptr) #4 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -426,7 +426,7 @@ define double @d3(ptr nocapture %fptr) #4 { - ; CHECK-8M-LE-NEXT: bic r0, r0, #1 - ; CHECK-8M-LE-NEXT: sub sp, #136 - ; CHECK-8M-LE-NEXT: vmov r11, r12, d0 --; CHECK-8M-LE-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-LE-NEXT: vlstm sp - ; CHECK-8M-LE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-LE-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-LE-NEXT: bic r1, r1, #159 -@@ -445,7 +445,7 @@ define double @d3(ptr nocapture %fptr) #4 { - ; CHECK-8M-LE-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-LE-NEXT: blxns r0 - ; CHECK-8M-LE-NEXT: vmov r11, r12, d0 --; CHECK-8M-LE-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-LE-NEXT: vlldm sp - ; CHECK-8M-LE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-LE-NEXT: add sp, #136 - ; CHECK-8M-LE-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -464,7 +464,7 @@ define double @d3(ptr nocapture %fptr) #4 { - ; CHECK-8M-BE-NEXT: bic r0, r0, #1 - ; CHECK-8M-BE-NEXT: sub sp, #136 - ; CHECK-8M-BE-NEXT: vmov r11, r12, d0 --; CHECK-8M-BE-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-BE-NEXT: vlstm sp - ; CHECK-8M-BE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-BE-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-BE-NEXT: bic r1, r1, #159 -@@ -483,7 +483,7 @@ define double @d3(ptr nocapture %fptr) #4 { - ; CHECK-8M-BE-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-BE-NEXT: blxns r0 - ; CHECK-8M-BE-NEXT: vmov r11, r12, d0 --; CHECK-8M-BE-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-BE-NEXT: vlldm sp - ; CHECK-8M-BE-NEXT: vmov d0, r11, r12 - ; CHECK-8M-BE-NEXT: add sp, #136 - ; CHECK-8M-BE-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -548,8 +548,8 @@ define float @f4(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov.f32 s0, s0 -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: mov r1, r0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: mov r3, r0 - ; CHECK-8M-NEXT: mov r4, r0 -@@ -564,7 +564,7 @@ define float @f4(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -600,8 +600,8 @@ define double @d4(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov.f32 s0, s0 -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: mov r1, r0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: mov r3, r0 - ; CHECK-8M-NEXT: mov r4, r0 -@@ -616,7 +616,7 @@ define double @d4(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r11, r12, d0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov d0, r11, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -651,7 +651,7 @@ define void @fd(ptr %f, float %a, double %b) #8 { - ; CHECK-8M-NEXT: vmov r12, s0 - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: vmov r10, r11, d1 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: vmov d1, r10, r11 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] -@@ -668,7 +668,7 @@ define void @fd(ptr %f, float %a, double %b) #8 { - ; CHECK-8M-NEXT: mov r9, r0 - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} - ; CHECK-8M-NEXT: pop {r7, pc} -@@ -710,7 +710,7 @@ define void @fdff(ptr %f, float %a, double %b, float %c, float %d) #8 { - ; CHECK-8M-NEXT: vmov r9, s1 - ; CHECK-8M-NEXT: mov r4, r0 - ; CHECK-8M-NEXT: vmov r8, s4 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: vmov d1, r10, r11 - ; CHECK-8M-NEXT: vmov s1, r9 -@@ -725,7 +725,7 @@ define void @fdff(ptr %f, float %a, double %b, float %c, float %d) #8 { - ; CHECK-8M-NEXT: mov r7, r0 - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} - ; CHECK-8M-NEXT: pop {r7, pc} -@@ -767,7 +767,7 @@ define void @fidififid(ptr %fu, float %a, i32 %b, double %c, i32 %d, float %e, i - ; CHECK-8M-NEXT: vmov r8, s1 - ; CHECK-8M-NEXT: vmov r7, s4 - ; CHECK-8M-NEXT: vmov r5, r6, d3 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r11 - ; CHECK-8M-NEXT: vmov d1, r9, r10 - ; CHECK-8M-NEXT: vmov s1, r8 -@@ -780,7 +780,7 @@ define void @fidififid(ptr %fu, float %a, i32 %b, double %c, i32 %d, float %e, i - ; CHECK-8M-NEXT: mov r4, r12 - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r12 - ; CHECK-8M-NEXT: blxns r12 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} - ; CHECK-8M-NEXT: pop {r7, pc} -@@ -899,7 +899,7 @@ define half @h2(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-NEXT: bic r1, r1, #159 -@@ -919,7 +919,7 @@ define half @h2(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -978,7 +978,7 @@ define half @h3(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-NEXT: bic r1, r1, #159 -@@ -998,7 +998,7 @@ define half @h3(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -1056,8 +1056,8 @@ define half @h4(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov.f32 s0, s0 -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: mov r1, r0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: mov r3, r0 - ; CHECK-8M-NEXT: mov r4, r0 -@@ -1072,7 +1072,7 @@ define half @h4(ptr nocapture %hptr) nounwind { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -1179,7 +1179,7 @@ define half @h1_arg(ptr nocapture %hptr, half %harg) nounwind { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: ldr r1, [sp, #64] - ; CHECK-8M-NEXT: bic r1, r1, #159 -@@ -1199,7 +1199,7 @@ define half @h1_arg(ptr nocapture %hptr, half %harg) nounwind { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -1252,8 +1252,8 @@ define float @float_return_undef_arg(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov.f32 s0, s0 -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: mov r1, r0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: mov r3, r0 - ; CHECK-8M-NEXT: mov r4, r0 -@@ -1268,7 +1268,7 @@ define float @float_return_undef_arg(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} -@@ -1301,8 +1301,8 @@ define float @float_return_poison_arg(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: bic r0, r0, #1 - ; CHECK-8M-NEXT: sub sp, #136 - ; CHECK-8M-NEXT: vmov.f32 s0, s0 -+; CHECK-8M-NEXT: vlstm sp - ; CHECK-8M-NEXT: mov r1, r0 --; CHECK-8M-NEXT: vlstm sp, {d0 - d15} - ; CHECK-8M-NEXT: mov r2, r0 - ; CHECK-8M-NEXT: mov r3, r0 - ; CHECK-8M-NEXT: mov r4, r0 -@@ -1317,7 +1317,7 @@ define float @float_return_poison_arg(ptr nocapture %fptr) #6 { - ; CHECK-8M-NEXT: msr apsr_nzcvqg, r0 - ; CHECK-8M-NEXT: blxns r0 - ; CHECK-8M-NEXT: vmov r12, s0 --; CHECK-8M-NEXT: vlldm sp, {d0 - d15} -+; CHECK-8M-NEXT: vlldm sp - ; CHECK-8M-NEXT: vmov s0, r12 - ; CHECK-8M-NEXT: add sp, #136 - ; CHECK-8M-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11} --- -Gitee diff --git a/0007-Fix-for-building-autotuner-with-mlir.patch b/0005-Fix-for-building-autotuner-with-mlir.patch similarity index 100% rename from 0007-Fix-for-building-autotuner-with-mlir.patch rename to 0005-Fix-for-building-autotuner-with-mlir.patch diff --git a/0006-CMake-Use-correct-exports-for-MLIR-tools.patch b/0006-CMake-Use-correct-exports-for-MLIR-tools.patch deleted file mode 100644 index d147ade..0000000 --- a/0006-CMake-Use-correct-exports-for-MLIR-tools.patch +++ /dev/null @@ -1,39 +0,0 @@ -From b443e55162861125a50048ae9bc521e98058b273 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Mon, 16 Dec 2024 14:44:43 +0100 -Subject: [PATCH] [CMake] Use correct exports file for MLIR tools - -llvm_add_tool() currently does not respect the passed project and -puts all tools into LLVMExports.cmake. This means that we end up -with binaries like mlir-opt in LLVMExports.cmake instead of -MLIRTargets.cmake, where they should be. - -Adjust llvm_add_tool() to take the project into account. ---- - llvm/cmake/modules/AddLLVM.cmake | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake -index 006dfb6de3a199..6cf0ee1a54dbdb 100644 ---- a/llvm/cmake/modules/AddLLVM.cmake -+++ b/llvm/cmake/modules/AddLLVM.cmake -@@ -1483,7 +1483,7 @@ macro(llvm_add_tool project name) - - if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - if( LLVM_BUILD_TOOLS ) -- get_target_export_arg(${name} LLVM export_to_llvmexports) -+ get_target_export_arg(${name} ${project} export_to_llvmexports) - install(TARGETS ${name} - ${export_to_llvmexports} - RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR} -@@ -1497,7 +1497,8 @@ macro(llvm_add_tool project name) - endif() - endif() - if( LLVM_BUILD_TOOLS ) -- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) -+ string(TOUPPER "${project}" project_upper) -+ set_property(GLOBAL APPEND PROPERTY ${project_upper}_EXPORTS ${name}) - endif() - set_target_properties(${name} PROPERTIES FOLDER "Tools") - endif() --- \ No newline at end of file diff --git a/llvm-for-oE-17.0.6-2503.0.2.tar.gz b/llvm-for-oE-17.0.6-2506.0.1.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2503.0.2.tar.gz rename to llvm-for-oE-17.0.6-2506.0.1.tar.gz index d1e8005..231eaac 100644 --- a/llvm-for-oE-17.0.6-2503.0.2.tar.gz +++ b/llvm-for-oE-17.0.6-2506.0.1.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69d108c6097cce7c7ba73346e99fbe75a8f59d5fa573e189bed0fd66e18b39a9 -size 195644037 +oid sha256:db733ac396925145ce00854d8175a66ea87a8b18e808fb00d167148271d644e9 +size 195853097 diff --git a/llvm.spec b/llvm.spec index e16fc53..eed2073 100644 --- a/llvm.spec +++ b/llvm.spec @@ -28,7 +28,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2503.0.2 +%global src_tarball llvm-for-oE-17.0.6-2506.0.1 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 38 +Release: 39 Summary: The Low Level Virtual Machine License: NCSA @@ -171,10 +171,8 @@ Patch0003: 0003-fedora-standalone.patch %if %{os_version} <= 2003 Patch0004: 0004-remove-cmake_minimum_required.patch %endif -Patch0005: 0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch -Patch0006: 0006-CMake-Use-correct-exports-for-MLIR-tools.patch %if %{with bisheng_autotuner} -Patch0007: 0007-Fix-for-building-autotuner-with-mlir.patch +Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif BuildRequires: gcc @@ -2855,6 +2853,10 @@ fi #endregion files %changelog +* Thu May 08 2025 liyunfei - 17.0.6-39 +- update to llvm-for-oe-17.0.6-2506.0.1 +- release-note https://gitee.com/openeuler/llvm-project/compare/llvm-for-oE-17.0.6-2503.0.2...llvm-for-oE-17.0.6-2506.0.1 + * Tue Apr 22 2025 liyunfei - 17.0.6-38 - llvm-mlir add obsoletes mlir - openmp add obsoletes libomp -- Gitee From 1d73ac2338f80da8951cfb7e02d6ddbef0a54235 Mon Sep 17 00:00:00 2001 From: chenli Date: Thu, 8 May 2025 20:16:36 +0800 Subject: [PATCH 2/9] [LoongArch] Fix sys_llvm build --- ...-Fix-compile-error-after-commit-5298.patch | 26 ++++++++++++ llvm.spec | 40 +++++++++++++++++-- 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch diff --git a/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch b/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch new file mode 100644 index 0000000..3d4c73c --- /dev/null +++ b/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch @@ -0,0 +1,26 @@ +From 256de0c8f68e8dc906256a2eecea0a53229966b0 Mon Sep 17 00:00:00 2001 +From: chenli +Date: Fri, 9 May 2025 15:32:29 +0800 +Subject: [PATCH] [openmp][LoongArch] Fix compile error after commit + 5298e93560ddd + +--- + openmp/runtime/src/kmp_platform.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/openmp/runtime/src/kmp_platform.h b/openmp/runtime/src/kmp_platform.h +index 780ff3b185b3..d9fa8a7a4a91 100644 +--- a/openmp/runtime/src/kmp_platform.h ++++ b/openmp/runtime/src/kmp_platform.h +@@ -210,7 +210,7 @@ + // TODO: Fixme - This is clever, but really fugly + #if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \ + KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \ +- KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH6464 + KMP_ARCH_SW64) ++ KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_SW64) + #error Unknown or unsupported architecture + #endif + +-- +2.20.1 + diff --git a/llvm.spec b/llvm.spec index eed2073..3bb869c 100644 --- a/llvm.spec +++ b/llvm.spec @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 39 +Release: 40 Summary: The Low Level Virtual Machine License: NCSA @@ -174,6 +174,7 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif +Patch0006: 0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -1906,6 +1907,33 @@ export LIT_XFAIL="$LIT_XFAIL;mlir-pdll-lsp-server/view-output.test" export LIT_XFAIL="$LIT_XFAIL;Target/LLVMIR/arm-sme.mlir" +# Following testcases depend on MCJIT which is not supported on LoongArch. +%ifarch loongarch64 +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/async-error.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/async-func.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/async-group.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/async-value.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/async.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/bare-ptr-call-conv.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/copy.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/expand-arith-ops.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/global-memref.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/math-polynomial-approx.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/memref-reinterpret-cast.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/memref-reshape.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/print.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/sgemm-naive-codegen.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/simple.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/test-expand-math-approx.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/unranked-memref.mlir" +export LIT_XFAIL="$LIT_XFAIL;mlir-cpu-runner/utils.mlir" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/4/10" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/5/10" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/6/10" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/7/10" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/8/10" +export LIT_XFAIL="$LIT_XFAIL;ExecutionEngine/./MLIRExecutionEngineTests/9/10" +%endif # The ml_dtypes python module required by mlir/test/python/execution_engine.py # isn't packaged. test_list_filter_out+=("MLIR :: python/execution_engine.py") @@ -2569,7 +2597,7 @@ fi %{_prefix}/lib/clang/%{maj_ver}/lib/%{compiler_rt_triple}/clang_rt.crtend.o %endif -%ifnarch %{ix86} s390x riscv64 +%ifnarch %{ix86} s390x riscv64 loongarch64 %{install_libdir}/clang/%{maj_ver}/lib/%{compiler_rt_triple}/liborc_rt.a %endif @@ -2622,7 +2650,7 @@ fi %ifnarch %{ix86} # libomptarget is not supported on 32-bit systems. # s390x does not support the offloading plugins. -%ifnarch riscv64 +%ifnarch riscv64 loongarch64 %{install_libdir}/libomptarget.rtl.amdgpu.so %{install_libdir}/libomptarget.rtl.cuda.so %{install_libdir}/libomptarget.rtl.%{libomp_arch}.so @@ -2853,6 +2881,12 @@ fi #endregion files %changelog +* Thu May 08 2025 chenli - 17.0.6-40 +- LoongArch: Fix mlir testcases which depend on MCJIT +- LoongArch: Fix liborc_rt.a file not found +- LoongArch: Fix openmp build +- LoongArch: Fix libomptarget.rtl.amdgpu|cuda|loonarch64.so file not found + * Thu May 08 2025 liyunfei - 17.0.6-39 - update to llvm-for-oe-17.0.6-2506.0.1 - release-note https://gitee.com/openeuler/llvm-project/compare/llvm-for-oE-17.0.6-2503.0.2...llvm-for-oE-17.0.6-2506.0.1 -- Gitee From a2410a15bfcbbc74e90fc7024d4935964a64de82 Mon Sep 17 00:00:00 2001 From: wangqiang Date: Fri, 30 May 2025 16:30:24 +0800 Subject: [PATCH 3/9] Modified python3-lldb dependency to require exact version match Signed-off-by: wangqiang --- llvm.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm.spec b/llvm.spec index 3bb869c..774e7b8 100644 --- a/llvm.spec +++ b/llvm.spec @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 40 +Release: 41 Summary: The Low Level Virtual Machine License: NCSA @@ -593,7 +593,7 @@ URL: http://lldb.llvm.org/ Requires: %{pkg_name_clang}-libs%{?_isa} = %{version}-%{release} %if %{with sys_llvm} -Requires: python%{python3_pkgversion}-lldb +Requires: python%{python3_pkgversion}-lldb = %{version}-%{release} %endif %description -n %{pkg_name_lldb} @@ -2881,6 +2881,9 @@ fi #endregion files %changelog +* Thu May 29 2025 wangqiang - 17.0.6-41 +- Modified python3-lldb dependency to require exact version match + * Thu May 08 2025 chenli - 17.0.6-40 - LoongArch: Fix mlir testcases which depend on MCJIT - LoongArch: Fix liborc_rt.a file not found -- Gitee From 3fe9f7599f19383273250e9923092b26ab4dca7f Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 4 Jun 2025 11:27:09 +0800 Subject: [PATCH 4/9] update to llvm-for-oe-17.0.6-2506.0.2 Signed-off-by: liyunfei --- ...-Fix-compile-error-after-commit-5298.patch | 26 ------------------- ...r.gz => llvm-for-oE-17.0.6-2506.0.2.tar.gz | 4 +-- llvm.spec | 12 ++++++--- 3 files changed, 11 insertions(+), 31 deletions(-) delete mode 100644 0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch rename llvm-for-oE-17.0.6-2506.0.1.tar.gz => llvm-for-oE-17.0.6-2506.0.2.tar.gz (32%) diff --git a/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch b/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch deleted file mode 100644 index 3d4c73c..0000000 --- a/0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 256de0c8f68e8dc906256a2eecea0a53229966b0 Mon Sep 17 00:00:00 2001 -From: chenli -Date: Fri, 9 May 2025 15:32:29 +0800 -Subject: [PATCH] [openmp][LoongArch] Fix compile error after commit - 5298e93560ddd - ---- - openmp/runtime/src/kmp_platform.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/openmp/runtime/src/kmp_platform.h b/openmp/runtime/src/kmp_platform.h -index 780ff3b185b3..d9fa8a7a4a91 100644 ---- a/openmp/runtime/src/kmp_platform.h -+++ b/openmp/runtime/src/kmp_platform.h -@@ -210,7 +210,7 @@ - // TODO: Fixme - This is clever, but really fugly - #if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \ - KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \ -- KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH6464 + KMP_ARCH_SW64) -+ KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_SW64) - #error Unknown or unsupported architecture - #endif - --- -2.20.1 - diff --git a/llvm-for-oE-17.0.6-2506.0.1.tar.gz b/llvm-for-oE-17.0.6-2506.0.2.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2506.0.1.tar.gz rename to llvm-for-oE-17.0.6-2506.0.2.tar.gz index 231eaac..05523a6 100644 --- a/llvm-for-oE-17.0.6-2506.0.1.tar.gz +++ b/llvm-for-oE-17.0.6-2506.0.2.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db733ac396925145ce00854d8175a66ea87a8b18e808fb00d167148271d644e9 -size 195853097 +oid sha256:5de6b25269c51cdaec2b4c296fe13d8ed07440e052c66c5d054f8199f41e7937 +size 212517798 diff --git a/llvm.spec b/llvm.spec index 774e7b8..42e9262 100644 --- a/llvm.spec +++ b/llvm.spec @@ -28,7 +28,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2506.0.1 +%global src_tarball llvm-for-oE-17.0.6-2506.0.2 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 41 +Release: 42 Summary: The Low Level Virtual Machine License: NCSA @@ -174,7 +174,6 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif -Patch0006: 0006-openmp-LoongArch-Fix-compile-error-after-commit-5298.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -1663,6 +1662,8 @@ reset_test_opts reset_test_opts # Xfail testing of update utility tools export LIT_XFAIL="tools/UpdateTestChecks" +# Todo: temporarily block this testcase +export LIT_XFAIL="$LIT_XFAIL;CodeGen/X86/machine-function-splitter.ll" %build_tool %cmake_target_opts check-llvm #endregion Test LLVM @@ -2881,6 +2882,11 @@ fi #endregion files %changelog +* Wed Jun 04 2025 liyunfei - 17.0.6-42 +- update to llvm-for-oe-17.0.6-2506.0.2 +- release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.2 +- add a small patch for backport testcase issue fix + * Thu May 29 2025 wangqiang - 17.0.6-41 - Modified python3-lldb dependency to require exact version match -- Gitee From 7aa623e7975987e747769105c6e32c833417d3b6 Mon Sep 17 00:00:00 2001 From: hongjinghao Date: Wed, 11 Jun 2025 14:56:08 +0800 Subject: [PATCH 5/9] llvm-doc delete unused Requires (llvm) --- llvm.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm.spec b/llvm.spec index 42e9262..eff2ea2 100644 --- a/llvm.spec +++ b/llvm.spec @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 42 +Release: 43 Summary: The Low Level Virtual Machine License: NCSA @@ -322,7 +322,6 @@ programs that use the LLVM infrastructure. %package -n %{pkg_name_llvm}-doc Summary: Documentation for LLVM BuildArch: noarch -Requires: %{pkg_name_llvm} = %{version}-%{release} Provides: %{pkg_name_llvm}-help = %{version}-%{release} Obsoletes: %{pkg_name_llvm}-help < %{version}-%{release} @@ -2882,6 +2881,9 @@ fi #endregion files %changelog +* Wed Jun 11 2025 hongjinghao - 17.0.6-43 +- llvm-doc delete unused Requires (llvm) + * Wed Jun 04 2025 liyunfei - 17.0.6-42 - update to llvm-for-oe-17.0.6-2506.0.2 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.2 -- Gitee From bf0f154a62e5bd3453127ac0a3fd57528abd3ae0 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Thu, 12 Jun 2025 10:02:31 +0800 Subject: [PATCH 6/9] update to llvm-for-oe-17.0.6-2506.0.3 --- ...06.0.2.tar.gz => llvm-for-oE-17.0.6-2506.0.3.tar.gz | 4 ++-- llvm.spec | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) rename llvm-for-oE-17.0.6-2506.0.2.tar.gz => llvm-for-oE-17.0.6-2506.0.3.tar.gz (32%) diff --git a/llvm-for-oE-17.0.6-2506.0.2.tar.gz b/llvm-for-oE-17.0.6-2506.0.3.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2506.0.2.tar.gz rename to llvm-for-oE-17.0.6-2506.0.3.tar.gz index 05523a6..f44baa6 100644 --- a/llvm-for-oE-17.0.6-2506.0.2.tar.gz +++ b/llvm-for-oE-17.0.6-2506.0.3.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5de6b25269c51cdaec2b4c296fe13d8ed07440e052c66c5d054f8199f41e7937 -size 212517798 +oid sha256:884dd9c9e4673f44d37fd6229ab8c63723c9c52f0ffe2c0c856a5820f11979a0 +size 212535248 diff --git a/llvm.spec b/llvm.spec index eff2ea2..bb7d651 100644 --- a/llvm.spec +++ b/llvm.spec @@ -28,7 +28,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2506.0.2 +%global src_tarball llvm-for-oE-17.0.6-2506.0.3 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 43 +Release: 44 Summary: The Low Level Virtual Machine License: NCSA @@ -1661,8 +1661,6 @@ reset_test_opts reset_test_opts # Xfail testing of update utility tools export LIT_XFAIL="tools/UpdateTestChecks" -# Todo: temporarily block this testcase -export LIT_XFAIL="$LIT_XFAIL;CodeGen/X86/machine-function-splitter.ll" %build_tool %cmake_target_opts check-llvm #endregion Test LLVM @@ -2881,6 +2879,10 @@ fi #endregion files %changelog +* Thu Jun 12 2025 liyunfei - 17.0.6-44 +- update to llvm-for-oe-17.0.6-2506.0.3 +- release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.3 + * Wed Jun 11 2025 hongjinghao - 17.0.6-43 - llvm-doc delete unused Requires (llvm) -- Gitee From c1881366010461632e94bc093023a12dff6299f0 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Fri, 13 Jun 2025 16:47:42 +0800 Subject: [PATCH 7/9] [ICP] Enable promotion of more targets --- ...ICP-Enable-promotion-of-more-targets.patch | 211 ++++++++++++++++++ 0007-bugfix-Constant-fold-logl-call.patch | 26 +++ llvm.spec | 11 +- 3 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 0006-ICP-Enable-promotion-of-more-targets.patch create mode 100644 0007-bugfix-Constant-fold-logl-call.patch diff --git a/0006-ICP-Enable-promotion-of-more-targets.patch b/0006-ICP-Enable-promotion-of-more-targets.patch new file mode 100644 index 0000000..c5541f2 --- /dev/null +++ b/0006-ICP-Enable-promotion-of-more-targets.patch @@ -0,0 +1,211 @@ +From 5fe24e3f1a7881d421fea7f71d59ff2f1288938d Mon Sep 17 00:00:00 2001 +From: "y00495115]" +Date: Fri, 13 Jun 2025 16:50:06 +0800 +Subject: [PATCH] [ICP] Enable promotion of more targets + +--- + .../llvm/Analysis/ProfileSummaryInfo.h | 3 +- + llvm/include/llvm/ProfileData/ProfileCommon.h | 1 + + llvm/lib/Analysis/ProfileSummaryInfo.cpp | 7 +- + .../lib/ProfileData/ProfileSummaryBuilder.cpp | 16 ++++ + .../Instrumentation/IndirectCallPromotion.cpp | 4 +- + .../indirect_call_promotion_enhanced.ll | 81 +++++++++++++++++++ + 6 files changed, 108 insertions(+), 4 deletions(-) + create mode 100644 llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll + +diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +index 38eb71ba271d..4ee54f592e2c 100644 +--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h ++++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +@@ -46,6 +46,7 @@ private: + void computeThresholds(); + // Count thresholds to answer isHotCount and isColdCount queries. + std::optional HotCountThreshold, ColdCountThreshold; ++ std::optional HotCountThresholdICP; + // True if the working set size of the code is considered huge, + // because the number of profile counts required to reach the hot + // percentile is above a huge threshold. +@@ -179,7 +180,7 @@ public: + PercentileCutoff, F, BFI); + } + /// Returns true if count \p C is considered hot. +- bool isHotCount(uint64_t C) const; ++ bool isHotCount(uint64_t C, bool isForICP = false) const; + /// Returns true if count \p C is considered cold. + bool isColdCount(uint64_t C) const; + /// Returns true if count \p C is considered hot with regard to a given +diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h +index 4fe92cef4d72..8a0a5a82cfcd 100644 +--- a/llvm/include/llvm/ProfileData/ProfileCommon.h ++++ b/llvm/include/llvm/ProfileData/ProfileCommon.h +@@ -65,6 +65,7 @@ public: + static const ProfileSummaryEntry & + getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile); + static uint64_t getHotCountThreshold(const SummaryEntryVector &DS); ++ static uint64_t getHotCountThresholdForICP(const SummaryEntryVector &DS); + static uint64_t getColdCountThreshold(const SummaryEntryVector &DS); + }; + +diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp +index 203f1e42733f..de855bd7def6 100644 +--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp ++++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp +@@ -124,6 +124,8 @@ void ProfileSummaryInfo::computeThresholds() { + DetailedSummary, ProfileSummaryCutoffHot); + HotCountThreshold = + ProfileSummaryBuilder::getHotCountThreshold(DetailedSummary); ++ HotCountThresholdICP = ++ ProfileSummaryBuilder::getHotCountThresholdForICP(DetailedSummary); + ColdCountThreshold = + ProfileSummaryBuilder::getColdCountThreshold(DetailedSummary); + assert(ColdCountThreshold <= HotCountThreshold && +@@ -171,7 +173,10 @@ bool ProfileSummaryInfo::hasLargeWorkingSetSize() const { + return HasLargeWorkingSetSize && *HasLargeWorkingSetSize; + } + +-bool ProfileSummaryInfo::isHotCount(uint64_t C) const { ++bool ProfileSummaryInfo::isHotCount(uint64_t C, bool isForICP) const { ++ if (isForICP) { ++ return HotCountThresholdICP && C >= *HotCountThresholdICP; ++ } + return HotCountThreshold && C >= *HotCountThreshold; + } + +diff --git a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp +index 8e07478fb083..29ef5d0d7300 100644 +--- a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp ++++ b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp +@@ -35,6 +35,12 @@ cl::opt ProfileSummaryCutoffHot( + cl::desc("A count is hot if it exceeds the minimum count to" + " reach this percentile of total counts.")); + ++cl::opt ProfileSummaryCutoffHotICP( ++ "profile-summary-cutoff-hot-icp", cl::Hidden, cl::init(990000), ++ cl::desc("A count is hot in the context of ICP, if it exceeds the minimum " ++ "count to" ++ " reach this percentile of total counts.")); ++ + cl::opt ProfileSummaryCutoffCold( + "profile-summary-cutoff-cold", cl::Hidden, cl::init(999999), + cl::desc("A count is cold if it is below the minimum count" +@@ -172,6 +178,16 @@ ProfileSummaryBuilder::getHotCountThreshold(const SummaryEntryVector &DS) { + return HotCountThreshold; + } + ++uint64_t ProfileSummaryBuilder::getHotCountThresholdForICP( ++ const SummaryEntryVector &DS) { ++ auto &HotEntry = ProfileSummaryBuilder::getEntryForPercentile( ++ DS, ProfileSummaryCutoffHotICP); ++ uint64_t HotCountThresholdICP = HotEntry.MinCount; ++ if (ProfileSummaryHotCount.getNumOccurrences() > 0) ++ HotCountThresholdICP = ProfileSummaryHotCount; ++ return HotCountThresholdICP; ++} ++ + uint64_t + ProfileSummaryBuilder::getColdCountThreshold(const SummaryEntryVector &DS) { + auto &ColdEntry = ProfileSummaryBuilder::getEntryForPercentile( +diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +index 5c9799235017..146fa3e06996 100644 +--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp ++++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +@@ -302,8 +302,8 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) { + uint64_t TotalCount; + auto ICallProfDataRef = ICallAnalysis.getPromotionCandidatesForInstruction( + CB, NumVals, TotalCount, NumCandidates); +- if (!NumCandidates || +- (PSI && PSI->hasProfileSummary() && !PSI->isHotCount(TotalCount))) ++ if (!NumCandidates || (PSI && PSI->hasProfileSummary() && ++ !PSI->isHotCount(TotalCount, /*isForICP=*/true))) + continue; + auto PromotionCandidates = getPromotionCandidatesForCallSite( + *CB, ICallProfDataRef, TotalCount, NumCandidates); +diff --git a/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll b/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll +new file mode 100644 +index 000000000000..b5031ca82a3e +--- /dev/null ++++ b/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll +@@ -0,0 +1,81 @@ ++; RUN: opt < %s -passes=pgo-icall-prom -profile-summary-cutoff-hot-icp=200000 -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefix=PASS-REMARK ++; RUN: opt < %s -passes=pgo-icall-prom -profile-summary-cutoff-hot-icp=100000 -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefix=FAIL-REMARK ++ ++; PASS-REMARK: remark: :0:0: Promote indirect call to func4 with count 5 out of 14 ++; PASS-REMARK: remark: :0:0: Promote indirect call to func2 with count 4 out of 9 ++; PASS-REMARK: remark: :0:0: Promote indirect call to func3 with count 3 out of 5 ++ ++; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func4 ++; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func2 ++; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func3 ++ ++target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" ++target triple = "x86_64-unknown-linux-gnu" ++ ++@foo = common global ptr null, align 8 ++ ++define i32 @func1() { ++entry: ++ ret i32 0 ++} ++ ++define i32 @func2() { ++entry: ++ ret i32 1 ++} ++ ++define i32 @func3() { ++entry: ++ ret i32 2 ++} ++ ++define i32 @func4() { ++entry: ++ ret i32 3 ++} ++ ++define i32 @bar() { ++entry: ++ %tmp = load ptr, ptr @foo, align 8 ++ %call = call i32 %tmp(), !prof !34 ++ ret i32 %call ++} ++ ++ ++!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} ++ ++!0 = !{i32 1, !"wchar_size", i32 4} ++!1 = !{i32 7, !"PIC Level", i32 2} ++!2 = !{i32 7, !"PIE Level", i32 2} ++!3 = !{i32 7, !"uwtable", i32 2} ++!4 = !{i32 7, !"frame-pointer", i32 1} ++!5 = !{i32 1, !"ProfileSummary", !6} ++!6 = !{!7, !8, !9, !10, !11, !12, !13, !14, !15, !16} ++!7 = !{!"ProfileFormat", !"InstrProf"} ++!8 = !{!"TotalCount", i64 3} ++!9 = !{!"MaxCount", i64 1} ++!10 = !{!"MaxInternalCount", i64 1} ++!11 = !{!"MaxFunctionCount", i64 1} ++!12 = !{!"NumCounts", i64 7} ++!13 = !{!"NumFunctions", i64 4} ++!14 = !{!"IsPartialProfile", i64 0} ++!15 = !{!"PartialProfileRatio", double 0.000000e+00} ++!16 = !{!"DetailedSummary", !17} ++!17 = !{!18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33} ++!18 = !{i32 10000, i64 16, i32 1} ++!19 = !{i32 100000, i64 15, i32 2} ++!20 = !{i32 200000, i64 14, i32 3} ++!21 = !{i32 300000, i64 13, i32 4} ++!22 = !{i32 400000, i64 12, i32 5} ++!23 = !{i32 500000, i64 11, i32 6} ++!24 = !{i32 600000, i64 10, i32 7} ++!25 = !{i32 700000, i64 9, i32 8} ++!26 = !{i32 800000, i64 8, i32 9} ++!27 = !{i32 900000, i64 7, i32 10} ++!28 = !{i32 950000, i64 6, i32 11} ++!29 = !{i32 990000, i64 5, i32 12} ++!30 = !{i32 999000, i64 4, i32 13} ++!31 = !{i32 999900, i64 3, i32 14} ++!32 = !{i32 999990, i64 2, i32 15} ++!33 = !{i32 999999, i64 1, i32 16} ++!34 = !{!"VP", i32 0, i64 14, i64 7651369219802541373, i64 5, i64 -4377547752858689819, i64 4, i64 -6929281286627296573, i64 3, i64 -2545542355363006406, i64 2} +-- +Gitee diff --git a/0007-bugfix-Constant-fold-logl-call.patch b/0007-bugfix-Constant-fold-logl-call.patch new file mode 100644 index 0000000..e62c67c --- /dev/null +++ b/0007-bugfix-Constant-fold-logl-call.patch @@ -0,0 +1,26 @@ +From 50c0b5564a0b88f9b5f3ad7891cb9d341c738cd8 Mon Sep 17 00:00:00 2001 +From: llvmssh +Date: Sat, 14 Jun 2025 14:16:12 +0800 +Subject: [PATCH] Constant fold logl call + +--- + llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp +index 449de7ce314d..3da9c9b293eb 100644 +--- a/llvm/lib/Analysis/ConstantFolding.cpp ++++ b/llvm/lib/Analysis/ConstantFolding.cpp +@@ -2136,8 +2136,8 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, + } + + LibFunc Fp128Func = NotLibFunc; +- if (TLI->getLibFunc(Name, Fp128Func) && TLI->has(Fp128Func) && +- Fp128Func == LibFunc_logl) ++ if (Name == "logl" && TLI->getLibFunc(Name, Fp128Func) && ++ TLI->has(Fp128Func) && Fp128Func == LibFunc_logl) + if (EnableLoglConstantFold) + return ConstantFoldFP128(logf128, Op->getValueAPF(), Ty); + } +-- +Gitee diff --git a/llvm.spec b/llvm.spec index bb7d651..31a69e1 100644 --- a/llvm.spec +++ b/llvm.spec @@ -9,7 +9,7 @@ # Build sys_llvm packages or compat packages %bcond_without sys_llvm %bcond_without check -%bcond_without toolchain_clang +%bcond_with toolchain_clang %bcond_without bisheng_autotuner %bcond_without ACPO @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 44 +Release: 45 Summary: The Low Level Virtual Machine License: NCSA @@ -174,6 +174,8 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif +Patch0006: 0006-ICP-Enable-promotion-of-more-targets.patch +Patch0007: 0007-bugfix-Constant-fold-logl-call.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -2879,6 +2881,11 @@ fi #endregion files %changelog +* Fri Jun 13 2025 liyunfei - 17.0.6-45 +- [ICP] Enable promotion of more targets +- [bugfix] Constant folding for long double type lib call is only supported for logl. +- switch to gcc build for bootstrap building failure + * Thu Jun 12 2025 liyunfei - 17.0.6-44 - update to llvm-for-oe-17.0.6-2506.0.3 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.3 -- Gitee From 3c50dc723a1394efef69f564a21a6b96d4407ef9 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Wed, 18 Jun 2025 09:06:41 +0800 Subject: [PATCH 8/9] update to llvm-for-oe-17.0.6-2506.0.4 for bugfix --- ...ICP-Enable-promotion-of-more-targets.patch | 211 ------------------ 0007-bugfix-Constant-fold-logl-call.patch | 26 --- ...r.gz => llvm-for-oE-17.0.6-2506.0.4.tar.gz | 4 +- llvm.spec | 12 +- 4 files changed, 9 insertions(+), 244 deletions(-) delete mode 100644 0006-ICP-Enable-promotion-of-more-targets.patch delete mode 100644 0007-bugfix-Constant-fold-logl-call.patch rename llvm-for-oE-17.0.6-2506.0.3.tar.gz => llvm-for-oE-17.0.6-2506.0.4.tar.gz (32%) diff --git a/0006-ICP-Enable-promotion-of-more-targets.patch b/0006-ICP-Enable-promotion-of-more-targets.patch deleted file mode 100644 index c5541f2..0000000 --- a/0006-ICP-Enable-promotion-of-more-targets.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 5fe24e3f1a7881d421fea7f71d59ff2f1288938d Mon Sep 17 00:00:00 2001 -From: "y00495115]" -Date: Fri, 13 Jun 2025 16:50:06 +0800 -Subject: [PATCH] [ICP] Enable promotion of more targets - ---- - .../llvm/Analysis/ProfileSummaryInfo.h | 3 +- - llvm/include/llvm/ProfileData/ProfileCommon.h | 1 + - llvm/lib/Analysis/ProfileSummaryInfo.cpp | 7 +- - .../lib/ProfileData/ProfileSummaryBuilder.cpp | 16 ++++ - .../Instrumentation/IndirectCallPromotion.cpp | 4 +- - .../indirect_call_promotion_enhanced.ll | 81 +++++++++++++++++++ - 6 files changed, 108 insertions(+), 4 deletions(-) - create mode 100644 llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll - -diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h -index 38eb71ba271d..4ee54f592e2c 100644 ---- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h -+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h -@@ -46,6 +46,7 @@ private: - void computeThresholds(); - // Count thresholds to answer isHotCount and isColdCount queries. - std::optional HotCountThreshold, ColdCountThreshold; -+ std::optional HotCountThresholdICP; - // True if the working set size of the code is considered huge, - // because the number of profile counts required to reach the hot - // percentile is above a huge threshold. -@@ -179,7 +180,7 @@ public: - PercentileCutoff, F, BFI); - } - /// Returns true if count \p C is considered hot. -- bool isHotCount(uint64_t C) const; -+ bool isHotCount(uint64_t C, bool isForICP = false) const; - /// Returns true if count \p C is considered cold. - bool isColdCount(uint64_t C) const; - /// Returns true if count \p C is considered hot with regard to a given -diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h -index 4fe92cef4d72..8a0a5a82cfcd 100644 ---- a/llvm/include/llvm/ProfileData/ProfileCommon.h -+++ b/llvm/include/llvm/ProfileData/ProfileCommon.h -@@ -65,6 +65,7 @@ public: - static const ProfileSummaryEntry & - getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile); - static uint64_t getHotCountThreshold(const SummaryEntryVector &DS); -+ static uint64_t getHotCountThresholdForICP(const SummaryEntryVector &DS); - static uint64_t getColdCountThreshold(const SummaryEntryVector &DS); - }; - -diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp -index 203f1e42733f..de855bd7def6 100644 ---- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp -+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp -@@ -124,6 +124,8 @@ void ProfileSummaryInfo::computeThresholds() { - DetailedSummary, ProfileSummaryCutoffHot); - HotCountThreshold = - ProfileSummaryBuilder::getHotCountThreshold(DetailedSummary); -+ HotCountThresholdICP = -+ ProfileSummaryBuilder::getHotCountThresholdForICP(DetailedSummary); - ColdCountThreshold = - ProfileSummaryBuilder::getColdCountThreshold(DetailedSummary); - assert(ColdCountThreshold <= HotCountThreshold && -@@ -171,7 +173,10 @@ bool ProfileSummaryInfo::hasLargeWorkingSetSize() const { - return HasLargeWorkingSetSize && *HasLargeWorkingSetSize; - } - --bool ProfileSummaryInfo::isHotCount(uint64_t C) const { -+bool ProfileSummaryInfo::isHotCount(uint64_t C, bool isForICP) const { -+ if (isForICP) { -+ return HotCountThresholdICP && C >= *HotCountThresholdICP; -+ } - return HotCountThreshold && C >= *HotCountThreshold; - } - -diff --git a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp -index 8e07478fb083..29ef5d0d7300 100644 ---- a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp -+++ b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp -@@ -35,6 +35,12 @@ cl::opt ProfileSummaryCutoffHot( - cl::desc("A count is hot if it exceeds the minimum count to" - " reach this percentile of total counts.")); - -+cl::opt ProfileSummaryCutoffHotICP( -+ "profile-summary-cutoff-hot-icp", cl::Hidden, cl::init(990000), -+ cl::desc("A count is hot in the context of ICP, if it exceeds the minimum " -+ "count to" -+ " reach this percentile of total counts.")); -+ - cl::opt ProfileSummaryCutoffCold( - "profile-summary-cutoff-cold", cl::Hidden, cl::init(999999), - cl::desc("A count is cold if it is below the minimum count" -@@ -172,6 +178,16 @@ ProfileSummaryBuilder::getHotCountThreshold(const SummaryEntryVector &DS) { - return HotCountThreshold; - } - -+uint64_t ProfileSummaryBuilder::getHotCountThresholdForICP( -+ const SummaryEntryVector &DS) { -+ auto &HotEntry = ProfileSummaryBuilder::getEntryForPercentile( -+ DS, ProfileSummaryCutoffHotICP); -+ uint64_t HotCountThresholdICP = HotEntry.MinCount; -+ if (ProfileSummaryHotCount.getNumOccurrences() > 0) -+ HotCountThresholdICP = ProfileSummaryHotCount; -+ return HotCountThresholdICP; -+} -+ - uint64_t - ProfileSummaryBuilder::getColdCountThreshold(const SummaryEntryVector &DS) { - auto &ColdEntry = ProfileSummaryBuilder::getEntryForPercentile( -diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp -index 5c9799235017..146fa3e06996 100644 ---- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp -+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp -@@ -302,8 +302,8 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) { - uint64_t TotalCount; - auto ICallProfDataRef = ICallAnalysis.getPromotionCandidatesForInstruction( - CB, NumVals, TotalCount, NumCandidates); -- if (!NumCandidates || -- (PSI && PSI->hasProfileSummary() && !PSI->isHotCount(TotalCount))) -+ if (!NumCandidates || (PSI && PSI->hasProfileSummary() && -+ !PSI->isHotCount(TotalCount, /*isForICP=*/true))) - continue; - auto PromotionCandidates = getPromotionCandidatesForCallSite( - *CB, ICallProfDataRef, TotalCount, NumCandidates); -diff --git a/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll b/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll -new file mode 100644 -index 000000000000..b5031ca82a3e ---- /dev/null -+++ b/llvm/test/Transforms/PGOProfile/indirect_call_promotion_enhanced.ll -@@ -0,0 +1,81 @@ -+; RUN: opt < %s -passes=pgo-icall-prom -profile-summary-cutoff-hot-icp=200000 -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefix=PASS-REMARK -+; RUN: opt < %s -passes=pgo-icall-prom -profile-summary-cutoff-hot-icp=100000 -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefix=FAIL-REMARK -+ -+; PASS-REMARK: remark: :0:0: Promote indirect call to func4 with count 5 out of 14 -+; PASS-REMARK: remark: :0:0: Promote indirect call to func2 with count 4 out of 9 -+; PASS-REMARK: remark: :0:0: Promote indirect call to func3 with count 3 out of 5 -+ -+; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func4 -+; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func2 -+; FAIL-REMARK-NOT: remark: :0:0: Promote indirect call to func3 -+ -+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -+target triple = "x86_64-unknown-linux-gnu" -+ -+@foo = common global ptr null, align 8 -+ -+define i32 @func1() { -+entry: -+ ret i32 0 -+} -+ -+define i32 @func2() { -+entry: -+ ret i32 1 -+} -+ -+define i32 @func3() { -+entry: -+ ret i32 2 -+} -+ -+define i32 @func4() { -+entry: -+ ret i32 3 -+} -+ -+define i32 @bar() { -+entry: -+ %tmp = load ptr, ptr @foo, align 8 -+ %call = call i32 %tmp(), !prof !34 -+ ret i32 %call -+} -+ -+ -+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5} -+ -+!0 = !{i32 1, !"wchar_size", i32 4} -+!1 = !{i32 7, !"PIC Level", i32 2} -+!2 = !{i32 7, !"PIE Level", i32 2} -+!3 = !{i32 7, !"uwtable", i32 2} -+!4 = !{i32 7, !"frame-pointer", i32 1} -+!5 = !{i32 1, !"ProfileSummary", !6} -+!6 = !{!7, !8, !9, !10, !11, !12, !13, !14, !15, !16} -+!7 = !{!"ProfileFormat", !"InstrProf"} -+!8 = !{!"TotalCount", i64 3} -+!9 = !{!"MaxCount", i64 1} -+!10 = !{!"MaxInternalCount", i64 1} -+!11 = !{!"MaxFunctionCount", i64 1} -+!12 = !{!"NumCounts", i64 7} -+!13 = !{!"NumFunctions", i64 4} -+!14 = !{!"IsPartialProfile", i64 0} -+!15 = !{!"PartialProfileRatio", double 0.000000e+00} -+!16 = !{!"DetailedSummary", !17} -+!17 = !{!18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33} -+!18 = !{i32 10000, i64 16, i32 1} -+!19 = !{i32 100000, i64 15, i32 2} -+!20 = !{i32 200000, i64 14, i32 3} -+!21 = !{i32 300000, i64 13, i32 4} -+!22 = !{i32 400000, i64 12, i32 5} -+!23 = !{i32 500000, i64 11, i32 6} -+!24 = !{i32 600000, i64 10, i32 7} -+!25 = !{i32 700000, i64 9, i32 8} -+!26 = !{i32 800000, i64 8, i32 9} -+!27 = !{i32 900000, i64 7, i32 10} -+!28 = !{i32 950000, i64 6, i32 11} -+!29 = !{i32 990000, i64 5, i32 12} -+!30 = !{i32 999000, i64 4, i32 13} -+!31 = !{i32 999900, i64 3, i32 14} -+!32 = !{i32 999990, i64 2, i32 15} -+!33 = !{i32 999999, i64 1, i32 16} -+!34 = !{!"VP", i32 0, i64 14, i64 7651369219802541373, i64 5, i64 -4377547752858689819, i64 4, i64 -6929281286627296573, i64 3, i64 -2545542355363006406, i64 2} --- -Gitee diff --git a/0007-bugfix-Constant-fold-logl-call.patch b/0007-bugfix-Constant-fold-logl-call.patch deleted file mode 100644 index e62c67c..0000000 --- a/0007-bugfix-Constant-fold-logl-call.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 50c0b5564a0b88f9b5f3ad7891cb9d341c738cd8 Mon Sep 17 00:00:00 2001 -From: llvmssh -Date: Sat, 14 Jun 2025 14:16:12 +0800 -Subject: [PATCH] Constant fold logl call - ---- - llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp -index 449de7ce314d..3da9c9b293eb 100644 ---- a/llvm/lib/Analysis/ConstantFolding.cpp -+++ b/llvm/lib/Analysis/ConstantFolding.cpp -@@ -2136,8 +2136,8 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, - } - - LibFunc Fp128Func = NotLibFunc; -- if (TLI->getLibFunc(Name, Fp128Func) && TLI->has(Fp128Func) && -- Fp128Func == LibFunc_logl) -+ if (Name == "logl" && TLI->getLibFunc(Name, Fp128Func) && -+ TLI->has(Fp128Func) && Fp128Func == LibFunc_logl) - if (EnableLoglConstantFold) - return ConstantFoldFP128(logf128, Op->getValueAPF(), Ty); - } --- -Gitee diff --git a/llvm-for-oE-17.0.6-2506.0.3.tar.gz b/llvm-for-oE-17.0.6-2506.0.4.tar.gz similarity index 32% rename from llvm-for-oE-17.0.6-2506.0.3.tar.gz rename to llvm-for-oE-17.0.6-2506.0.4.tar.gz index f44baa6..171f896 100644 --- a/llvm-for-oE-17.0.6-2506.0.3.tar.gz +++ b/llvm-for-oE-17.0.6-2506.0.4.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:884dd9c9e4673f44d37fd6229ab8c63723c9c52f0ffe2c0c856a5820f11979a0 -size 212535248 +oid sha256:db05405706279885e543dd562d7f2887fd433eb10dae819811df7d588e8548b3 +size 212541296 diff --git a/llvm.spec b/llvm.spec index 31a69e1..ee6d9bd 100644 --- a/llvm.spec +++ b/llvm.spec @@ -9,7 +9,7 @@ # Build sys_llvm packages or compat packages %bcond_without sys_llvm %bcond_without check -%bcond_with toolchain_clang +%bcond_without toolchain_clang %bcond_without bisheng_autotuner %bcond_without ACPO @@ -28,7 +28,7 @@ %undefine __cmake_in_source_build -%global src_tarball llvm-for-oE-17.0.6-2506.0.3 +%global src_tarball llvm-for-oE-17.0.6-2506.0.4 %global src_tarball_dir llvm-project-%{src_tarball} #region LLVM globals @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 45 +Release: 46 Summary: The Low Level Virtual Machine License: NCSA @@ -174,8 +174,6 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif -Patch0006: 0006-ICP-Enable-promotion-of-more-targets.patch -Patch0007: 0007-bugfix-Constant-fold-logl-call.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -2881,6 +2879,10 @@ fi #endregion files %changelog +* Wed Jun 18 2025 liyunfei - 17.0.6-46 +- update to llvm-for-oe-17.0.6-2506.0.4 +- release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.4 + * Fri Jun 13 2025 liyunfei - 17.0.6-45 - [ICP] Enable promotion of more targets - [bugfix] Constant folding for long double type lib call is only supported for logl. -- Gitee From a214f9859bfd15ddd3825953a6abc71c34c232ef Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 1 Jul 2025 14:49:32 +0800 Subject: [PATCH 9/9] fix for mlir build failure after numpy 2.3.0 --- ...ke-it-possible-to-build-a-DenseResou.patch | 161 ++++++ ...d-Python-bindings-for-DenseResourceE.patch | 533 ++++++++++++++++++ llvm.spec | 7 +- 3 files changed, 700 insertions(+), 1 deletion(-) create mode 100644 0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch create mode 100644 0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch diff --git a/0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch b/0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch new file mode 100644 index 0000000..27cad62 --- /dev/null +++ b/0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch @@ -0,0 +1,161 @@ +From 33de1b4de43ef2d94f94ee0973724cc1ab2b8a6b Mon Sep 17 00:00:00 2001 +From: Stella Laurenzo +Date: Mon, 11 Sep 2023 14:10:03 -0700 +Subject: [PATCH 1/2] [backport][mlir] Make it possible to build a + DenseResourceElementsAttr from untyped memory. (#66009) + +Exposes the existing `get(ShapedType, StringRef, AsmResourceBlob)` +builder publicly (was protected) and adds a CAPI +`mlirUnmanagedDenseBlobResourceElementsAttrGet`. + +While such a generic construction interface is a big help when it comes +to interop, it is also necessary for creating resources that don't have +a standard C type (i.e. f16, the f8s, etc). + +Previously reviewed/approved as part of https://reviews.llvm.org/D157064 + +original by: Stella Laurenzo + +reference: https://github.com/llvm/llvm-project/commit/7055df7b4f6abf64f672703316bb8a7e7b185652 +--- + mlir/include/mlir-c/BuiltinAttributes.h | 7 +++++++ + mlir/include/mlir/IR/BuiltinAttributes.td | 17 ++++++++--------- + mlir/lib/CAPI/IR/BuiltinAttributes.cpp | 8 ++++++++ + mlir/test/CAPI/ir.c | 15 ++++++++++++--- + 4 files changed, 35 insertions(+), 12 deletions(-) + +diff --git a/mlir/include/mlir-c/BuiltinAttributes.h b/mlir/include/mlir-c/BuiltinAttributes.h +index 63198192453e..93c4ed5692ef 100644 +--- a/mlir/include/mlir-c/BuiltinAttributes.h ++++ b/mlir/include/mlir-c/BuiltinAttributes.h +@@ -600,6 +600,13 @@ mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, + intptr_t numElements, + const double *elements); + ++/// Unlike the typed accessors above, constructs the attribute with a raw ++/// data buffer and no type/alignment checking. Use a more strongly typed ++/// accessor if possible. ++MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBlobResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, const void *data, ++ size_t dataLength); ++ + /// Returns the pos-th value (flat contiguous indexing) of a specific type + /// contained by the given dense resource elements attribute. + MLIR_CAPI_EXPORTED bool +diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td +index 075eee456a7b..893ded074ed4 100644 +--- a/mlir/include/mlir/IR/BuiltinAttributes.td ++++ b/mlir/include/mlir/IR/BuiltinAttributes.td +@@ -466,21 +466,20 @@ def Builtin_DenseResourceElementsAttr : Builtin_Attr<"DenseResourceElements", [ + let builders = [ + AttrBuilderWithInferredContext<(ins + "ShapedType":$type, "DenseResourceElementsHandle":$handle +- )> +- ]; +- let extraClassDeclaration = [{ +- protected: ++ )>, + /// A builder that inserts a new resource into the builtin dialect's blob + /// manager using the provided blob. The handle of the inserted blob is used + /// when building the attribute. The provided `blobName` is used as a hint + /// for the key of the new handle for the `blob` resource, but may be + /// changed if necessary to ensure uniqueness during insertion. +- static DenseResourceElementsAttr get( +- ShapedType type, StringRef blobName, AsmResourceBlob blob +- ); ++ /// This base class builder does no element type specific size or alignment ++ /// checking. Use the typed subclasses for more safety unless if performing ++ /// generic operations. ++ AttrBuilderWithInferredContext<(ins ++ "ShapedType":$type, "StringRef":$blobName, "AsmResourceBlob":$blob ++ )> ++ ]; + +- public: +- }]; + let skipDefaultBuilders = 1; + } + +diff --git a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp +index de221ddbfa7a..84a958d01d2e 100644 +--- a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp ++++ b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp +@@ -852,6 +852,14 @@ mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, + return getDenseResource(shapedType, name, + numElements, elements); + } ++MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBlobResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, const void *data, ++ size_t dataLength) { ++ return wrap(DenseResourceElementsAttr::get( ++ llvm::cast(unwrap(shapedType)), unwrap(name), ++ UnmanagedAsmResourceBlob::allocateInferAlign( ++ llvm::ArrayRef(static_cast(data), dataLength)))); ++} + + template + static T getDenseResourceVal(MlirAttribute attr, intptr_t pos) { +diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c +index c3b78fe1762c..5d78daa29650 100644 +--- a/mlir/test/CAPI/ir.c ++++ b/mlir/test/CAPI/ir.c +@@ -1118,7 +1118,8 @@ int printBuiltinAttributes(MlirContext ctx) { + + const uint8_t *uint8RawData = + (const uint8_t *)mlirDenseElementsAttrGetRawData(uint8Elements); +- const int8_t *int8RawData = (const int8_t *)mlirDenseElementsAttrGetRawData(int8Elements); ++ const int8_t *int8RawData = ++ (const int8_t *)mlirDenseElementsAttrGetRawData(int8Elements); + const uint32_t *uint32RawData = + (const uint32_t *)mlirDenseElementsAttrGetRawData(uint32Elements); + const int32_t *int32RawData = +@@ -1127,7 +1128,8 @@ int printBuiltinAttributes(MlirContext ctx) { + (const uint64_t *)mlirDenseElementsAttrGetRawData(uint64Elements); + const int64_t *int64RawData = + (const int64_t *)mlirDenseElementsAttrGetRawData(int64Elements); +- const float *floatRawData = (const float *)mlirDenseElementsAttrGetRawData(floatElements); ++ const float *floatRawData = ++ (const float *)mlirDenseElementsAttrGetRawData(floatElements); + const double *doubleRawData = + (const double *)mlirDenseElementsAttrGetRawData(doubleElements); + const uint16_t *bf16RawData = +@@ -1268,6 +1270,10 @@ int printBuiltinAttributes(MlirContext ctx) { + MlirAttribute doublesBlob = mlirUnmanagedDenseDoubleResourceElementsAttrGet( + mlirRankedTensorTypeGet(2, shape, mlirF64TypeGet(ctx), encoding), + mlirStringRefCreateFromCString("resource_f64"), 2, doubles); ++ MlirAttribute blobBlob = mlirUnmanagedDenseBlobResourceElementsAttrGet( ++ mlirRankedTensorTypeGet(2, shape, mlirIntegerTypeGet(ctx, 64), encoding), ++ mlirStringRefCreateFromCString("resource_i64_blob"), uints64, ++ sizeof(uints64)); + + mlirAttributeDump(uint8Blob); + mlirAttributeDump(uint16Blob); +@@ -1279,6 +1285,7 @@ int printBuiltinAttributes(MlirContext ctx) { + mlirAttributeDump(int64Blob); + mlirAttributeDump(floatsBlob); + mlirAttributeDump(doublesBlob); ++ mlirAttributeDump(blobBlob); + // CHECK: dense_resource : tensor<1x2xui8> + // CHECK: dense_resource : tensor<1x2xui16> + // CHECK: dense_resource : tensor<1x2xui32> +@@ -1289,6 +1296,7 @@ int printBuiltinAttributes(MlirContext ctx) { + // CHECK: dense_resource : tensor<1x2xi64> + // CHECK: dense_resource : tensor<1x2xf32> + // CHECK: dense_resource : tensor<1x2xf64> ++ // CHECK: dense_resource : tensor<1x2xi64> + + if (mlirDenseUInt8ResourceElementsAttrGetValue(uint8Blob, 1) != 1 || + mlirDenseUInt16ResourceElementsAttrGetValue(uint16Blob, 1) != 1 || +@@ -1302,7 +1310,8 @@ int printBuiltinAttributes(MlirContext ctx) { + fabsf(mlirDenseFloatResourceElementsAttrGetValue(floatsBlob, 1) - 1.0f) > + 1e-6 || + fabs(mlirDenseDoubleResourceElementsAttrGetValue(doublesBlob, 1) - 1.0f) > +- 1e-6) ++ 1e-6 || ++ mlirDenseUInt64ResourceElementsAttrGetValue(blobBlob, 1) != 1) + return 23; + + MlirLocation loc = mlirLocationUnknownGet(ctx); +-- +2.28.0.windows.1 + diff --git a/0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch b/0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch new file mode 100644 index 0000000..d34c0f4 --- /dev/null +++ b/0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch @@ -0,0 +1,533 @@ +From 9b10a248c436bcc5c72071d8f3a6dae268652b81 Mon Sep 17 00:00:00 2001 +From: Stella Laurenzo +Date: Thu, 14 Sep 2023 18:45:29 -0700 +Subject: [PATCH 2/2] [backport][mlir] Add Python bindings for + DenseResourceElementsAttr. (#66319) + +Only construction and type casting are implemented. The method to create +is explicitly named "unsafe" and the documentation calls out what the +caller is responsible for. There really isn't a better way to do this +and retain the power-user feature this represents. + +originally by: Stella Laurenzo + +reference: https://github.com/llvm/llvm-project/commit/f66cd9e9556a53142a26a5c21a72e21f1579 +--- + mlir/include/mlir-c/BuiltinAttributes.h | 24 +++-- + mlir/lib/Bindings/Python/IRAttributes.cpp | 103 ++++++++++++++++++ + mlir/lib/CAPI/IR/BuiltinAttributes.cpp | 123 ++++++++++++---------- + mlir/test/CAPI/ir.c | 29 ++++- + mlir/test/python/ir/array_attributes.py | 44 +++++++- + 5 files changed, 252 insertions(+), 71 deletions(-) + +diff --git a/mlir/include/mlir-c/BuiltinAttributes.h b/mlir/include/mlir-c/BuiltinAttributes.h +index 93c4ed5692ef..01d1b6008f5e 100644 +--- a/mlir/include/mlir-c/BuiltinAttributes.h ++++ b/mlir/include/mlir-c/BuiltinAttributes.h +@@ -558,6 +558,23 @@ mlirDenseElementsAttrGetRawData(MlirAttribute attr); + // Resource blob attributes. + //===----------------------------------------------------------------------===// + ++MLIR_CAPI_EXPORTED bool ++mlirAttributeIsADenseResourceElements(MlirAttribute attr); ++ ++/// Unlike the typed accessors below, constructs the attribute with a raw ++/// data buffer and no type/alignment checking. Use a more strongly typed ++/// accessor if possible. If dataIsMutable is false, then an immutable ++/// AsmResourceBlob will be created and that passed data contents will be ++/// treated as const. ++/// If the deleter is non NULL, then it will be called when the data buffer ++/// can no longer be accessed (passing userData to it). ++MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, void *data, size_t dataLength, ++ size_t dataAlignment, bool dataIsMutable, ++ void (*deleter)(void *userData, const void *data, size_t size, ++ size_t align), ++ void *userData); ++ + MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBoolResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int *elements); +@@ -600,13 +617,6 @@ mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, + intptr_t numElements, + const double *elements); + +-/// Unlike the typed accessors above, constructs the attribute with a raw +-/// data buffer and no type/alignment checking. Use a more strongly typed +-/// accessor if possible. +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBlobResourceElementsAttrGet( +- MlirType shapedType, MlirStringRef name, const void *data, +- size_t dataLength); +- + /// Returns the pos-th value (flat contiguous indexing) of a specific type + /// contained by the given dense resource elements attribute. + MLIR_CAPI_EXPORTED bool +diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp +index 75d743f3a396..220c04f4a2ae 100644 +--- a/mlir/lib/Bindings/Python/IRAttributes.cpp ++++ b/mlir/lib/Bindings/Python/IRAttributes.cpp +@@ -72,6 +72,32 @@ Raises: + type or if the buffer does not meet expectations. + )"; + ++static const char kDenseResourceElementsAttrGetFromBufferDocstring[] = ++ R"(Gets a DenseResourceElementsAttr from a Python buffer or array. ++ ++This function does minimal validation or massaging of the data, and it is ++up to the caller to ensure that the buffer meets the characteristics ++implied by the shape. ++ ++The backing buffer and any user objects will be retained for the lifetime ++of the resource blob. This is typically bounded to the context but the ++resource can have a shorter lifespan depending on how it is used in ++subsequent processing. ++ ++Args: ++ buffer: The array or buffer to convert. ++ name: Name to provide to the resource (may be changed upon collision). ++ type: The explicit ShapedType to construct the attribute with. ++ context: Explicit context, if not from context manager. ++ ++Returns: ++ DenseResourceElementsAttr on success. ++ ++Raises: ++ ValueError: If the type of the buffer or array cannot be matched to an MLIR ++ type or if the buffer does not meet expectations. ++)"; ++ + namespace { + + static MlirStringRef toMlirStringRef(const std::string &s) { +@@ -985,6 +1011,82 @@ public: + } + }; + ++class PyDenseResourceElementsAttribute ++ : public PyConcreteAttribute { ++public: ++ static constexpr IsAFunctionTy isaFunction = ++ mlirAttributeIsADenseResourceElements; ++ static constexpr const char *pyClassName = "DenseResourceElementsAttr"; ++ using PyConcreteAttribute::PyConcreteAttribute; ++ ++ static PyDenseResourceElementsAttribute ++ getFromBuffer(py::buffer buffer, std::string name, PyType type, ++ std::optional alignment, bool isMutable, ++ DefaultingPyMlirContext contextWrapper) { ++ if (!mlirTypeIsAShaped(type)) { ++ throw std::invalid_argument( ++ "Constructing a DenseResourceElementsAttr requires a ShapedType."); ++ } ++ ++ // Do not request any conversions as we must ensure to use caller ++ // managed memory. ++ int flags = PyBUF_STRIDES; ++ std::unique_ptr view = std::make_unique(); ++ if (PyObject_GetBuffer(buffer.ptr(), view.get(), flags) != 0) { ++ throw py::error_already_set(); ++ } ++ ++ // This scope releaser will only release if we haven't yet transferred ++ // ownership. ++ auto freeBuffer = llvm::make_scope_exit([&]() { ++ if (view) ++ PyBuffer_Release(view.get()); ++ }); ++ ++ if (!PyBuffer_IsContiguous(view.get(), 'A')) { ++ throw std::invalid_argument("Contiguous buffer is required."); ++ } ++ ++ // Infer alignment to be the stride of one element if not explicit. ++ size_t inferredAlignment; ++ if (alignment) ++ inferredAlignment = *alignment; ++ else ++ inferredAlignment = view->strides[view->ndim - 1]; ++ ++ // The userData is a Py_buffer* that the deleter owns. ++ auto deleter = [](void *userData, const void *data, size_t size, ++ size_t align) { ++ Py_buffer *ownedView = static_cast(userData); ++ PyBuffer_Release(ownedView); ++ delete ownedView; ++ }; ++ ++ size_t rawBufferSize = view->len; ++ MlirAttribute attr = mlirUnmanagedDenseResourceElementsAttrGet( ++ type, toMlirStringRef(name), view->buf, rawBufferSize, ++ inferredAlignment, isMutable, deleter, static_cast(view.get())); ++ if (mlirAttributeIsNull(attr)) { ++ throw std::invalid_argument( ++ "DenseResourceElementsAttr could not be constructed from the given " ++ "buffer. " ++ "This may mean that the Python buffer layout does not match that " ++ "MLIR expected layout and is a bug."); ++ } ++ view.release(); ++ return PyDenseResourceElementsAttribute(contextWrapper->getRef(), attr); ++ } ++ ++ static void bindDerived(ClassTy &c) { ++ c.def_static("get_from_buffer", ++ PyDenseResourceElementsAttribute::getFromBuffer, ++ py::arg("array"), py::arg("name"), py::arg("type"), ++ py::arg("alignment") = py::none(), ++ py::arg("is_mutable") = false, py::arg("context") = py::none(), ++ kDenseResourceElementsAttrGetFromBufferDocstring); ++ } ++}; ++ + class PyDictAttribute : public PyConcreteAttribute { + public: + static constexpr IsAFunctionTy isaFunction = mlirAttributeIsADictionary; +@@ -1261,6 +1363,7 @@ void mlir::python::populateIRAttributes(py::module &m) { + PyGlobals::get().registerTypeCaster( + mlirDenseIntOrFPElementsAttrGetTypeID(), + pybind11::cpp_function(denseIntOrFPElementsAttributeCaster)); ++ PyDenseResourceElementsAttribute::bind(m); + + PyDictAttribute::bind(m); + PySymbolRefAttribute::bind(m); +diff --git a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp +index 84a958d01d2e..b3066ee0c28b 100644 +--- a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp ++++ b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp +@@ -770,6 +770,30 @@ const void *mlirDenseElementsAttrGetRawData(MlirAttribute attr) { + // Resource blob attributes. + //===----------------------------------------------------------------------===// + ++bool mlirAttributeIsADenseResourceElements(MlirAttribute attr) { ++ return llvm::isa(unwrap(attr)); ++} ++ ++MlirAttribute mlirUnmanagedDenseResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, void *data, size_t dataLength, ++ size_t dataAlignment, bool dataIsMutable, ++ void (*deleter)(void *userData, const void *data, size_t size, ++ size_t align), ++ void *userData) { ++ AsmResourceBlob::DeleterFn cppDeleter = {}; ++ if (deleter) { ++ cppDeleter = [deleter, userData](void *data, size_t size, size_t align) { ++ deleter(userData, data, size, align); ++ }; ++ } ++ AsmResourceBlob blob( ++ llvm::ArrayRef(static_cast(data), dataLength), ++ dataAlignment, std::move(cppDeleter), dataIsMutable); ++ return wrap( ++ DenseResourceElementsAttr::get(llvm::cast(unwrap(shapedType)), ++ unwrap(name), std::move(blob))); ++} ++ + template + static MlirAttribute getDenseResource(MlirType shapedType, MlirStringRef name, + intptr_t numElements, const T *elements) { +@@ -778,139 +802,122 @@ static MlirAttribute getDenseResource(MlirType shapedType, MlirStringRef name, + llvm::ArrayRef(elements, numElements)))); + } + +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBoolResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseBoolResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseUInt8ResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseUInt8ResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const uint8_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute +-mlirUnmanagedDenseUInt16ResourceElementsAttrGet(MlirType shapedType, +- MlirStringRef name, +- intptr_t numElements, +- const uint16_t *elements) { ++MlirAttribute mlirUnmanagedDenseUInt16ResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, intptr_t numElements, ++ const uint16_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute +-mlirUnmanagedDenseUInt32ResourceElementsAttrGet(MlirType shapedType, +- MlirStringRef name, +- intptr_t numElements, +- const uint32_t *elements) { ++MlirAttribute mlirUnmanagedDenseUInt32ResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, intptr_t numElements, ++ const uint32_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute +-mlirUnmanagedDenseUInt64ResourceElementsAttrGet(MlirType shapedType, +- MlirStringRef name, +- intptr_t numElements, +- const uint64_t *elements) { ++MlirAttribute mlirUnmanagedDenseUInt64ResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, intptr_t numElements, ++ const uint64_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt8ResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseInt8ResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int8_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt16ResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseInt16ResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int16_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt32ResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseInt32ResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int32_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt64ResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseInt64ResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const int64_t *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseFloatResourceElementsAttrGet( ++MlirAttribute mlirUnmanagedDenseFloatResourceElementsAttrGet( + MlirType shapedType, MlirStringRef name, intptr_t numElements, + const float *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute +-mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, +- MlirStringRef name, +- intptr_t numElements, +- const double *elements) { ++MlirAttribute mlirUnmanagedDenseDoubleResourceElementsAttrGet( ++ MlirType shapedType, MlirStringRef name, intptr_t numElements, ++ const double *elements) { + return getDenseResource(shapedType, name, + numElements, elements); + } +-MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBlobResourceElementsAttrGet( +- MlirType shapedType, MlirStringRef name, const void *data, +- size_t dataLength) { +- return wrap(DenseResourceElementsAttr::get( +- llvm::cast(unwrap(shapedType)), unwrap(name), +- UnmanagedAsmResourceBlob::allocateInferAlign( +- llvm::ArrayRef(static_cast(data), dataLength)))); +-} +- + template + static T getDenseResourceVal(MlirAttribute attr, intptr_t pos) { + return (*llvm::cast(unwrap(attr)).tryGetAsArrayRef())[pos]; + } + +-MLIR_CAPI_EXPORTED bool +-mlirDenseBoolResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++bool mlirDenseBoolResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED uint8_t +-mlirDenseUInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++uint8_t mlirDenseUInt8ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED uint16_t +-mlirDenseUInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++uint16_t mlirDenseUInt16ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, + pos); + } +-MLIR_CAPI_EXPORTED uint32_t +-mlirDenseUInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++uint32_t mlirDenseUInt32ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, + pos); + } +-MLIR_CAPI_EXPORTED uint64_t +-mlirDenseUInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++uint64_t mlirDenseUInt64ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, + pos); + } +-MLIR_CAPI_EXPORTED int8_t +-mlirDenseInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++int8_t mlirDenseInt8ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED int16_t +-mlirDenseInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++int16_t mlirDenseInt16ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED int32_t +-mlirDenseInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++int32_t mlirDenseInt32ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED int64_t +-mlirDenseInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++int64_t mlirDenseInt64ResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED float +-mlirDenseFloatResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++float mlirDenseFloatResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } +-MLIR_CAPI_EXPORTED double +-mlirDenseDoubleResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos) { ++double mlirDenseDoubleResourceElementsAttrGetValue(MlirAttribute attr, ++ intptr_t pos) { + return getDenseResourceVal(attr, pos); + } + +diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c +index 5d78daa29650..5725d05a3e13 100644 +--- a/mlir/test/CAPI/ir.c ++++ b/mlir/test/CAPI/ir.c +@@ -35,6 +35,17 @@ static void registerAllUpstreamDialects(MlirContext ctx) { + mlirDialectRegistryDestroy(registry); + } + ++struct ResourceDeleteUserData { ++ const char *name; ++}; ++static struct ResourceDeleteUserData resourceI64BlobUserData = { ++ "resource_i64_blob"}; ++static void reportResourceDelete(void *userData, const void *data, size_t size, ++ size_t align) { ++ fprintf(stderr, "reportResourceDelete: %s\n", ++ ((struct ResourceDeleteUserData *)userData)->name); ++} ++ + void populateLoopBody(MlirContext ctx, MlirBlock loopBody, + MlirLocation location, MlirBlock funcBody) { + MlirValue iv = mlirBlockGetArgument(loopBody, 0); +@@ -1270,10 +1281,14 @@ int printBuiltinAttributes(MlirContext ctx) { + MlirAttribute doublesBlob = mlirUnmanagedDenseDoubleResourceElementsAttrGet( + mlirRankedTensorTypeGet(2, shape, mlirF64TypeGet(ctx), encoding), + mlirStringRefCreateFromCString("resource_f64"), 2, doubles); +- MlirAttribute blobBlob = mlirUnmanagedDenseBlobResourceElementsAttrGet( ++ MlirAttribute blobBlob = mlirUnmanagedDenseResourceElementsAttrGet( + mlirRankedTensorTypeGet(2, shape, mlirIntegerTypeGet(ctx, 64), encoding), +- mlirStringRefCreateFromCString("resource_i64_blob"), uints64, +- sizeof(uints64)); ++ mlirStringRefCreateFromCString("resource_i64_blob"), /*data=*/uints64, ++ /*dataLength=*/sizeof(uints64), ++ /*dataAlignment=*/_Alignof(uint64_t), ++ /*dataIsMutable=*/false, ++ /*deleter=*/reportResourceDelete, ++ /*userData=*/(void *)&resourceI64BlobUserData); + + mlirAttributeDump(uint8Blob); + mlirAttributeDump(uint16Blob); +@@ -2329,9 +2344,13 @@ int main(void) { + if (testDialectRegistry()) + return 15; + +- mlirContextDestroy(ctx); +- + testExplicitThreadPools(); + testDiagnostics(); ++ ++ // CHECK: DESTROY MAIN CONTEXT ++ // CHECK: reportResourceDelete: resource_i64_blob ++ fprintf(stderr, "DESTROY MAIN CONTEXT\n"); ++ mlirContextDestroy(ctx); ++ + return 0; + } +diff --git a/mlir/test/python/ir/array_attributes.py b/mlir/test/python/ir/array_attributes.py +index 452d860861d7..9251588a4c48 100644 +--- a/mlir/test/python/ir/array_attributes.py ++++ b/mlir/test/python/ir/array_attributes.py +@@ -5,6 +5,7 @@ + import gc + from mlir.ir import * + import numpy as np ++import weakref + + + def run(f): +@@ -162,7 +163,7 @@ def testGetDenseElementsBF16(): + @run + def testGetDenseElementsInteger4(): + with Context(): +- array = np.array([[2, 4, 7], [-2, -4, -8]], dtype=np.uint8) ++ array = np.array([[2, 4, 7], [-2, -4, -8]], dtype=np.int8) + attr = DenseElementsAttr.get(array, type=IntegerType.get_signless(4)) + # Note: These values don't mean much since just bit-casting. But they + # shouldn't change. +@@ -417,3 +418,44 @@ def testGetDenseElementsIndex(): + print(arr) + # CHECK: True + print(arr.dtype == np.int64) ++ ++ ++# CHECK-LABEL: TEST: testGetDenseResourceElementsAttr ++@run ++def testGetDenseResourceElementsAttr(): ++ def on_delete(_): ++ print("BACKING MEMORY DELETED") ++ ++ context = Context() ++ mview = memoryview(np.array([[1, 2, 3], [4, 5, 6]], dtype=np.int32)) ++ ref = weakref.ref(mview, on_delete) ++ ++ def test_attribute(context, mview): ++ with context, Location.unknown(): ++ element_type = IntegerType.get_signless(32) ++ tensor_type = RankedTensorType.get((2, 3), element_type) ++ resource = DenseResourceElementsAttr.get_from_buffer( ++ mview, "from_py", tensor_type ++ ) ++ module = Module.parse("module {}") ++ module.operation.attributes["test.resource"] = resource ++ # CHECK: test.resource = dense_resource : tensor<2x3xi32> ++ # CHECK: from_py: "0x04000000010000000200000003000000040000000500000006000000" ++ print(module) ++ ++ # Verifies type casting. ++ # CHECK: dense_resource : tensor<2x3xi32> ++ print( ++ DenseResourceElementsAttr(module.operation.attributes["test.resource"]) ++ ) ++ ++ test_attribute(context, mview) ++ mview = None ++ gc.collect() ++ # CHECK: FREEING CONTEXT ++ print("FREEING CONTEXT") ++ context = None ++ gc.collect() ++ # CHECK: BACKING MEMORY DELETED ++ # CHECK: EXIT FUNCTION ++ print("EXIT FUNCTION") +-- +2.28.0.windows.1 + diff --git a/llvm.spec b/llvm.spec index ee6d9bd..6df2842 100644 --- a/llvm.spec +++ b/llvm.spec @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 46 +Release: 47 Summary: The Low Level Virtual Machine License: NCSA @@ -174,6 +174,8 @@ Patch0004: 0004-remove-cmake_minimum_required.patch %if %{with bisheng_autotuner} Patch0005: 0005-Fix-for-building-autotuner-with-mlir.patch %endif +Patch0006: 0006-backport-mlir-Make-it-possible-to-build-a-DenseResou.patch +Patch0007: 0007-backport-mlir-Add-Python-bindings-for-DenseResourceE.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -2879,6 +2881,9 @@ fi #endregion files %changelog +* Tue Jul 01 2025 liyunfei - 17.0.6-47 +- fix for mlir build failure after numpy 2.3.0 + * Wed Jun 18 2025 liyunfei - 17.0.6-46 - update to llvm-for-oe-17.0.6-2506.0.4 - release-note https://gitee.com/openeuler/llvm-project/releases/tag/llvm-for-oE-17.0.6-2506.0.4 -- Gitee