[clang] ObjcRuntime.h: Add mips64, aarch64, and riscv64 to non-legacy dispatch (PR #76694)
Hugo Melder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 2 13:22:14 PST 2024
https://github.com/hmelder updated https://github.com/llvm/llvm-project/pull/76694
>From 97a9a2753c52d6b377d929a4a6e717ab3c69b68d Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 01:46:19 +0100
Subject: [PATCH 1/8] Add mips64, aarch64, and riscv64 to ObjcRuntime dispatch
---
clang/include/clang/Basic/ObjCRuntime.h | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index 500b2462f00773..29392ad0a0f577 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -101,10 +101,17 @@ class ObjCRuntime {
// The GNUstep runtime uses a newer dispatch method by default from
// version 1.6 onwards
if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
- if (Arch == llvm::Triple::arm ||
- Arch == llvm::Triple::x86 ||
- Arch == llvm::Triple::x86_64)
- return false;
+ switch (Arch) {
+ case llvm::Triple::arm:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::mips64:
+ case llvm::Triple::riscv64:
+ return false;
+ default:
+ return true;
+ }
}
else if ((getKind() == MacOSX) && isNonFragile() &&
(getVersion() >= VersionTuple(10, 0)) &&
>From c9dd0b77456302fddcb9ee4904db2f667e946850 Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 01:54:40 +0100
Subject: [PATCH 2/8] ObjcRuntime.h: Adjust formatting
---
clang/include/clang/Basic/ObjCRuntime.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index 29392ad0a0f577..adfc04e3bd2d29 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -102,15 +102,15 @@ class ObjCRuntime {
// version 1.6 onwards
if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
switch (Arch) {
- case llvm::Triple::arm:
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- case llvm::Triple::aarch64:
- case llvm::Triple::mips64:
- case llvm::Triple::riscv64:
- return false;
- default:
- return true;
+ case llvm::Triple::arm:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::mips64:
+ case llvm::Triple::riscv64:
+ return false;
+ default:
+ return true;
}
}
else if ((getKind() == MacOSX) && isNonFragile() &&
>From 7c69da720afc45f6d2e3b7e2cc62f09a257289da Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 21:41:33 +0100
Subject: [PATCH 3/8] ObjCRuntime: format and update dispatch archs
---
clang/include/clang/Basic/ObjCRuntime.h | 213 +++++++++++++++---------
1 file changed, 133 insertions(+), 80 deletions(-)
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index adfc04e3bd2d29..c368b6f3bf3b24 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -81,13 +81,20 @@ class ObjCRuntime {
/// "non-fragile" ABI?
bool isNonFragile() const {
switch (getKind()) {
- case FragileMacOSX: return false;
- case GCC: return false;
- case MacOSX: return true;
- case GNUstep: return true;
- case ObjFW: return true;
- case iOS: return true;
- case WatchOS: return true;
+ case FragileMacOSX:
+ return false;
+ case GCC:
+ return false;
+ case MacOSX:
+ return true;
+ case GNUstep:
+ return true;
+ case ObjFW:
+ return true;
+ case iOS:
+ return true;
+ case WatchOS:
+ return true;
}
llvm_unreachable("bad kind");
}
@@ -100,23 +107,24 @@ class ObjCRuntime {
bool isLegacyDispatchDefaultForArch(llvm::Triple::ArchType Arch) {
// The GNUstep runtime uses a newer dispatch method by default from
// version 1.6 onwards
- if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
+ if (getKind() == GNUstep) {
switch (Arch) {
case llvm::Triple::arm:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
+ return !(getVersion() >= VersionTuple(1, 6));
case llvm::Triple::aarch64:
case llvm::Triple::mips64:
+ return !(getVersion() >= VersionTuple(1, 9));
case llvm::Triple::riscv64:
- return false;
+ return !(getVersion() >= VersionTuple(2, 2));
default:
return true;
}
- }
- else if ((getKind() == MacOSX) && isNonFragile() &&
- (getVersion() >= VersionTuple(10, 0)) &&
- (getVersion() < VersionTuple(10, 6)))
- return Arch != llvm::Triple::x86_64;
+ } else if ((getKind() == MacOSX) && isNonFragile() &&
+ (getVersion() >= VersionTuple(10, 0)) &&
+ (getVersion() < VersionTuple(10, 6)))
+ return Arch != llvm::Triple::x86_64;
// Except for deployment target of 10.5 or less,
// Mac runtimes use legacy dispatch everywhere now.
return true;
@@ -151,12 +159,18 @@ class ObjCRuntime {
case FragileMacOSX:
// No stub library for the fragile runtime.
return getVersion() >= VersionTuple(10, 7);
- case MacOSX: return true;
- case iOS: return true;
- case WatchOS: return true;
- case GCC: return false;
- case GNUstep: return true;
- case ObjFW: return true;
+ case MacOSX:
+ return true;
+ case iOS:
+ return true;
+ case WatchOS:
+ return true;
+ case GCC:
+ return false;
+ case GNUstep:
+ return true;
+ case ObjFW:
+ return true;
}
llvm_unreachable("bad kind");
}
@@ -168,14 +182,21 @@ class ObjCRuntime {
/// library.
bool hasNativeARC() const {
switch (getKind()) {
- case FragileMacOSX: return getVersion() >= VersionTuple(10, 7);
- case MacOSX: return getVersion() >= VersionTuple(10, 7);
- case iOS: return getVersion() >= VersionTuple(5);
- case WatchOS: return true;
-
- case GCC: return false;
- case GNUstep: return getVersion() >= VersionTuple(1, 6);
- case ObjFW: return true;
+ case FragileMacOSX:
+ return getVersion() >= VersionTuple(10, 7);
+ case MacOSX:
+ return getVersion() >= VersionTuple(10, 7);
+ case iOS:
+ return getVersion() >= VersionTuple(5);
+ case WatchOS:
+ return true;
+
+ case GCC:
+ return false;
+ case GNUstep:
+ return getVersion() >= VersionTuple(1, 6);
+ case ObjFW:
+ return true;
}
llvm_unreachable("bad kind");
}
@@ -273,23 +294,21 @@ class ObjCRuntime {
/// Does this runtime supports optimized setter entrypoints?
bool hasOptimizedSetter() const {
switch (getKind()) {
- case MacOSX:
- return getVersion() >= VersionTuple(10, 8);
- case iOS:
- return (getVersion() >= VersionTuple(6));
- case WatchOS:
- return true;
- case GNUstep:
- return getVersion() >= VersionTuple(1, 7);
- default:
- return false;
+ case MacOSX:
+ return getVersion() >= VersionTuple(10, 8);
+ case iOS:
+ return (getVersion() >= VersionTuple(6));
+ case WatchOS:
+ return true;
+ case GNUstep:
+ return getVersion() >= VersionTuple(1, 7);
+ default:
+ return false;
}
}
/// Does this runtime allow the use of __weak?
- bool allowsWeak() const {
- return hasNativeWeak();
- }
+ bool allowsWeak() const { return hasNativeWeak(); }
/// Does this runtime natively provide ARC-compliant 'weak'
/// entrypoints?
@@ -304,25 +323,30 @@ class ObjCRuntime {
/// This is really a property of the library, not the runtime.
bool hasSubscripting() const {
switch (getKind()) {
- case FragileMacOSX: return false;
- case MacOSX: return getVersion() >= VersionTuple(10, 11);
- case iOS: return getVersion() >= VersionTuple(9);
- case WatchOS: return true;
+ case FragileMacOSX:
+ return false;
+ case MacOSX:
+ return getVersion() >= VersionTuple(10, 11);
+ case iOS:
+ return getVersion() >= VersionTuple(9);
+ case WatchOS:
+ return true;
// This is really a lie, because some implementations and versions
// of the runtime do not support ARC. Probably -fgnu-runtime
// should imply a "maximal" runtime or something?
- case GCC: return true;
- case GNUstep: return true;
- case ObjFW: return true;
+ case GCC:
+ return true;
+ case GNUstep:
+ return true;
+ case ObjFW:
+ return true;
}
llvm_unreachable("bad kind");
}
/// Does this runtime allow sizeof or alignof on object types?
- bool allowsSizeofAlignof() const {
- return isFragile();
- }
+ bool allowsSizeofAlignof() const { return isFragile(); }
/// Does this runtime allow pointer arithmetic on objects?
///
@@ -354,13 +378,20 @@ class ObjCRuntime {
/// without it, abort() must be used in pure ObjC files.
bool hasTerminate() const {
switch (getKind()) {
- case FragileMacOSX: return getVersion() >= VersionTuple(10, 8);
- case MacOSX: return getVersion() >= VersionTuple(10, 8);
- case iOS: return getVersion() >= VersionTuple(5);
- case WatchOS: return true;
- case GCC: return false;
- case GNUstep: return false;
- case ObjFW: return false;
+ case FragileMacOSX:
+ return getVersion() >= VersionTuple(10, 8);
+ case MacOSX:
+ return getVersion() >= VersionTuple(10, 8);
+ case iOS:
+ return getVersion() >= VersionTuple(5);
+ case WatchOS:
+ return true;
+ case GCC:
+ return false;
+ case GNUstep:
+ return false;
+ case ObjFW:
+ return false;
}
llvm_unreachable("bad kind");
}
@@ -368,13 +399,20 @@ class ObjCRuntime {
/// Does this runtime support weakly importing classes?
bool hasWeakClassImport() const {
switch (getKind()) {
- case MacOSX: return true;
- case iOS: return true;
- case WatchOS: return true;
- case FragileMacOSX: return false;
- case GCC: return true;
- case GNUstep: return true;
- case ObjFW: return true;
+ case MacOSX:
+ return true;
+ case iOS:
+ return true;
+ case WatchOS:
+ return true;
+ case FragileMacOSX:
+ return false;
+ case GCC:
+ return true;
+ case GNUstep:
+ return true;
+ case ObjFW:
+ return true;
}
llvm_unreachable("bad kind");
}
@@ -382,13 +420,20 @@ class ObjCRuntime {
/// Does this runtime use zero-cost exceptions?
bool hasUnwindExceptions() const {
switch (getKind()) {
- case MacOSX: return true;
- case iOS: return true;
- case WatchOS: return true;
- case FragileMacOSX: return false;
- case GCC: return true;
- case GNUstep: return true;
- case ObjFW: return true;
+ case MacOSX:
+ return true;
+ case iOS:
+ return true;
+ case WatchOS:
+ return true;
+ case FragileMacOSX:
+ return false;
+ case GCC:
+ return true;
+ case GNUstep:
+ return true;
+ case ObjFW:
+ return true;
}
llvm_unreachable("bad kind");
}
@@ -402,7 +447,8 @@ class ObjCRuntime {
return true;
case GNUstep:
return getVersion() >= VersionTuple(1, 7);
- default: return false;
+ default:
+ return false;
}
}
@@ -457,13 +503,20 @@ class ObjCRuntime {
/// Does this runtime supports direct dispatch
bool allowsDirectDispatch() const {
switch (getKind()) {
- case FragileMacOSX: return false;
- case MacOSX: return true;
- case iOS: return true;
- case WatchOS: return true;
- case GCC: return false;
- case GNUstep: return false;
- case ObjFW: return false;
+ case FragileMacOSX:
+ return false;
+ case MacOSX:
+ return true;
+ case iOS:
+ return true;
+ case WatchOS:
+ return true;
+ case GCC:
+ return false;
+ case GNUstep:
+ return false;
+ case ObjFW:
+ return false;
}
llvm_unreachable("bad kind");
}
>From 5d2ee5e34277d2338573202634c6b349453c2b31 Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 21:43:09 +0100
Subject: [PATCH 4/8] Clang driver dispatch-method test for gnustep runtime
---
clang/test/Driver/gnustep-dispatch-method.m | 38 +++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 clang/test/Driver/gnustep-dispatch-method.m
diff --git a/clang/test/Driver/gnustep-dispatch-method.m b/clang/test/Driver/gnustep-dispatch-method.m
new file mode 100644
index 00000000000000..7f20455b9c2265
--- /dev/null
+++ b/clang/test/Driver/gnustep-dispatch-method.m
@@ -0,0 +1,38 @@
+// DEFINE: %{triple} =
+// DEFINE: %{ver} = 1.6
+// DEFINE: %{prefix} = CHECK-MSGSEND
+// DEFINE: %{check} = %clang --target=%{triple} -fobjc-runtime=gnustep-%{ver} -### -c %s 2>&1 | FileCheck -check-prefix=%{prefix} %s
+
+// REDEFINE: %{ver} = 1.6
+// REDEFINE: %{triple} = i386-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{triple} = x86_64-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{triple} = arm-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{prefix} = CHECK-MSGLOOKUP
+// REDEFINE: %{triple} = aarch64-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{triple} = mips64-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{triple} = riscv64-unknown-freebsd
+// RUN: %{check}
+
+// REDEFINE: %{ver} = 1.9
+// REDEFINE: %{prefix} = CHECK-MSGSEND
+// REDEFINE: %{triple} = aarch64-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{triple} = mips64-unknown-freebsd
+// RUN: %{check}
+// REDEFINE: %{prefix} = CHECK-MSGLOOKUP
+// REDEFINE: %{triple} = riscv64-unknown-freebsd
+// RUN: %{check}
+
+// REDEFINE: %{ver} = 2.2
+// REDEFINE: %{prefix} = CHECK-MSGSEND
+// REDEFINE: %{triple} = riscv64-unknown-freebsd
+// RUN: %{check}
+
+
+// CHECK-MSGSEND: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
+// CHECK-MSGLOOKUP-NOT: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
\ No newline at end of file
>From 4a67b4844afb31234fd1a927cbb2bb1982a2cc7b Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 21:48:23 +0100
Subject: [PATCH 5/8] gnustep-dispatch-method: Add trailing space
---
clang/test/Driver/gnustep-dispatch-method.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Driver/gnustep-dispatch-method.m b/clang/test/Driver/gnustep-dispatch-method.m
index 7f20455b9c2265..6cd043fb272043 100644
--- a/clang/test/Driver/gnustep-dispatch-method.m
+++ b/clang/test/Driver/gnustep-dispatch-method.m
@@ -35,4 +35,4 @@
// CHECK-MSGSEND: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
-// CHECK-MSGLOOKUP-NOT: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
\ No newline at end of file
+// CHECK-MSGLOOKUP-NOT: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
>From a10dbeed5c006bc8ca2fa4ccac9fd7ad88bc760b Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 21:53:45 +0100
Subject: [PATCH 6/8] CodeGenObjC: Add simple non-legacy dispatch gnustep test
---
clang/test/CodeGenObjC/messages.m | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/test/CodeGenObjC/messages.m b/clang/test/CodeGenObjC/messages.m
index f93d35a8d60c18..41f9d2fbc284c7 100644
--- a/clang/test/CodeGenObjC/messages.m
+++ b/clang/test/CodeGenObjC/messages.m
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC-NF
// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU
-// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF
+// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU-NF
+// RUN: %clang_cc1 -fobjc-runtime=gnustep-2.2 -fobjc-dispatch-method=non-legacy -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC
typedef struct {
int x;
>From c8cc84a297e59b1ed669faae930f3fd9ebeac1a0 Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 22:19:24 +0100
Subject: [PATCH 7/8] Revert "ObjCRuntime: format and update dispatch archs"
This reverts commit 7c69da720afc45f6d2e3b7e2cc62f09a257289da.
---
clang/include/clang/Basic/ObjCRuntime.h | 213 +++++++++---------------
1 file changed, 80 insertions(+), 133 deletions(-)
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index c368b6f3bf3b24..adfc04e3bd2d29 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -81,20 +81,13 @@ class ObjCRuntime {
/// "non-fragile" ABI?
bool isNonFragile() const {
switch (getKind()) {
- case FragileMacOSX:
- return false;
- case GCC:
- return false;
- case MacOSX:
- return true;
- case GNUstep:
- return true;
- case ObjFW:
- return true;
- case iOS:
- return true;
- case WatchOS:
- return true;
+ case FragileMacOSX: return false;
+ case GCC: return false;
+ case MacOSX: return true;
+ case GNUstep: return true;
+ case ObjFW: return true;
+ case iOS: return true;
+ case WatchOS: return true;
}
llvm_unreachable("bad kind");
}
@@ -107,24 +100,23 @@ class ObjCRuntime {
bool isLegacyDispatchDefaultForArch(llvm::Triple::ArchType Arch) {
// The GNUstep runtime uses a newer dispatch method by default from
// version 1.6 onwards
- if (getKind() == GNUstep) {
+ if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
switch (Arch) {
case llvm::Triple::arm:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
- return !(getVersion() >= VersionTuple(1, 6));
case llvm::Triple::aarch64:
case llvm::Triple::mips64:
- return !(getVersion() >= VersionTuple(1, 9));
case llvm::Triple::riscv64:
- return !(getVersion() >= VersionTuple(2, 2));
+ return false;
default:
return true;
}
- } else if ((getKind() == MacOSX) && isNonFragile() &&
- (getVersion() >= VersionTuple(10, 0)) &&
- (getVersion() < VersionTuple(10, 6)))
- return Arch != llvm::Triple::x86_64;
+ }
+ else if ((getKind() == MacOSX) && isNonFragile() &&
+ (getVersion() >= VersionTuple(10, 0)) &&
+ (getVersion() < VersionTuple(10, 6)))
+ return Arch != llvm::Triple::x86_64;
// Except for deployment target of 10.5 or less,
// Mac runtimes use legacy dispatch everywhere now.
return true;
@@ -159,18 +151,12 @@ class ObjCRuntime {
case FragileMacOSX:
// No stub library for the fragile runtime.
return getVersion() >= VersionTuple(10, 7);
- case MacOSX:
- return true;
- case iOS:
- return true;
- case WatchOS:
- return true;
- case GCC:
- return false;
- case GNUstep:
- return true;
- case ObjFW:
- return true;
+ case MacOSX: return true;
+ case iOS: return true;
+ case WatchOS: return true;
+ case GCC: return false;
+ case GNUstep: return true;
+ case ObjFW: return true;
}
llvm_unreachable("bad kind");
}
@@ -182,21 +168,14 @@ class ObjCRuntime {
/// library.
bool hasNativeARC() const {
switch (getKind()) {
- case FragileMacOSX:
- return getVersion() >= VersionTuple(10, 7);
- case MacOSX:
- return getVersion() >= VersionTuple(10, 7);
- case iOS:
- return getVersion() >= VersionTuple(5);
- case WatchOS:
- return true;
-
- case GCC:
- return false;
- case GNUstep:
- return getVersion() >= VersionTuple(1, 6);
- case ObjFW:
- return true;
+ case FragileMacOSX: return getVersion() >= VersionTuple(10, 7);
+ case MacOSX: return getVersion() >= VersionTuple(10, 7);
+ case iOS: return getVersion() >= VersionTuple(5);
+ case WatchOS: return true;
+
+ case GCC: return false;
+ case GNUstep: return getVersion() >= VersionTuple(1, 6);
+ case ObjFW: return true;
}
llvm_unreachable("bad kind");
}
@@ -294,21 +273,23 @@ class ObjCRuntime {
/// Does this runtime supports optimized setter entrypoints?
bool hasOptimizedSetter() const {
switch (getKind()) {
- case MacOSX:
- return getVersion() >= VersionTuple(10, 8);
- case iOS:
- return (getVersion() >= VersionTuple(6));
- case WatchOS:
- return true;
- case GNUstep:
- return getVersion() >= VersionTuple(1, 7);
- default:
- return false;
+ case MacOSX:
+ return getVersion() >= VersionTuple(10, 8);
+ case iOS:
+ return (getVersion() >= VersionTuple(6));
+ case WatchOS:
+ return true;
+ case GNUstep:
+ return getVersion() >= VersionTuple(1, 7);
+ default:
+ return false;
}
}
/// Does this runtime allow the use of __weak?
- bool allowsWeak() const { return hasNativeWeak(); }
+ bool allowsWeak() const {
+ return hasNativeWeak();
+ }
/// Does this runtime natively provide ARC-compliant 'weak'
/// entrypoints?
@@ -323,30 +304,25 @@ class ObjCRuntime {
/// This is really a property of the library, not the runtime.
bool hasSubscripting() const {
switch (getKind()) {
- case FragileMacOSX:
- return false;
- case MacOSX:
- return getVersion() >= VersionTuple(10, 11);
- case iOS:
- return getVersion() >= VersionTuple(9);
- case WatchOS:
- return true;
+ case FragileMacOSX: return false;
+ case MacOSX: return getVersion() >= VersionTuple(10, 11);
+ case iOS: return getVersion() >= VersionTuple(9);
+ case WatchOS: return true;
// This is really a lie, because some implementations and versions
// of the runtime do not support ARC. Probably -fgnu-runtime
// should imply a "maximal" runtime or something?
- case GCC:
- return true;
- case GNUstep:
- return true;
- case ObjFW:
- return true;
+ case GCC: return true;
+ case GNUstep: return true;
+ case ObjFW: return true;
}
llvm_unreachable("bad kind");
}
/// Does this runtime allow sizeof or alignof on object types?
- bool allowsSizeofAlignof() const { return isFragile(); }
+ bool allowsSizeofAlignof() const {
+ return isFragile();
+ }
/// Does this runtime allow pointer arithmetic on objects?
///
@@ -378,20 +354,13 @@ class ObjCRuntime {
/// without it, abort() must be used in pure ObjC files.
bool hasTerminate() const {
switch (getKind()) {
- case FragileMacOSX:
- return getVersion() >= VersionTuple(10, 8);
- case MacOSX:
- return getVersion() >= VersionTuple(10, 8);
- case iOS:
- return getVersion() >= VersionTuple(5);
- case WatchOS:
- return true;
- case GCC:
- return false;
- case GNUstep:
- return false;
- case ObjFW:
- return false;
+ case FragileMacOSX: return getVersion() >= VersionTuple(10, 8);
+ case MacOSX: return getVersion() >= VersionTuple(10, 8);
+ case iOS: return getVersion() >= VersionTuple(5);
+ case WatchOS: return true;
+ case GCC: return false;
+ case GNUstep: return false;
+ case ObjFW: return false;
}
llvm_unreachable("bad kind");
}
@@ -399,20 +368,13 @@ class ObjCRuntime {
/// Does this runtime support weakly importing classes?
bool hasWeakClassImport() const {
switch (getKind()) {
- case MacOSX:
- return true;
- case iOS:
- return true;
- case WatchOS:
- return true;
- case FragileMacOSX:
- return false;
- case GCC:
- return true;
- case GNUstep:
- return true;
- case ObjFW:
- return true;
+ case MacOSX: return true;
+ case iOS: return true;
+ case WatchOS: return true;
+ case FragileMacOSX: return false;
+ case GCC: return true;
+ case GNUstep: return true;
+ case ObjFW: return true;
}
llvm_unreachable("bad kind");
}
@@ -420,20 +382,13 @@ class ObjCRuntime {
/// Does this runtime use zero-cost exceptions?
bool hasUnwindExceptions() const {
switch (getKind()) {
- case MacOSX:
- return true;
- case iOS:
- return true;
- case WatchOS:
- return true;
- case FragileMacOSX:
- return false;
- case GCC:
- return true;
- case GNUstep:
- return true;
- case ObjFW:
- return true;
+ case MacOSX: return true;
+ case iOS: return true;
+ case WatchOS: return true;
+ case FragileMacOSX: return false;
+ case GCC: return true;
+ case GNUstep: return true;
+ case ObjFW: return true;
}
llvm_unreachable("bad kind");
}
@@ -447,8 +402,7 @@ class ObjCRuntime {
return true;
case GNUstep:
return getVersion() >= VersionTuple(1, 7);
- default:
- return false;
+ default: return false;
}
}
@@ -503,20 +457,13 @@ class ObjCRuntime {
/// Does this runtime supports direct dispatch
bool allowsDirectDispatch() const {
switch (getKind()) {
- case FragileMacOSX:
- return false;
- case MacOSX:
- return true;
- case iOS:
- return true;
- case WatchOS:
- return true;
- case GCC:
- return false;
- case GNUstep:
- return false;
- case ObjFW:
- return false;
+ case FragileMacOSX: return false;
+ case MacOSX: return true;
+ case iOS: return true;
+ case WatchOS: return true;
+ case GCC: return false;
+ case GNUstep: return false;
+ case ObjFW: return false;
}
llvm_unreachable("bad kind");
}
>From 9e7749554f3c448bb4b0d249a0b494178376e569 Mon Sep 17 00:00:00 2001
From: hmelder <service at hugomelder.com>
Date: Tue, 2 Jan 2024 22:21:47 +0100
Subject: [PATCH 8/8] ObjCRuntime: Update gnustep dispatch archs with
versioning
---
clang/include/clang/Basic/ObjCRuntime.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index adfc04e3bd2d29..4a2979aa42a202 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -100,15 +100,17 @@ class ObjCRuntime {
bool isLegacyDispatchDefaultForArch(llvm::Triple::ArchType Arch) {
// The GNUstep runtime uses a newer dispatch method by default from
// version 1.6 onwards
- if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
+ if (getKind() == GNUstep) {
switch (Arch) {
case llvm::Triple::arm:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
+ return !(getVersion() >= VersionTuple(1, 6));
case llvm::Triple::aarch64:
case llvm::Triple::mips64:
+ return !(getVersion() >= VersionTuple(1, 9));
case llvm::Triple::riscv64:
- return false;
+ return !(getVersion() >= VersionTuple(2, 2));
default:
return true;
}
More information about the cfe-commits
mailing list