mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-05 04:16:46 +02:00
main/clang16: backport patches that didn't make it into stable
This commit is contained in:
parent
54d80a6f7e
commit
ce455246bc
196
main/clang16/9008-Clang-Support-more-stdio-builtins.patch
Normal file
196
main/clang16/9008-Clang-Support-more-stdio-builtins.patch
Normal file
@ -0,0 +1,196 @@
|
||||
From d67f31b2fdf74d999b8a0b298361daee3503c2f5 Mon Sep 17 00:00:00 2001
|
||||
From: Qiu Chaofan <qiucofan@cn.ibm.com>
|
||||
Date: Tue, 23 May 2023 16:22:32 +0800
|
||||
Subject: [PATCH 08/10] [Clang] Support more stdio builtins
|
||||
|
||||
Add more builtins for stdio functions as in GCC, along with their
|
||||
mutations under IEEE float128 ABI.
|
||||
|
||||
Reviewed By: tuliom
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D150087
|
||||
|
||||
Gentoo-Component: clang
|
||||
---
|
||||
clang/include/clang/Basic/Builtins.def | 36 +++++++-----
|
||||
clang/lib/CodeGen/CGBuiltin.cpp | 24 ++++++--
|
||||
.../CodeGen/PowerPC/ppc64-f128-builtins.c | 57 +++++++++++++++++++
|
||||
3 files changed, 99 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
|
||||
index 41f124556446..e6a89da1912c 100644
|
||||
--- a/include/clang/Basic/Builtins.def
|
||||
+++ b/include/clang/Basic/Builtins.def
|
||||
@@ -551,7 +551,6 @@ BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nctE")
|
||||
BUILTIN(__builtin_bcmp, "ivC*vC*z", "FnE")
|
||||
BUILTIN(__builtin_bcopy, "vv*v*z", "n")
|
||||
BUILTIN(__builtin_bzero, "vv*z", "nF")
|
||||
-BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
|
||||
BUILTIN(__builtin_free, "vv*", "nF")
|
||||
BUILTIN(__builtin_malloc, "v*z", "nF")
|
||||
BUILTIN(__builtin_memchr, "v*vC*iz", "nFE")
|
||||
@@ -562,7 +561,6 @@ BUILTIN(__builtin_memmove, "v*v*vC*z", "nFE")
|
||||
BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
|
||||
BUILTIN(__builtin_memset, "v*v*iz", "nF")
|
||||
BUILTIN(__builtin_memset_inline, "vv*iIz", "n")
|
||||
-BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
|
||||
BUILTIN(__builtin_stpcpy, "c*c*cC*", "nF")
|
||||
BUILTIN(__builtin_stpncpy, "c*c*cC*z", "nF")
|
||||
BUILTIN(__builtin_strcasecmp, "icC*cC*", "nF")
|
||||
@@ -599,10 +597,20 @@ BUILTIN(__builtin_setjmp, "iv**", "j")
|
||||
BUILTIN(__builtin_longjmp, "vv**i", "r")
|
||||
BUILTIN(__builtin_unwind_init, "v", "")
|
||||
BUILTIN(__builtin_eh_return_data_regno, "iIi", "ncE")
|
||||
-BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
|
||||
-BUILTIN(__builtin_sprintf, "ic*cC*.", "nFP:1:")
|
||||
-BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
|
||||
-BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
|
||||
+BUILTIN(__builtin_fprintf, "iP*RcC*R.", "nFp:1:")
|
||||
+BUILTIN(__builtin_printf, "icC*R.", "nFp:0:")
|
||||
+BUILTIN(__builtin_sprintf, "ic*RcC*R.", "nFp:1:")
|
||||
+BUILTIN(__builtin_snprintf, "ic*RzcC*R.", "nFp:2:")
|
||||
+BUILTIN(__builtin_vprintf, "icC*Ra", "nFP:0:")
|
||||
+BUILTIN(__builtin_vfprintf, "iP*RcC*Ra", "nFP:1:")
|
||||
+BUILTIN(__builtin_vsprintf, "ic*RcC*Ra", "nFP:1:")
|
||||
+BUILTIN(__builtin_vsnprintf, "ic*RzcC*Ra", "nFP:2:")
|
||||
+BUILTIN(__builtin_fscanf, "iP*RcC*R.", "Fs:1:")
|
||||
+BUILTIN(__builtin_scanf, "icC*R.", "Fs:0:")
|
||||
+BUILTIN(__builtin_sscanf, "icC*RcC*R.", "Fs:1:")
|
||||
+BUILTIN(__builtin_vfscanf, "iP*RcC*Ra", "FS:1:")
|
||||
+BUILTIN(__builtin_vscanf, "icC*Ra", "FS:0:")
|
||||
+BUILTIN(__builtin_vsscanf, "icC*RcC*Ra", "FS:1:")
|
||||
BUILTIN(__builtin_thread_pointer, "v*", "nc")
|
||||
BUILTIN(__builtin_launder, "v*v*", "ntE")
|
||||
LANGBUILTIN(__builtin_is_constant_evaluated, "b", "nE", CXX_LANG)
|
||||
@@ -631,14 +639,14 @@ BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
|
||||
BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
|
||||
BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
|
||||
BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
|
||||
-BUILTIN(__builtin___snprintf_chk, "ic*zizcC*.", "Fp:4:")
|
||||
-BUILTIN(__builtin___sprintf_chk, "ic*izcC*.", "Fp:3:")
|
||||
-BUILTIN(__builtin___vsnprintf_chk, "ic*zizcC*a", "FP:4:")
|
||||
-BUILTIN(__builtin___vsprintf_chk, "ic*izcC*a", "FP:3:")
|
||||
-BUILTIN(__builtin___fprintf_chk, "iP*icC*.", "Fp:2:")
|
||||
-BUILTIN(__builtin___printf_chk, "iicC*.", "Fp:1:")
|
||||
-BUILTIN(__builtin___vfprintf_chk, "iP*icC*a", "FP:2:")
|
||||
-BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
|
||||
+BUILTIN(__builtin___snprintf_chk, "ic*RzizcC*R.", "Fp:4:")
|
||||
+BUILTIN(__builtin___sprintf_chk, "ic*RizcC*R.", "Fp:3:")
|
||||
+BUILTIN(__builtin___vsnprintf_chk, "ic*RzizcC*Ra", "FP:4:")
|
||||
+BUILTIN(__builtin___vsprintf_chk, "ic*RizcC*Ra", "FP:3:")
|
||||
+BUILTIN(__builtin___fprintf_chk, "iP*RicC*R.", "Fp:2:")
|
||||
+BUILTIN(__builtin___printf_chk, "iicC*R.", "Fp:1:")
|
||||
+BUILTIN(__builtin___vfprintf_chk, "iP*RicC*Ra", "FP:2:")
|
||||
+BUILTIN(__builtin___vprintf_chk, "iicC*Ra", "FP:1:")
|
||||
|
||||
BUILTIN(__builtin_unpredictable, "LiLi" , "nc")
|
||||
BUILTIN(__builtin_expect, "LiLiLi" , "ncE")
|
||||
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
|
||||
index f72e04a425d9..cc3c5cc5028a 100644
|
||||
--- a/lib/CodeGen/CGBuiltin.cpp
|
||||
+++ b/lib/CodeGen/CGBuiltin.cpp
|
||||
@@ -98,13 +98,29 @@ llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
|
||||
|
||||
// TODO: This list should be expanded or refactored after all GCC-compatible
|
||||
// std libcall builtins are implemented.
|
||||
- static SmallDenseMap<unsigned, StringRef, 8> F128Builtins{
|
||||
+ static SmallDenseMap<unsigned, StringRef, 64> F128Builtins{
|
||||
+ {Builtin::BI__builtin___fprintf_chk, "__fprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___printf_chk, "__printf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___snprintf_chk, "__snprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___sprintf_chk, "__sprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___vfprintf_chk, "__vfprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___vprintf_chk, "__vprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___vsnprintf_chk, "__vsnprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin___vsprintf_chk, "__vsprintf_chkieee128"},
|
||||
+ {Builtin::BI__builtin_fprintf, "__fprintfieee128"},
|
||||
{Builtin::BI__builtin_printf, "__printfieee128"},
|
||||
+ {Builtin::BI__builtin_snprintf, "__snprintfieee128"},
|
||||
+ {Builtin::BI__builtin_sprintf, "__sprintfieee128"},
|
||||
+ {Builtin::BI__builtin_vfprintf, "__vfprintfieee128"},
|
||||
+ {Builtin::BI__builtin_vprintf, "__vprintfieee128"},
|
||||
{Builtin::BI__builtin_vsnprintf, "__vsnprintfieee128"},
|
||||
{Builtin::BI__builtin_vsprintf, "__vsprintfieee128"},
|
||||
- {Builtin::BI__builtin_sprintf, "__sprintfieee128"},
|
||||
- {Builtin::BI__builtin_snprintf, "__snprintfieee128"},
|
||||
- {Builtin::BI__builtin_fprintf, "__fprintfieee128"},
|
||||
+ {Builtin::BI__builtin_fscanf, "__fscanfieee128"},
|
||||
+ {Builtin::BI__builtin_scanf, "__scanfieee128"},
|
||||
+ {Builtin::BI__builtin_sscanf, "__sscanfieee128"},
|
||||
+ {Builtin::BI__builtin_vfscanf, "__vfscanfieee128"},
|
||||
+ {Builtin::BI__builtin_vscanf, "__vscanfieee128"},
|
||||
+ {Builtin::BI__builtin_vsscanf, "__vsscanfieee128"},
|
||||
{Builtin::BI__builtin_nexttowardf128, "__nexttowardieee128"},
|
||||
};
|
||||
|
||||
diff --git a/clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c b/clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
|
||||
index 635e7fadbbf0..b7e6cc9a2eb4 100644
|
||||
--- a/test/CodeGen/PowerPC/ppc64-f128-builtins.c
|
||||
+++ b/test/CodeGen/PowerPC/ppc64-f128-builtins.c
|
||||
@@ -52,6 +52,63 @@ void test_snprintf(void) {
|
||||
__builtin_snprintf(buf, 20, "%.Lf", x);
|
||||
}
|
||||
|
||||
+// IEEE128-LABEL: define dso_local void @test_scanf
|
||||
+// IEEE128: call signext i32 (ptr, ...) @__scanfieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_scanf
|
||||
+// PPC128: call signext i32 (ptr, ...) @scanf
|
||||
+void test_scanf(int *x) {
|
||||
+ __builtin_scanf("%d", x);
|
||||
+}
|
||||
+
|
||||
+// IEEE128-LABEL: define dso_local void @test_sscanf
|
||||
+// IEEE128: call signext i32 (ptr, ptr, ...) @__sscanfieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_sscanf
|
||||
+// PPC128: call signext i32 (ptr, ptr, ...) @sscanf
|
||||
+void test_sscanf(int *x) {
|
||||
+ __builtin_sscanf(buf, "%d", x);
|
||||
+}
|
||||
+
|
||||
+// IEEE128-LABEL: define dso_local void @test_vprintf
|
||||
+// IEEE128: call signext i32 @__vprintfieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_vprintf
|
||||
+// PPC128: call signext i32 @vprintf
|
||||
+void test_vprintf(const char *fmt, ...) {
|
||||
+ __builtin_va_list args;
|
||||
+ __builtin_va_start(args, fmt);
|
||||
+ __builtin_vprintf(fmt, args);
|
||||
+ __builtin_va_end(args);
|
||||
+}
|
||||
+
|
||||
+// IEEE128-LABEL: define dso_local void @test_vscanf
|
||||
+// IEEE128: call signext i32 @__vscanfieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_vscanf
|
||||
+// PPC128: call signext i32 @vscanf
|
||||
+void test_vscanf(const char *fmt, ...) {
|
||||
+ __builtin_va_list args;
|
||||
+ __builtin_va_start(args, fmt);
|
||||
+ __builtin_vscanf(fmt, args);
|
||||
+ __builtin_va_end(args);
|
||||
+}
|
||||
+
|
||||
+// IEEE128-LABEL: define dso_local void @test_vsscanf
|
||||
+// IEEE128: call signext i32 @__vsscanfieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_vsscanf
|
||||
+// PPC128: call signext i32 @vsscanf
|
||||
+void test_vsscanf(const char *fmt, ...) {
|
||||
+ __builtin_va_list args;
|
||||
+ __builtin_va_start(args, fmt);
|
||||
+ __builtin_vsscanf(buf, fmt, args);
|
||||
+ __builtin_va_end(args);
|
||||
+}
|
||||
+
|
||||
+// IEEE128-LABEL: define dso_local void @test_snprintf_chk
|
||||
+// IEEE128: call signext i32 (ptr, i64, i32, i64, ptr, ...) @__snprintf_chkieee128
|
||||
+// PPC128-LABEL: define dso_local void @test_snprintf_chk
|
||||
+// PPC128: call signext i32 (ptr, i64, i32, i64, ptr, ...) @__snprintf_chk
|
||||
+void test_snprintf_chk(long double x) {
|
||||
+ __builtin___snprintf_chk(buf, 20, 1, 20, "%.Lf", x);
|
||||
+}
|
||||
+
|
||||
// GLIBC has special handling of 'nexttoward'
|
||||
|
||||
// IEEE128-LABEL: define dso_local fp128 @test_nexttoward
|
||||
--
|
||||
2.41.0
|
||||
|
||||
72
main/clang16/9012-Call-printName-to-get-name-of-Decl.patch
Normal file
72
main/clang16/9012-Call-printName-to-get-name-of-Decl.patch
Normal file
@ -0,0 +1,72 @@
|
||||
From 91daf2a98bf10c6974c79305eca4ac13b76b19d1 Mon Sep 17 00:00:00 2001
|
||||
From: Dan McGregor <danismostlikely@gmail.com>
|
||||
Date: Tue, 2 May 2023 11:53:48 -0400
|
||||
Subject: [PATCH] Call printName to get name of Decl
|
||||
|
||||
Rather than sending a name directly to the stream, use printName
|
||||
to preserve any PrintingPolicy. This ensures that names are properly
|
||||
affected by path remapping.
|
||||
|
||||
Fixes: https://github.com/llvm/llvm-project/issues/62192
|
||||
Differential Revision: https://reviews.llvm.org/D149272
|
||||
|
||||
(cherry picked from commit ea6ecdbfe09d4318f2d616af794e2930f996e393)
|
||||
---
|
||||
clang/docs/ReleaseNotes.rst | 2 ++
|
||||
clang/lib/AST/Decl.cpp | 4 ++--
|
||||
clang/lib/AST/DeclarationName.cpp | 4 ++--
|
||||
clang/test/CodeGen/debug-prefix-map.cpp | 11 +++++++++++
|
||||
4 files changed, 17 insertions(+), 4 deletions(-)
|
||||
create mode 100644 clang/test/CodeGen/debug-prefix-map.cpp
|
||||
|
||||
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
|
||||
index e60cc28f6e0f..24de6156c0f5 100644
|
||||
--- a/lib/AST/Decl.cpp
|
||||
+++ b/lib/AST/Decl.cpp
|
||||
@@ -1626,8 +1626,8 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
|
||||
llvm_unreachable("unknown module kind");
|
||||
}
|
||||
|
||||
-void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy&) const {
|
||||
- OS << Name;
|
||||
+void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const {
|
||||
+ Name.print(OS, Policy);
|
||||
}
|
||||
|
||||
void NamedDecl::printName(raw_ostream &OS) const {
|
||||
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp
|
||||
index c1219041a466..da8b3886c340 100644
|
||||
--- a/lib/AST/DeclarationName.cpp
|
||||
+++ b/lib/AST/DeclarationName.cpp
|
||||
@@ -117,12 +117,12 @@ static void printCXXConstructorDestructorName(QualType ClassType,
|
||||
Policy.adjustForCPlusPlus();
|
||||
|
||||
if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
|
||||
- OS << *ClassRec->getDecl();
|
||||
+ ClassRec->getDecl()->printName(OS, Policy);
|
||||
return;
|
||||
}
|
||||
if (Policy.SuppressTemplateArgsInCXXConstructors) {
|
||||
if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
|
||||
- OS << *InjTy->getDecl();
|
||||
+ InjTy->getDecl()->printName(OS, Policy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
diff --git a/clang/test/CodeGen/debug-prefix-map.cpp b/clang/test/CodeGen/debug-prefix-map.cpp
|
||||
new file mode 100644
|
||||
index 000000000000..5e90aedd8ed7
|
||||
--- /dev/null
|
||||
+++ b/test/CodeGen/debug-prefix-map.cpp
|
||||
@@ -0,0 +1,11 @@
|
||||
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S %s -emit-llvm -o - | FileCheck %s
|
||||
+
|
||||
+struct alignas(64) an {
|
||||
+ struct {
|
||||
+ unsigned char x{0};
|
||||
+ } arr[64];
|
||||
+};
|
||||
+
|
||||
+struct an *pan = new an;
|
||||
+
|
||||
+// CHECK: !DISubprogram(name: "(unnamed struct at ./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}",
|
||||
@ -5,7 +5,7 @@
|
||||
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
||||
pkgname=clang16
|
||||
pkgver=16.0.6
|
||||
pkgrel=0
|
||||
pkgrel=1
|
||||
_llvmver=${pkgver%%.*}
|
||||
pkgdesc="C language family front-end for LLVM"
|
||||
arch="all"
|
||||
@ -43,6 +43,8 @@ source="https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver/c
|
||||
clang-001-fortify-include.patch
|
||||
clang-002-fortify-enable.patch
|
||||
clang-003-as-needed.patch
|
||||
9008-Clang-Support-more-stdio-builtins.patch
|
||||
9012-Call-printName-to-get-name-of-Decl.patch
|
||||
"
|
||||
builddir="$srcdir/clang-$pkgver.src"
|
||||
|
||||
@ -475,4 +477,6 @@ ec1a0834f223e393d24c11586b744167a41cea6c39d1bb18c433d2fb736501950fdff42f1eb0caa1
|
||||
aa2dff990278e0258763934eaa528827baa1733eeb7dc36cc7f1500a4919b8d11870a0522f20f210d454322e3faf5945e9afaeffc9f3a3c4fd422b706370a663 clang-001-fortify-include.patch
|
||||
751f8acef2bfd1b50c065dea2ad0c3a20cadd4ff4c842ae519b5085c48372127b49a75d3fd0bd32291f5a69119340e5568a9fba6d94e6f354b14233986f61328 clang-002-fortify-enable.patch
|
||||
5f98f147d7d66315e9a56ae6fee602a053d40e57a8b1ee4f2ef1764203bb6fdb9082c8e825c535a9388213a38b49d2702b1e936fcf56560c4a2a56b7e6dd232c clang-003-as-needed.patch
|
||||
0928f379068e0bf819074f9cefad6247705c2571a08e995036e8432becdae0daf81dbc02548097fb544bb0c3fe02cac4039eb7d0dfcd51d03c3952ec3524b727 9008-Clang-Support-more-stdio-builtins.patch
|
||||
1d6d1dd5719ff1e93e55c8fd0fde115a0145d0d27c53e9a60bcf32a2e55afceac0dc28c41e1e2b1d2e5c1b8a16350c080b6c34b72595381f433e01130b52d162 9012-Call-printName-to-get-name-of-Decl.patch
|
||||
"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user