[llvm-branch-commits] [libcxx] [clang-tools-extra] [mlir] [libc] [compiler-rt] [llvm] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [libc] [compiler-rt] [mlir] [clang] [libcxx] [clang-tools-extra] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [mlir] [llvm] [libcxx] [clang-tools-extra] [libc] [compiler-rt] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [llvm] [clang] [clang-tools-extra] [compiler-rt] [mlir] [libc] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [clang-tools-extra] [mlir] [libc] [compiler-rt] [llvm] [clang] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [llvm] [clang] [mlir] [libcxx] [clang-tools-extra] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [clang-tools-extra] [mlir] [libc] [lld] [libcxxabi] [flang] [compiler-rt] [llvm] [clang] [lldb] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [lld] [libcxx] [llvm] [mlir] [libcxxabi] [libc] [clang] [flang] [compiler-rt] [clang-tools-extra] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [compiler-rt] [lld] [llvm] [libc] [libcxxabi] [clang-tools-extra] [libcxx] [clang] [mlir] [flang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] [libcxx] [compiler-rt] [lldb] [mlir] [flang] [libcxxabi] [clang-tools-extra] [libc] [clang] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [clang-tools-extra] [libc] [clang] [compiler-rt] [libcxx] [flang] [lld] [mlir] [lldb] [libcxxabi] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [libcxxabi] [clang-tools-extra] [libcxx] [mlir] [libc] [llvm] [compiler-rt] [clang] [lld] [flang] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [lldb] [mlir] [libc] [libcxx] [clang-tools-extra] [flang] [libcxxabi] [compiler-rt] [lld] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Eric Christopher via llvm-branch-commits

https://github.com/echristo approved this pull request.

SGTM. 

https://github.com/llvm/llvm-project/pull/73687
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [flang] [lldb] [clang] [llvm] [clang-tools-extra] [libc] [mlir] [libcxxabi] [lld] [libcxx] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [lldb] [libc] [clang] [lld] [mlir] [llvm] [libcxxabi] [clang-tools-extra] [flang] [libcxx] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [mlir] [clang] [libc] [flang] [llvm] [libcxx] [clang-tools-extra] [lld] [libcxxabi] [lldb] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [lld] [libcxxabi] [clang-tools-extra] [clang] [llvm] [flang] [compiler-rt] [lldb] [libcxx] [mlir] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [mlir] [clang] [libc] [flang] [llvm] [libcxx] [clang-tools-extra] [lld] [libcxxabi] [lldb] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxxabi] [libc] [compiler-rt] [clang] [llvm] [libcxx] [flang] [lldb] [clang-tools-extra] [lld] [mlir] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [clang] [mlir] [compiler-rt] [libc] [clang-tools-extra] [libcxx] [libcxxabi] [lld] [llvm] [flang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #7368

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [clang-tools-extra] [clang] [flang] [libcxxabi] [libc] [lld] [libcxx] [mlir] [llvm] [compiler-rt] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] [clang-tools-extra] [libcxxabi] [lld] [mlir] [llvm] [libc] [libcxx] [clang] [flang] [compiler-rt] [clang] Function Multi Versioning supports IFunc lowerings on Darwin plat

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [libc] [clang-tools-extra] [clang] [mlir] [libcxx] [llvm] [lldb] [flang] [compiler-rt] [libcxxabi] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [libc] [mlir] [compiler-rt] [lld] [llvm] [libcxxabi] [clang] [libcxx] [flang] [lldb] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c..001467a9f7ff5 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [llvm] [clang] [HLSL] RWBuffer should not have a default parameter (PR #71265)

2023-12-06 Thread Justin Bogner via llvm-branch-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71265


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [clang] [clang-tools-extra] [HLSL] RWBuffer should not have a default parameter (PR #71265)

2023-12-06 Thread Justin Bogner via llvm-branch-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71265


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [clang] [llvm] [HLSL] Add helpers to simplify HLSL resource type declarations. NFC (PR #73967)

2023-12-06 Thread Justin Bogner via llvm-branch-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/73967


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [llvm] [clang] [HLSL] Add helpers to simplify HLSL resource type declarations. NFC (PR #73967)

2023-12-06 Thread Justin Bogner via llvm-branch-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/73967


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libcxxabi] [lldb] [clang-tools-extra] [openmp] [flang] [libc] [lld] [compiler-rt] [clang] [llvm] [mlir] [clang] Support __attribute__((ifunc(...))) on Darwin platforms

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [compiler-rt] [lldb] [lld] [clang] [libcxx] [clang-tools-extra] [llvm] [mlir] [flang] [libcxxabi] [openmp] [clang] Support __attribute__((ifunc(...))) on Darwin platforms

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73687

>From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 12:23:46 -0800
Subject: [PATCH] adjust tests per review feedback

Created using spr 1.3.4
---
 clang/test/CodeGen/attr-ifunc.c   | 20 +++
 clang/test/CodeGen/attr-ifunc.cpp |  4 
 .../CodeGenCXX/externc-ifunc-resolver.cpp |  2 ++
 clang/test/SemaCXX/externc-ifunc-resolver.cpp |  4 
 4 files changed, 30 insertions(+)

diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 4f8fe13530fdb..2ad41edf20dfa 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 
 #if defined(_WIN32)
 void foo(void) {}
@@ -36,6 +37,25 @@ void *f6_resolver(void) 
__attribute__((ifunc("f6_resolver_resolver")));
 void f6(void) __attribute__((ifunc("f6_resolver")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
+#elif defined(__APPLE__)
+
+// NOTE: aliases are not supported on Darwin, so the above tests are not 
relevant.
+
+#define STR2(X) #X
+#define STR(X) STR2(X)
+#define PREFIX STR(__USER_LABEL_PREFIX__)
+
+void f1a(void) __asm("f1");
+void f1a(void) {}
+// expected-note@-1 {{previous definition is here}}
+void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1");
+// expected-error@-1 {{definition with same mangled name 'f1' as 
another definition}}
+void *f1_ifunc(void) { return 0; }
+
+void *f6_ifunc(int i);
+void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #else
 void f1a(void) __asm("f1");
 void f1a(void) {}
diff --git a/clang/test/CodeGen/attr-ifunc.cpp 
b/clang/test/CodeGen/attr-ifunc.cpp
index 5b5b2c14b4074..b6e342df46eb5 100644
--- a/clang/test/CodeGen/attr-ifunc.cpp
+++ b/clang/test/CodeGen/attr-ifunc.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify 
-emit-llvm-only %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 void *f1_ifunc(void) { return nullptr; }
 void f1(void) __attribute__((ifunc("f1_ifunc")));
diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp 
b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
index 0518a8dcc831d..be4453ae7eb08 100644
--- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }
diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp 
b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
index aa44525bde2ca..6c6c262c5f09d 100644
--- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp
+++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s
+// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s
 // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 extern "C" {
 __attribute__((used)) static void *resolve_foo() { return 0; }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [libc] [llvm] [openmp] [lldb] [libcxx] [libcxxabi] [lld] [clang-tools-extra] [clang] [flang] [mlir] [clang] Function Multi Versioning supports IFunc lowerings on Da

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [mlir] [flang] [libc] [lldb] [compiler-rt] [libcxx] [libcxxabi] [clang] [llvm] [lld] [openmp] [clang] Function Multi Versioning supports IFunc lowerings on Da

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73688


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [libc] [llvm] [openmp] [lldb] [libcxx] [libcxxabi] [lld] [clang-tools-extra] [clang] [flang] [mlir] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c4..001467a9f7ff51 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [libc] [lldb] [lld] [clang] [libcxx] [clang-tools-extra] [llvm] [mlir] [flang] [libcxxabi] [openmp] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl

2023-12-06 Thread Jon Roelofs via llvm-branch-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73685

>From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Wed, 29 Nov 2023 14:21:54 -0800
Subject: [PATCH] add a note about the dispatch_once block

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/cpu_model.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 5f5182859080c4..001467a9f7ff51 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) {
 }
 
 void __init_cpu_features_resolver(void) {
+  // On Darwin platforms, this may be called concurrently by multiple threads
+  // because the resolvers that use it are called lazily at runtime (unlike on
+  // ELF platforms, where IFuncs are resolved serially at load time).  This
+  // function's effect on __aarch64_cpu_features should be idempotent, but even
+  // so we need dispatch_once to resolve the race condition.  Dispatch is
+  // available through libSystem, which we need anyway for the sysctl, so this
+  // does not add a new dependency.
+
   static dispatch_once_t onceToken = 0;
   dispatch_once(&onceToken, ^{
 // 
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [clang] [lld] [openmp] [clang-tools-extra] [mlir] [llvm] [HLSL] RWBuffer should not have a default parameter (PR #71265)

2023-12-06 Thread Justin Bogner via llvm-branch-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71265

>From 1779fd08dad4f03ae5e9f1803b8ea3d7dc77c093 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 19:03:00 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5

[skip ci]
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9..a86c428c9121a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e4531..de5cc07f5d428 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f..0952b065d56b5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac..603b7465323e2 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee35486221280..1a6eaa196db09 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Temp

[llvm-branch-commits] [openmp] 57dd853 - Revert " [OpenMP][NFC] Remove `DelayedBinDesc` (#74360)"

2023-12-06 Thread via llvm-branch-commits

Author: Johannes Doerfert
Date: 2023-12-06T16:00:30-08:00
New Revision: 57dd853fd39a76a5c3211fb3c64ed915934f257b

URL: 
https://github.com/llvm/llvm-project/commit/57dd853fd39a76a5c3211fb3c64ed915934f257b
DIFF: 
https://github.com/llvm/llvm-project/commit/57dd853fd39a76a5c3211fb3c64ed915934f257b.diff

LOG: Revert " [OpenMP][NFC] Remove `DelayedBinDesc` (#74360)"

This reverts commit d552ce263839ea92ae6bc5d05cf5e20b711019d1.

Added: 


Modified: 
openmp/libomptarget/include/PluginManager.h
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/rtl.cpp

Removed: 
openmp/libomptarget/test/Inputs/empty.c
openmp/libomptarget/test/offloading/bug60119.c



diff  --git a/openmp/libomptarget/include/PluginManager.h 
b/openmp/libomptarget/include/PluginManager.h
index 6af99efa32a0c..0b0974709b525 100644
--- a/openmp/libomptarget/include/PluginManager.h
+++ b/openmp/libomptarget/include/PluginManager.h
@@ -150,6 +150,24 @@ struct PluginManager {
   HostPtrToTableMapTy HostPtrToTableMap;
   std::mutex TblMapMtx; ///< For HostPtrToTableMap
 
+  // Work around for plugins that call dlopen on shared libraries that call
+  // tgt_register_lib during their initialisation. Stash the pointers in a
+  // vector until the plugins are all initialised and then register them.
+  bool delayRegisterLib(__tgt_bin_desc *Desc) {
+if (RTLsLoaded)
+  return false;
+DelayedBinDesc.push_back(Desc);
+return true;
+  }
+
+  void registerDelayedLibraries() {
+// Only called by libomptarget constructor
+RTLsLoaded = true;
+for (auto *Desc : DelayedBinDesc)
+  __tgt_register_lib(Desc);
+DelayedBinDesc.clear();
+  }
+
   /// Return the number of usable devices.
   int getNumDevices() { return getExclusiveDevicesAccessor()->size(); }
 
@@ -178,6 +196,9 @@ struct PluginManager {
   void addRequirements(int64_t Flags) { Requirements.addRequirements(Flags); }
 
 private:
+  bool RTLsLoaded = false;
+  llvm::SmallVector<__tgt_bin_desc *> DelayedBinDesc;
+
   // List of all plugin adaptors, in use or not.
   llvm::SmallVector> PluginAdaptors;
 

diff  --git a/openmp/libomptarget/src/interface.cpp 
b/openmp/libomptarget/src/interface.cpp
index 777dc07943aa6..d92f40ce1d14e 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -46,6 +46,9 @@ EXTERN void __tgt_register_requires(int64_t Flags) {
 /// adds a target shared library to the target execution image
 EXTERN void __tgt_register_lib(__tgt_bin_desc *Desc) {
   TIMESCOPE();
+  if (PM->delayRegisterLib(Desc))
+return;
+
   PM->registerLib(Desc);
 }
 

diff  --git a/openmp/libomptarget/src/rtl.cpp b/openmp/libomptarget/src/rtl.cpp
index 27db7034d8956..5eb1c553df491 100644
--- a/openmp/libomptarget/src/rtl.cpp
+++ b/openmp/libomptarget/src/rtl.cpp
@@ -51,6 +51,7 @@ __attribute__((constructor(101))) void init() {
   PM->init();
 
   Profiler::get();
+  PM->registerDelayedLibraries();
 }
 
 __attribute__((destructor(101))) void deinit() {

diff  --git a/openmp/libomptarget/test/Inputs/empty.c 
b/openmp/libomptarget/test/Inputs/empty.c
deleted file mode 100644
index 8b137891791fe..0
--- a/openmp/libomptarget/test/Inputs/empty.c
+++ /dev/null
@@ -1 +0,0 @@
-

diff  --git a/openmp/libomptarget/test/offloading/bug60119.c 
b/openmp/libomptarget/test/offloading/bug60119.c
deleted file mode 100644
index e32f1ccd59881..0
--- a/openmp/libomptarget/test/offloading/bug60119.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang-generic -fPIC -shared %S/../Inputs/empty.c -o %T/liba.so
-// RUN: %clang-generic -fPIC -shared %S/../Inputs/empty.c -o %T/libb.so
-// RUN: %clang-generic -rpath %T -L %T -l a -l b %s -o %t
-// RUN: %t
-
-int main() {}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 662487d - Revert "[XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (#70642)"

2023-12-06 Thread via llvm-branch-commits

Author: Esme
Date: 2023-12-07T14:47:56+08:00
New Revision: 662487d74653206942f261e6ffb87cfde104f382

URL: 
https://github.com/llvm/llvm-project/commit/662487d74653206942f261e6ffb87cfde104f382
DIFF: 
https://github.com/llvm/llvm-project/commit/662487d74653206942f261e6ffb87cfde104f382.diff

LOG: Revert "[XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF 
(#70642)"

This reverts commit 0e3faa20c467e6cd62423b22cf8650c6aa2628ba.

Added: 


Modified: 
llvm/include/llvm/Object/XCOFFObjectFile.h
llvm/lib/ObjectYAML/XCOFFYAML.cpp
llvm/test/tools/obj2yaml/XCOFF/aix.yaml
llvm/tools/obj2yaml/xcoff2yaml.cpp

Removed: 
llvm/test/tools/obj2yaml/XCOFF/aux-symbols.yaml



diff  --git a/llvm/include/llvm/Object/XCOFFObjectFile.h 
b/llvm/include/llvm/Object/XCOFFObjectFile.h
index 47926ab3ae401..9492284ea93d3 100644
--- a/llvm/include/llvm/Object/XCOFFObjectFile.h
+++ b/llvm/include/llvm/Object/XCOFFObjectFile.h
@@ -411,13 +411,13 @@ class XCOFFCsectAuxRef {
 return Entry64->AuxType;
   }
 
+private:
   uint8_t getSymbolAlignmentAndType() const {
 return GETVALUE(SymbolAlignmentAndType);
   }
 
 #undef GETVALUE
 
-private:
   const XCOFFCsectAuxEnt32 *Entry32 = nullptr;
   const XCOFFCsectAuxEnt64 *Entry64 = nullptr;
 };

diff  --git a/llvm/lib/ObjectYAML/XCOFFYAML.cpp 
b/llvm/lib/ObjectYAML/XCOFFYAML.cpp
index b71a7b8b6cb44..44ef33501b65e 100644
--- a/llvm/lib/ObjectYAML/XCOFFYAML.cpp
+++ b/llvm/lib/ObjectYAML/XCOFFYAML.cpp
@@ -282,57 +282,45 @@ static void auxSymMapping(IO &IO, 
XCOFFYAML::SectAuxEntForStat &AuxSym) {
 
 void MappingTraits>::mapping(
 IO &IO, std::unique_ptr &AuxSym) {
-
-  auto ResetAuxSym = [&](auto *AuxEnt) {
-if (!IO.outputting())
-  AuxSym.reset(AuxEnt);
-  };
-
+  assert(!IO.outputting() && "We don't dump aux symbols currently.");
   const bool Is64 =
   static_cast(IO.getContext())->Header.Magic ==
   (llvm::yaml::Hex16)XCOFF::XCOFF64;
-
   XCOFFYAML::AuxSymbolType AuxType;
-  if (IO.outputting())
-AuxType = AuxSym.get()->Type;
   IO.mapRequired("Type", AuxType);
   switch (AuxType) {
   case XCOFFYAML::AUX_EXCEPT:
-if (!Is64) {
+if (!Is64)
   IO.setError("an auxiliary symbol of type AUX_EXCEPT cannot be defined in 
"
   "XCOFF32");
-  return;
-}
-ResetAuxSym(new XCOFFYAML::ExcpetionAuxEnt());
+AuxSym.reset(new XCOFFYAML::ExcpetionAuxEnt());
 auxSymMapping(IO, *cast(AuxSym.get()));
 break;
   case XCOFFYAML::AUX_FCN:
-ResetAuxSym(new XCOFFYAML::FunctionAuxEnt());
+AuxSym.reset(new XCOFFYAML::FunctionAuxEnt());
 auxSymMapping(IO, *cast(AuxSym.get()), Is64);
 break;
   case XCOFFYAML::AUX_SYM:
-ResetAuxSym(new XCOFFYAML::BlockAuxEnt());
+AuxSym.reset(new XCOFFYAML::BlockAuxEnt());
 auxSymMapping(IO, *cast(AuxSym.get()), Is64);
 break;
   case XCOFFYAML::AUX_FILE:
-ResetAuxSym(new XCOFFYAML::FileAuxEnt());
+AuxSym.reset(new XCOFFYAML::FileAuxEnt());
 auxSymMapping(IO, *cast(AuxSym.get()));
 break;
   case XCOFFYAML::AUX_CSECT:
-ResetAuxSym(new XCOFFYAML::CsectAuxEnt());
+AuxSym.reset(new XCOFFYAML::CsectAuxEnt());
 auxSymMapping(IO, *cast(AuxSym.get()), Is64);
 break;
   case XCOFFYAML::AUX_SECT:
-ResetAuxSym(new XCOFFYAML::SectAuxEntForDWARF());
+AuxSym.reset(new XCOFFYAML::SectAuxEntForDWARF());
 auxSymMapping(IO, *cast(AuxSym.get()));
 break;
   case XCOFFYAML::AUX_STAT:
-if (Is64) {
+if (Is64)
   IO.setError(
   "an auxiliary symbol of type AUX_STAT cannot be defined in XCOFF64");
-  return;
-}
-ResetAuxSym(new XCOFFYAML::SectAuxEntForStat());
+AuxSym.reset(new XCOFFYAML::SectAuxEntForStat());
 auxSymMapping(IO, *cast(AuxSym.get()));
 break;
   }
@@ -346,7 +334,8 @@ void MappingTraits::mapping(IO &IO, 
XCOFFYAML::Symbol &S) {
   IO.mapOptional("Type", S.Type);
   IO.mapOptional("StorageClass", S.StorageClass);
   IO.mapOptional("NumberOfAuxEntries", S.NumberOfAuxEntries);
-  IO.mapOptional("AuxEntries", S.AuxEntries);
+  if (!IO.outputting())
+IO.mapOptional("AuxEntries", S.AuxEntries);
 }
 
 void MappingTraits::mapping(IO &IO, 
XCOFFYAML::StringTable &Str) {

diff  --git a/llvm/test/tools/obj2yaml/XCOFF/aix.yaml 
b/llvm/test/tools/obj2yaml/XCOFF/aix.yaml
index fbd5fa0629d10..cd1e88dec11d2 100644
--- a/llvm/test/tools/obj2yaml/XCOFF/aix.yaml
+++ b/llvm/test/tools/obj2yaml/XCOFF/aix.yaml
@@ -52,30 +52,12 @@
 # CHECK32-NEXT: Type:0x0
 # CHECK32-NEXT: StorageClass:C_EXT
 # CHECK32-NEXT: NumberOfAuxEntries: 1
-# CHECK32-NEXT: AuxEntries:
-# CHECK32-NEXT:   - Type:AUX_CSECT
-# CHECK32-NEXT: ParameterHashIndex: 0
-# CHECK32-NEXT: TypeChkSectNum:  0
-# CHECK32-NEXT: SymbolAlignmentAndType: 0
-# CHECK32-NEXT: StorageMappingClass: XMC_PR
-# CHECK32-NEXT: SectionOrLength: 0
-# CHECK32-NEXT: S