[llvm-branch-commits] [compiler-rt] 288d97b - [𝘀𝗽𝗿] initial version

2023-12-01 Thread Zachary Johnson via llvm-branch-commits

Author: Zachary Johnson
Date: 2023-12-01T09:50:33-05:00
New Revision: 288d97bf080136cd91b9d5c359a3178281f6e72f

URL: 
https://github.com/llvm/llvm-project/commit/288d97bf080136cd91b9d5c359a3178281f6e72f
DIFF: 
https://github.com/llvm/llvm-project/commit/288d97bf080136cd91b9d5c359a3178281f6e72f.diff

LOG: [𝘀𝗽𝗿] initial version

Created using spr 1.3.4

Added: 


Modified: 
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_malloc_mac.cpp
compiler-rt/lib/asan/asan_rtl.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index 234b18bd83aa541..a58436de4ef7412 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,14 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
-ASAN_INTERCEPTOR_ENTER(ctx, func);\
-do {  \
-  if (AsanInitIsRunning())\
-return REAL(func)(__VA_ARGS__);   \
-  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
-return REAL(func)(__VA_ARGS__);   \
-  ENSURE_ASAN_INITED();   \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)   \
+ASAN_INTERCEPTOR_ENTER(ctx, func);   \
+do { \
+  if (asan_init_is_running)  \
+return REAL(func)(__VA_ARGS__);  \
+  if (SANITIZER_APPLE && UNLIKELY(!asan_inited)) \
+return REAL(func)(__VA_ARGS__);  \
+  ENSURE_ASAN_INITED();  \
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -556,7 +556,7 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!asan_inited))
 return internal_strdup(s);
   ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
@@ -575,7 +575,7 @@ INTERCEPTOR(char*, strdup, const char *s) {
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!asan_inited))
 return internal_strdup(s);
   ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
@@ -636,7 +636,7 @@ INTERCEPTOR(int, atoi, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
 #if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!asan_inited))
 return REAL(atoi)(nptr);
 #  endif
   ENSURE_ASAN_INITED();
@@ -658,7 +658,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
 #if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!asan_inited))
 return REAL(atol)(nptr);
 #  endif
   ENSURE_ASAN_INITED();
@@ -697,7 +697,7 @@ static void AtCxaAtexit(void *unused) {
 INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
 void *dso_handle) {
 #if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!asan_inited))
 return REAL(__cxa_atexit)(func, arg, dso_handle);
 #endif
   ENSURE_ASAN_INITED();

diff  --git a/compiler-rt/lib/asan/asan_malloc_mac.cpp 
b/compiler-rt/lib/asan/asan_malloc_mac.cpp
index d2380ee62bf3dff..496a7b940218a2e 100644
--- a/compiler-rt/lib/asan/asan_malloc_mac.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_mac.cpp
@@ -23,7 +23,7 @@
 using namespace __asan;
 #define COMMON_MALLOC_ZONE_NAME "asan"
 #define COMMON_MALLOC_ENTER() ENSURE_ASAN_INITED()
-#  define COMMON_MALLOC_SANITIZER_INITIALIZED AsanInited()
+#  define COMMON_MALLOC_SANITIZER_INITIALIZED asan_inited
 #  define COMMON_MALLOC_FORCE_LOCK() asan_mz_force_lock()
 #  define COMMON_MALLOC_FORCE_UNLOCK() asan_mz_force_unlock()
 #  define COMMON_MALLOC_MEMALIGN(alignment, size) \

diff  --git a/compiler-rt/lib/asan/asan_rtl.cpp 
b/compiler-rt/lib/asan/asan_rtl.cpp
index d1e7856973b43b3..3d7afdacd866531 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -391,7 +391,7 @@ void PrintAddressSpaceLayout() {
 }
 
 static void AsanInitInternal() {
-  if (LIKELY(AsanInited()))
+  if (LIKELY(asan_inited))
 return;
   SanitizerToolName = "AddressSanitizer";
   CHECK(!AsanInitIsRunning() && "ASan init calls itself!");



___
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] [NFC][asan] Change asan_init and asan_init_is_running; add setters/getters (PR #74085)

2023-12-01 Thread Zack Johnson via llvm-branch-commits

https://github.com/zacklj89 created 
https://github.com/llvm/llvm-project/pull/74085

None


___
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] 1449b52 - [𝘀𝗽𝗿] initial version

2023-12-01 Thread Zachary Johnson via llvm-branch-commits

Author: Zachary Johnson
Date: 2023-12-01T09:50:53-05:00
New Revision: 1449b5262b8d6f04389546611a7e2f3c9e5cc02e

URL: 
https://github.com/llvm/llvm-project/commit/1449b5262b8d6f04389546611a7e2f3c9e5cc02e
DIFF: 
https://github.com/llvm/llvm-project/commit/1449b5262b8d6f04389546611a7e2f3c9e5cc02e.diff

LOG: [𝘀𝗽𝗿] initial version

Created using spr 1.3.4

Added: 


Modified: 
compiler-rt/lib/asan/asan_internal.h
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/asan_thread.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_internal.h 
b/compiler-rt/lib/asan/asan_internal.h
index e2b1e9800f5be62..569f8aedc69a1d0 100644
--- a/compiler-rt/lib/asan/asan_internal.h
+++ b/compiler-rt/lib/asan/asan_internal.h
@@ -130,6 +130,17 @@ void InstallAtExitCheckLeaks();
   if (&__asan_on_error) \
   __asan_on_error()
 
+// Unless synchronization is used during initialization, 
+// race conditions can appear causing incorrect states or internal check
+// failures, depending on the loading thread and when ASAN is loaded on 
Windows.
+// From a multithreaded managed environment, if an ASAN instrumented dll
+// is loading on a spawned thread, an intercepted function may be called on
+// multiple threads while ASAN is still in the process of initialization. This
+// can also cause the ASAN thread registry to create the "main" thread after
+// another thread, resulting in a TID != 0.
+//
+// Two threads can also race to initialize ASAN, resulting in either incorrect
+// state or internal check failures for init already running.
 bool AsanInited();
 bool AsanInitIsRunning();  // Used to avoid infinite recursion in 
__asan_init().
 extern bool replace_intrin_cached;

diff  --git a/compiler-rt/lib/asan/asan_rtl.cpp 
b/compiler-rt/lib/asan/asan_rtl.cpp
index d1e7856973b43b3..092ddf15d5a3db2 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -71,16 +71,54 @@ static void CheckUnwind() {
 }
 
 // -- Globals - {{{1
-static int asan_inited = 0;
-static int asan_init_is_running = 0;
+#if SANITIZER_WINDOWS
+atomic_uint8_t asan_inited{0};
+atomic_uint8_t asan_init_is_running{0};
+#else
+int asan_inited = 0;
+int asan_init_is_running = 0;
+#endif
 
-void SetAsanInited(u32 val) { asan_inited = val; }
+void SetAsanInited(u32 val) {
+#if SANITIZER_WINDOWS
+  atomic_store(&asan_inited, val, memory_order_release);
+#else
+  asan_inited = val;
+#endif
+}
 
-void SetAsanInitIsRunning(u32 val) { asan_init_is_running = val; }
+void SetAsanInitIsRunning(u32 val) {
+#if SANITIZER_WINDOWS
+  atomic_store(&asan_init_is_running, val, memory_order_release);
+#else
+  asan_init_is_running = val;
+#endif
+}
 
-bool AsanInited() { return asan_inited == 1; }
+bool AsanInited() {
+#if SANITIZER_WINDOWS
+  return atomic_load(&asan_inited, memory_order_acquire) == 1;
+#else
+  return asan_inited == 1;
+#endif
+}
 
-bool AsanInitIsRunning() { return asan_init_is_running == 1; }
+bool AsanInitIsRunning() {
+#if SANITIZER_WINDOWS
+  return atomic_load(&asan_init_is_running, memory_order_acquire) == 1;
+#else
+  return asan_init_is_running == 1;
+#endif
+}
+
+void CheckAsanInitRunning() {
+#if SANITIZER_WINDOWS
+  while (AsanInitIsRunning()) {
+// If ASAN is initializing on another thread, wait for it to finish.
+internal_sched_yield();
+  }
+#endif
+}
 
 bool replace_intrin_cached;
 
@@ -391,6 +429,7 @@ void PrintAddressSpaceLayout() {
 }
 
 static void AsanInitInternal() {
+  CheckAsanInitRunning();
   if (LIKELY(AsanInited()))
 return;
   SanitizerToolName = "AddressSanitizer";

diff  --git a/compiler-rt/lib/asan/asan_thread.cpp 
b/compiler-rt/lib/asan/asan_thread.cpp
index 8798968947e82e6..dc0ad2caf3bbd10 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -27,6 +27,10 @@ namespace __asan {
 
 // AsanThreadContext implementation.
 
+#if SANITIZER_WINDOWS
+static atomic_uint8_t main_thread_created{0};
+#endif
+
 void AsanThreadContext::OnCreated(void *arg) {
   CreateThreadContextArgs *args = static_cast(arg);
   if (args->stack)
@@ -93,6 +97,12 @@ AsanThreadContext *GetThreadContextByTidLocked(u32 tid) {
 AsanThread *AsanThread::Create(const void *start_data, uptr data_size,
u32 parent_tid, StackTrace *stack,
bool detached) {
+#if SANITIZER_WINDOWS
+  while (atomic_load(&main_thread_created, memory_order_acquire) == 0) {
+// If another thread is trying to be created before the main thread, wait.
+internal_sched_yield();
+  }
+#endif
   uptr PageSize = GetPageSizeCached();
   uptr size = RoundUpTo(sizeof(AsanThread), PageSize);
   AsanThread *thread = (AsanThread *)MmapOrDie(size, __func__);
@@ -288,11 +298,25 @@ void AsanThread::ThreadStart(tid_t os_id) {
 }
 
 AsanThread *CreateMainThread() {
+// Depending on the loading thread, specifically in m

[llvm-branch-commits] [NFC][asan] Change asan_init and asan_init_is_running; add setters/getters (PR #74085)

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

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Zack Johnson (zacklj89)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74085.diff


3 Files Affected:

- (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+13-13) 
- (modified) compiler-rt/lib/asan/asan_malloc_mac.cpp (+1-1) 
- (modified) compiler-rt/lib/asan/asan_rtl.cpp (+1-1) 


``diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index a58436de4ef7412..234b18bd83aa541 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,14 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)   \
-ASAN_INTERCEPTOR_ENTER(ctx, func);   \
-do { \
-  if (asan_init_is_running)  \
-return REAL(func)(__VA_ARGS__);  \
-  if (SANITIZER_APPLE && UNLIKELY(!asan_inited)) \
-return REAL(func)(__VA_ARGS__);  \
-  ENSURE_ASAN_INITED();  \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
+ASAN_INTERCEPTOR_ENTER(ctx, func);\
+do {  \
+  if (AsanInitIsRunning())\
+return REAL(func)(__VA_ARGS__);   \
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
+return REAL(func)(__VA_ARGS__);   \
+  ENSURE_ASAN_INITED();   \
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -556,7 +556,7 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(!AsanInited()))
 return internal_strdup(s);
   ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
@@ -575,7 +575,7 @@ INTERCEPTOR(char*, strdup, const char *s) {
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(!AsanInited()))
 return internal_strdup(s);
   ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
@@ -636,7 +636,7 @@ INTERCEPTOR(int, atoi, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
 #if SANITIZER_APPLE
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(!AsanInited()))
 return REAL(atoi)(nptr);
 #  endif
   ENSURE_ASAN_INITED();
@@ -658,7 +658,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
 #if SANITIZER_APPLE
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(!AsanInited()))
 return REAL(atol)(nptr);
 #  endif
   ENSURE_ASAN_INITED();
@@ -697,7 +697,7 @@ static void AtCxaAtexit(void *unused) {
 INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
 void *dso_handle) {
 #if SANITIZER_APPLE
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(!AsanInited()))
 return REAL(__cxa_atexit)(func, arg, dso_handle);
 #endif
   ENSURE_ASAN_INITED();
diff --git a/compiler-rt/lib/asan/asan_malloc_mac.cpp 
b/compiler-rt/lib/asan/asan_malloc_mac.cpp
index 496a7b940218a2e..d2380ee62bf3dff 100644
--- a/compiler-rt/lib/asan/asan_malloc_mac.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_mac.cpp
@@ -23,7 +23,7 @@
 using namespace __asan;
 #define COMMON_MALLOC_ZONE_NAME "asan"
 #define COMMON_MALLOC_ENTER() ENSURE_ASAN_INITED()
-#  define COMMON_MALLOC_SANITIZER_INITIALIZED asan_inited
+#  define COMMON_MALLOC_SANITIZER_INITIALIZED AsanInited()
 #  define COMMON_MALLOC_FORCE_LOCK() asan_mz_force_lock()
 #  define COMMON_MALLOC_FORCE_UNLOCK() asan_mz_force_unlock()
 #  define COMMON_MALLOC_MEMALIGN(alignment, size) \
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp 
b/compiler-rt/lib/asan/asan_rtl.cpp
index 3d7afdacd866531..d1e7856973b43b3 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -391,7 +391,7 @@ void PrintAddressSpaceLayout() {
 }
 
 static void AsanInitInternal() {
-  if (LIKELY(asan_inited))
+  if (LIKELY(AsanInited()))
 return;
   SanitizerToolName = "AddressSanitizer";
   CHECK(!AsanInitIsRunning() && "ASan init calls itself!");

``




https://github.com/llvm/llvm-project/pull/74085
___
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] 6232394 - More run lines, neon mappings, negative stride test

2023-12-01 Thread Graham Hunter via llvm-branch-commits

Author: Graham Hunter
Date: 2023-12-01T16:06:25Z
New Revision: 62323944c4a6447dab25145de7dd816a54e499c4

URL: 
https://github.com/llvm/llvm-project/commit/62323944c4a6447dab25145de7dd816a54e499c4
DIFF: 
https://github.com/llvm/llvm-project/commit/62323944c4a6447dab25145de7dd816a54e499c4.diff

LOG: More run lines, neon mappings, negative stride test

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index ef6b8e1d83f3811..ba9d57e1e4a16fd 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -1,26 +1,24 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 2
-; RUN: opt < %s -passes=loop-vectorize,instsimplify -force-vector-interleave=1 
-S | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --filter "call" --version 2
+; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=1 -S | 
FileCheck %s --check-prefixes=NEON
+; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S | FileCheck %s --check-prefixes=SVE_OR_NEON
+; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S -prefer-predicate-over-epilogue=predicate-dont-vectorize | FileCheck %s 
--check-prefixes=SVE_TF
 
 target triple = "aarch64-unknown-linux-gnu"
 
 ; A call whose argument can remain a scalar because it's sequential and only 
the
 ; starting value is required.
-define void @test_linear(ptr noalias %a, ptr readnone %b, i64 %n) #0 {
-; CHECK-LABEL: define void @test_linear
-; CHECK-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) 
#[[ATTR0:[0-9]+]] {
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:br label [[FOR_BODY:%.*]]
-; CHECK:   for.body:
-; CHECK-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ 
[[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[GEPB:%.*]] = getelementptr i64, ptr [[B]], i64 
[[INDVARS_IV]]
-; CHECK-NEXT:[[CALL:%.*]] = call i64 @foo(ptr [[GEPB]]) #[[ATTR1:[0-9]+]]
-; CHECK-NEXT:[[GEPA:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 
[[INDVARS_IV]]
-; CHECK-NEXT:store i64 [[CALL]], ptr [[GEPA]], align 8
-; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
-; CHECK-NEXT:[[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N]]
-; CHECK-NEXT:br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP:%.*]], label 
[[FOR_BODY]]
-; CHECK:   for.cond.cleanup:
-; CHECK-NEXT:ret void
+define void @test_linear(ptr noalias %a, ptr readnone %b, i64 %n) {
+; NEON-LABEL: define void @test_linear
+; NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) {
+; NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR0:[0-9]+]]
+;
+; SVE_OR_NEON-LABEL: define void @test_linear
+; SVE_OR_NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
+; SVE_OR_NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR1:[0-9]+]]
+;
+; SVE_TF-LABEL: define void @test_linear
+; SVE_TF-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) 
#[[ATTR0:[0-9]+]] {
+; SVE_TF:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR1:[0-9]+]]
 ;
 entry:
   br label %for.body
@@ -28,9 +26,9 @@ entry:
 for.body:
   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
   %gepb = getelementptr i64, ptr %b, i64 %indvars.iv
-  %call = call i64 @foo(ptr %gepb) #1
+  %data = call i64 @foo(ptr %gepb) #0
   %gepa = getelementptr inbounds i64, ptr %a, i64 %indvars.iv
-  store i64 %call, ptr %gepa
+  store i64 %data, ptr %gepa
   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
   %exitcond = icmp eq i64 %indvars.iv.next, %n
   br i1 %exitcond, label %for.cond.cleanup, label %for.body
@@ -39,32 +37,30 @@ for.cond.cleanup:
   ret void
 }
 
-define void @test_linear_with_mask(ptr noalias %a, ptr readnone %b, i64 %n) #0 
{
-; CHECK-LABEL: define void @test_linear_with_mask
-; CHECK-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) 
#[[ATTR0]] {
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:br label [[FOR_BODY:%.*]]
-; CHECK:   for.body:
-; CHECK-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ 
[[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[GEPB:%.*]] = getelementptr i64, ptr [[B]], i64 
[[INDVARS_IV]]
-; CHECK-NEXT:[[CALL:%.*]] = call i64 @foo(ptr [[GEPB]]) #[[ATTR2:[0-9]+]]
-; CHECK-NEXT:[[GEPA:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 
[[INDVARS_IV]]
-; CHECK-NEXT:store i64 [[CALL]], ptr [[GEPA]], align 8
-; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_

[llvm-branch-commits] [llvm] a3f46f4 - [LV] Add support for linear arguments for vector function variants

2023-12-01 Thread Graham Hunter via llvm-branch-commits

Author: Graham Hunter
Date: 2023-12-01T16:35:34Z
New Revision: a3f46f46483b2d83a5b38c197caebf7f68af8d56

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

LOG: [LV] Add support for linear arguments for vector function variants

If we have vectorized variants of a function which take linear
parameters, we should be able to vectorize assuming the strides
match.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 09a6e01226ab68c..4b6eac56597c232 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7035,6 +7035,30 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
   ParamsOk = false;
 break;
   }
+  case VFParamKind::OMP_Linear: {
+Value *ScalarParam = CI->getArgOperand(Param.ParamPos);
+// Find the stride for the scalar parameter in this loop and see if
+// it matches the stride for the variant.
+// TODO: do we need to figure out the cost of an extract to get the
+// first lane? Or do we hope that it will be folded away?
+ScalarEvolution *SE = PSE.getSE();
+const auto *SAR =
+dyn_cast(SE->getSCEV(ScalarParam));
+
+if (!SAR || SAR->getLoop() != TheLoop) {
+  ParamsOk = false;
+  break;
+}
+
+const SCEVConstant *Step =
+dyn_cast(SAR->getStepRecurrence(*SE));
+
+if (!Step ||
+Step->getAPInt().getSExtValue() != Param.LinearStepOrPos)
+  ParamsOk = false;
+
+break;
+  }
   case VFParamKind::GlobalPredicate:
 UsesMask = true;
 break;

diff  --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index ba9d57e1e4a16fd..ee7f243d5b3734c 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --filter "call" --version 2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --filter "call.*(foo|bar|baz|quux)" --version 2
 ; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=1 -S | 
FileCheck %s --check-prefixes=NEON
 ; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S | FileCheck %s --check-prefixes=SVE_OR_NEON
 ; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S -prefer-predicate-over-epilogue=predicate-dont-vectorize | FileCheck %s 
--check-prefixes=SVE_TF
@@ -10,15 +10,18 @@ target triple = "aarch64-unknown-linux-gnu"
 define void @test_linear(ptr noalias %a, ptr readnone %b, i64 %n) {
 ; NEON-LABEL: define void @test_linear
 ; NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) {
+; NEON:[[TMP3:%.*]] = call <2 x i64> @neon_foo_linear(ptr [[TMP2:%.*]])
 ; NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR0:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear
 ; SVE_OR_NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
-; SVE_OR_NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR1:[0-9]+]]
+; SVE_OR_NEON:[[TMP13:%.*]] = call  
@sve_foo_linear_nomask(ptr [[TMP12:%.*]])
+; SVE_OR_NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR2:[0-9]+]]
 ;
 ; SVE_TF-LABEL: define void @test_linear
 ; SVE_TF-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) 
#[[ATTR0:[0-9]+]] {
-; SVE_TF:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR1:[0-9]+]]
+; SVE_TF:[[TMP19:%.*]] = call  @sve_foo_linear(ptr 
[[TMP18:%.*]],  [[ACTIVE_LANE_MASK:%.*]])
+; SVE_TF:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR3:[0-9]+]]
 ;
 entry:
   br label %for.body
@@ -40,15 +43,17 @@ for.cond.cleanup:
 define void @test_linear_with_vector(ptr noalias %a, ptr readnone %b, ptr 
readonly %c, i64 %n) {
 ; NEON-LABEL: define void @test_linear_with_vector
 ; NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], ptr readonly 
[[C:%.*]], i64 [[N:%.*]]) {
+; NEON:[[TMP5:%.*]] = call <4 x i32> @neon_baz_vector_and_linear(<4 x i32> 
[[WIDE_LOAD:%.*]], ptr [[TMP4:%.*]])
 ; NEON:[[DATA:%.*]] = call i32 @baz(i32 [[INPUT:%.*]], ptr [[GEPB:%.*]]) 
#[[ATTR1:[0-

[llvm-branch-commits] [llvm] [LV] Add support for linear arguments for vector function variants (PR #73941)

2023-12-01 Thread Graham Hunter via llvm-branch-commits

https://github.com/huntergr-arm updated 
https://github.com/llvm/llvm-project/pull/73941

>From a3f46f46483b2d83a5b38c197caebf7f68af8d56 Mon Sep 17 00:00:00 2001
From: Graham Hunter 
Date: Wed, 11 Oct 2023 17:06:09 +0100
Subject: [PATCH] [LV] Add support for linear arguments for vector function
 variants

If we have vectorized variants of a function which take linear
parameters, we should be able to vectorize assuming the strides
match.
---
 .../Transforms/Vectorize/LoopVectorize.cpp| 24 ++
 .../AArch64/vector-call-linear-args.ll| 44 ---
 2 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 09a6e01226ab68c..4b6eac56597c232 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7035,6 +7035,30 @@ void 
LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
   ParamsOk = false;
 break;
   }
+  case VFParamKind::OMP_Linear: {
+Value *ScalarParam = CI->getArgOperand(Param.ParamPos);
+// Find the stride for the scalar parameter in this loop and see if
+// it matches the stride for the variant.
+// TODO: do we need to figure out the cost of an extract to get the
+// first lane? Or do we hope that it will be folded away?
+ScalarEvolution *SE = PSE.getSE();
+const auto *SAR =
+dyn_cast(SE->getSCEV(ScalarParam));
+
+if (!SAR || SAR->getLoop() != TheLoop) {
+  ParamsOk = false;
+  break;
+}
+
+const SCEVConstant *Step =
+dyn_cast(SAR->getStepRecurrence(*SE));
+
+if (!Step ||
+Step->getAPInt().getSExtValue() != Param.LinearStepOrPos)
+  ParamsOk = false;
+
+break;
+  }
   case VFParamKind::GlobalPredicate:
 UsesMask = true;
 break;
diff --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index ba9d57e1e4a16fd..ee7f243d5b3734c 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --filter "call" --version 2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --filter "call.*(foo|bar|baz|quux)" --version 2
 ; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=1 -S | 
FileCheck %s --check-prefixes=NEON
 ; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S | FileCheck %s --check-prefixes=SVE_OR_NEON
 ; RUN: opt < %s -mattr=+sve -passes=loop-vectorize -force-vector-interleave=1 
-S -prefer-predicate-over-epilogue=predicate-dont-vectorize | FileCheck %s 
--check-prefixes=SVE_TF
@@ -10,15 +10,18 @@ target triple = "aarch64-unknown-linux-gnu"
 define void @test_linear(ptr noalias %a, ptr readnone %b, i64 %n) {
 ; NEON-LABEL: define void @test_linear
 ; NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) {
+; NEON:[[TMP3:%.*]] = call <2 x i64> @neon_foo_linear(ptr [[TMP2:%.*]])
 ; NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR0:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear
 ; SVE_OR_NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
-; SVE_OR_NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR1:[0-9]+]]
+; SVE_OR_NEON:[[TMP13:%.*]] = call  
@sve_foo_linear_nomask(ptr [[TMP12:%.*]])
+; SVE_OR_NEON:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR2:[0-9]+]]
 ;
 ; SVE_TF-LABEL: define void @test_linear
 ; SVE_TF-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 [[N:%.*]]) 
#[[ATTR0:[0-9]+]] {
-; SVE_TF:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR1:[0-9]+]]
+; SVE_TF:[[TMP19:%.*]] = call  @sve_foo_linear(ptr 
[[TMP18:%.*]],  [[ACTIVE_LANE_MASK:%.*]])
+; SVE_TF:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) #[[ATTR3:[0-9]+]]
 ;
 entry:
   br label %for.body
@@ -40,15 +43,17 @@ for.cond.cleanup:
 define void @test_linear_with_vector(ptr noalias %a, ptr readnone %b, ptr 
readonly %c, i64 %n) {
 ; NEON-LABEL: define void @test_linear_with_vector
 ; NEON-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], ptr readonly 
[[C:%.*]], i64 [[N:%.*]]) {
+; NEON:[[TMP5:%.*]] = call <4 x i32> @neon_baz_vector_and_linear(<4 x i32> 
[[WIDE_LOAD:%.*]], ptr [[TMP4:%.*]])
 ; NEON:[[DATA:%.*]] = call i32 @baz(i32 [[INPUT:%.*]], ptr [[GEPB:%.*]]) 
#[[ATTR1:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear_with_vector
 ; SVE_OR_NEON-SAME: (ptr noalias [[A:%.*]], ptr readn

[llvm-branch-commits] [llvm] [LV] Add support for linear arguments for vector function variants (PR #73941)

2023-12-01 Thread Graham Hunter via llvm-branch-commits

huntergr-arm wrote:

Rebased after test changes.

https://github.com/llvm/llvm-project/pull/73941
___
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] [NFC][asan] Change asan_init and asan_init_is_running; add setters/getters (PR #74085)

2023-12-01 Thread Florian Mayer via llvm-branch-commits

fmayer wrote:

"change" in commit message is very vague. "change name of" or something? "fix 
name style"? what does "setters/getters" refer to? I don't see anything but the 
name change?

https://github.com/llvm/llvm-project/pull/74085
___
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] [NFC][asan] Change asan_init and asan_init_is_running; add setters/getters (PR #74085)

2023-12-01 Thread Zack Johnson via llvm-branch-commits

https://github.com/zacklj89 edited 
https://github.com/llvm/llvm-project/pull/74085
___
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] [NFC][asan] Change asan_init and asan_init_is_running; add setters/getters (PR #74085)

2023-12-01 Thread Zack Johnson via llvm-branch-commits

zacklj89 wrote:

Apologies @fmayer, I'm attempting to use SPR for the change in #71833. I've 
updated the description. 

https://github.com/llvm/llvm-project/pull/74085
___
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] d72d2e5 - Revert "[flang][Driver] Let the linker fail on multiple definitions of main() (#73124)"

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

Author: Tom Eccles
Date: 2023-12-01T17:56:20Z
New Revision: d72d2e5320e33b558c258eeb872d53e550d70147

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

LOG: Revert "[flang][Driver] Let the linker fail on multiple definitions of 
main() (#73124)"

This reverts commit 17feb330aab39c6c0c21ee9b02efb484dfb2261e.

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Haiku.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
flang/test/Driver/linker-flags.f90

Removed: 
flang/test/Driver/Inputs/no_duplicate_main.ll
flang/test/Driver/no_duplicate_main.f90



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 0ae8e2dce32e94a..a50ce53dd5d7d5c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1116,60 +1116,14 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
+void tools::addFortranRuntimeLibs(const ToolChain &TC,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
-// The --whole-archive option needs to be part of the link line to
-// make sure that the main() function from Fortran_main.a is pulled
-// in by the linker.  Determine if --whole-archive is active when
-// flang will try to link Fortran_main.a.  If it is, don't add the
-// --whole-archive flag to the link line.  If it's not, add a proper
-// --whole-archive/--no-whole-archive bracket to the link line.
-bool WholeArchiveActive = false;
-for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA))
-  if (Arg)
-for (StringRef ArgValue : Arg->getValues()) {
-  if (ArgValue == "--whole-archive")
-WholeArchiveActive = true;
-  if (ArgValue == "--no-whole-archive")
-WholeArchiveActive = false;
-}
-
-if (!WholeArchiveActive)
-  CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lFortran_main");
-if (!WholeArchiveActive)
-  CmdArgs.push_back("--no-whole-archive");
-
-// Perform regular linkage of the remaining runtime libraries.
 CmdArgs.push_back("-lFortranRuntime");
 CmdArgs.push_back("-lFortranDecimal");
-  } else {
-unsigned RTOptionID = options::OPT__SLASH_MT;
-if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
-  RTOptionID = llvm::StringSwitch(rtl->getValue())
-   .Case("static", options::OPT__SLASH_MT)
-   .Case("static_dbg", options::OPT__SLASH_MTd)
-   .Case("dll", options::OPT__SLASH_MD)
-   .Case("dll_dbg", options::OPT__SLASH_MDd)
-   .Default(options::OPT__SLASH_MT);
-}
-switch (RTOptionID) {
-case options::OPT__SLASH_MT:
-  CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static.lib");
-  break;
-case options::OPT__SLASH_MTd:
-  CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static_dbg.lib");
-  break;
-case options::OPT__SLASH_MD:
-  CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic.lib");
-  break;
-case options::OPT__SLASH_MDd:
-  CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic_dbg.lib");
-  break;
-}
   }
 }
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 25d68345a9f9ebf..a74dfebd6e5cad9 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,7 +117,7 @@ bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, 
const ToolChain &TC,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
 /// Adds Fortran runtime libraries to \p CmdArgs.
-void addFortranRuntimeLibs(const ToolChain &TC, const llvm::opt::ArgList &Args,
+void addFortranRuntimeLibs(const ToolChain &TC,
llvm::opt::ArgStringList &CmdArgs);
 
 /// Adds the path for the Fortran runtime libraries to \p CmdArgs.

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/T

[llvm-branch-commits] [compiler-rt] 025e4b2 - [asan][Windows] Synchronizing ASAN init on Windows

2023-12-01 Thread Zachary Johnson via llvm-branch-commits

Author: Zachary Johnson
Date: 2023-12-01T16:05:42-05:00
New Revision: 025e4b27257ebc94cb11a45e99fad3ec5b10e401

URL: 
https://github.com/llvm/llvm-project/commit/025e4b27257ebc94cb11a45e99fad3ec5b10e401
DIFF: 
https://github.com/llvm/llvm-project/commit/025e4b27257ebc94cb11a45e99fad3ec5b10e401.diff

LOG: [asan][Windows] Synchronizing ASAN init on Windows

Created using spr 1.3.4

Added: 


Modified: 
compiler-rt/lib/asan/asan_internal.h

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_internal.h 
b/compiler-rt/lib/asan/asan_internal.h
index 569f8aedc69a1d0..b19ed92be12fd71 100644
--- a/compiler-rt/lib/asan/asan_internal.h
+++ b/compiler-rt/lib/asan/asan_internal.h
@@ -130,7 +130,7 @@ void InstallAtExitCheckLeaks();
   if (&__asan_on_error) \
   __asan_on_error()
 
-// Unless synchronization is used during initialization, 
+// Unless synchronization is used during initialization,
 // race conditions can appear causing incorrect states or internal check
 // failures, depending on the loading thread and when ASAN is loaded on 
Windows.
 // From a multithreaded managed environment, if an ASAN instrumented dll



___
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] 6fe823c - drop the non-manual .symbol_resolver lowering

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

Author: Jon Roelofs
Date: 2023-12-01T13:08:03-08:00
New Revision: 6fe823c600230e92eb790dcca58a5f41e1e7900e

URL: 
https://github.com/llvm/llvm-project/commit/6fe823c600230e92eb790dcca58a5f41e1e7900e
DIFF: 
https://github.com/llvm/llvm-project/commit/6fe823c600230e92eb790dcca58a5f41e1e7900e.diff

LOG: drop the non-manual .symbol_resolver lowering

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot appear 

[llvm-branch-commits] [llvm] f11d250 - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:09:38-08:00
New Revision: f11d250777f8f4e1252712f4e05d6b95d95524ed

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

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot ap

[llvm-branch-commits] [llvm] d313d09 - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:09:46-08:00
New Revision: d313d091dc40d5566d1b61e6108276b02ee5be8f

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

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot appear in bundles
-///
-/// This works around 

[llvm-branch-commits] [llvm] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-01 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 4f8fe13530fdb7b..2ad41edf20dfa01 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 5b5b2c14b4074b7..b6e342df46eb583 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 0518a8dcc831dd4..be4453ae7eb08ce 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 aa44525bde2cae1..6c6c262c5f09d8e 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] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-01 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 4f8fe13530fdb7b..2ad41edf20dfa01 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 5b5b2c14b4074b7..b6e342df46eb583 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 0518a8dcc831dd4..be4453ae7eb08ce 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 aa44525bde2cae1..6c6c262c5f09d8e 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] ca23e96 - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:09:57-08:00
New Revision: ca23e96d355c853e3f52b8defa9626b1ea9b4cfb

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

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot ap

[llvm-branch-commits] [llvm] 9d89b03 - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:09:58-08:00
New Revision: 9d89b0327643aeedb266ef0991466dc0f16e43af

URL: 
https://github.com/llvm/llvm-project/commit/9d89b0327643aeedb266ef0991466dc0f16e43af
DIFF: 
https://github.com/llvm/llvm-project/commit/9d89b0327643aeedb266ef0991466dc0f16e43af.diff

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot appear in bundles
-///
-/// This works around 

[llvm-branch-commits] [llvm] [clang] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-01 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] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-01 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] 501007c - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:10:21-08:00
New Revision: 501007c36f8f5a92bc64aaf54038cc6fb26fa897

URL: 
https://github.com/llvm/llvm-project/commit/501007c36f8f5a92bc64aaf54038cc6fb26fa897
DIFF: 
https://github.com/llvm/llvm-project/commit/501007c36f8f5a92bc64aaf54038cc6fb26fa897.diff

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot ap

[llvm-branch-commits] [llvm] 38823b5 - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:10:22-08:00
New Revision: 38823b54f61b1b043ccd6e752b9d0fe82a60ec7b

URL: 
https://github.com/llvm/llvm-project/commit/38823b54f61b1b043ccd6e752b9d0fe82a60ec7b
DIFF: 
https://github.com/llvm/llvm-project/commit/38823b54f61b1b043ccd6e752b9d0fe82a60ec7b.diff

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ifunc-asm.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a3513ca439ac261..f19dcb5be172271 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,27 +71,6 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering {
-  SymbolResolverIfSupported,
-  SymbolResolverAlways,
-  SymbolResolverNever
-};
-
-static cl::opt PreferredIFuncLowering(
-"arm64-darwin-ifunc-symbol_resolver",
-cl::init(IFuncLowering::SymbolResolverNever),
-cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
-cl::values(
-clEnumValN(
-IFuncLowering::SymbolResolverIfSupported, "if_supported",
-"Use .symbol_resolver's when known to be supported by the 
linker."),
-clEnumValN(IFuncLowering::SymbolResolverAlways, "always",
-   "Always use .symbol_resolvers. NOTE: this might not be "
-   "supported by the linker in all cases."),
-clEnumValN(IFuncLowering::SymbolResolverNever, "never",
-   "Use a manual lowering, doing what the linker would have "
-   "done, but in the compiler.")));
-
 class AArch64AsmPrinter : public AsmPrinter {
   AArch64MCInstLower MCInstLowering;
   FaultMaps FM;
@@ -224,9 +203,6 @@ class AArch64AsmPrinter : public AsmPrinter {
   }
 
   void emitGlobalIFunc(Module &M, const GlobalIFunc &GI) override;
-
-  void emitLinkerSymbolResolver(Module &M, const GlobalIFunc &GI);
-  void emitManualSymbolResolver(Module &M, const GlobalIFunc &GI);
 };
 
 } // end anonymous namespace
@@ -1838,51 +1814,26 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
-void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
- const GlobalIFunc &GI) {
-  OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
-
-  MCSymbol *Name = getSymbol(&GI);
-
-  // NOTE: non-global .symbol_resolvers are not yet supported by Darwin linkers
-
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
-
-  OutStreamer->emitCodeAlignment(Align(4), STI);
-  OutStreamer->emitLabel(Name);
-  OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
-  emitVisibility(Name, GI.getVisibility());
+void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have
-  // to tail call the resolver manually.
-  OutStreamer->emitInstruction(
-  MCInstBuilder(AArch64::B)
-  .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver(,
-  *STI);
-}
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there 
are
+  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
+  // that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
 
-/// \brief Emit a manually-constructed .symbol_resolver that implements the
-/// symbol resolution duties of the IFunc.
-///
-/// Normally, this would be handled by linker magic, but unfortunately there 
are
-/// a few limitations in ld64 and ld-prime's implementation of .symbol_resolver
-/// that mean we can't always use them:
-///
-///*  resolvers cannot be the target of an alias
-///*  resolvers cannot have private linkage
-///*  resolvers cannot have linkonce linkage
-///*  resolvers cannot appear in executables
-///*  resolvers cannot appear in bundles
-///
-/// This works around 

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

2023-12-01 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 5f5182859080c49..001467a9f7ff511 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] [clang] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)

2023-12-01 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 5f5182859080c49..001467a9f7ff511 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] 72853bb - fix formatting

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

Author: Jon Roelofs
Date: 2023-12-01T13:32:40-08:00
New Revision: 72853bb876a884f2c9af03a858cc3b86d09b09bc

URL: 
https://github.com/llvm/llvm-project/commit/72853bb876a884f2c9af03a858cc3b86d09b09bc
DIFF: 
https://github.com/llvm/llvm-project/commit/72853bb876a884f2c9af03a858cc3b86d09b09bc.diff

LOG: fix formatting

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] 7f2f351 - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:32:44-08:00
New Revision: 7f2f3512dacd04f20cc30fdef4576d73e11da2c8

URL: 
https://github.com/llvm/llvm-project/commit/7f2f3512dacd04f20cc30fdef4576d73e11da2c8
DIFF: 
https://github.com/llvm/llvm-project/commit/7f2f3512dacd04f20cc30fdef4576d73e11da2c8.diff

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] 655e788 - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:32:52-08:00
New Revision: 655e7886620df43f27e9e970c6629d45ab81331b

URL: 
https://github.com/llvm/llvm-project/commit/655e7886620df43f27e9e970c6629d45ab81331b
DIFF: 
https://github.com/llvm/llvm-project/commit/655e7886620df43f27e9e970c6629d45ab81331b.diff

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] 4a03437 - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:32:56-08:00
New Revision: 4a034379bd636ce448c5a8f706c388da49f02062

URL: 
https://github.com/llvm/llvm-project/commit/4a034379bd636ce448c5a8f706c388da49f02062
DIFF: 
https://github.com/llvm/llvm-project/commit/4a034379bd636ce448c5a8f706c388da49f02062.diff

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] [llvm] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-01 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 4f8fe13530fdb7b..2ad41edf20dfa01 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 5b5b2c14b4074b7..b6e342df46eb583 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 0518a8dcc831dd4..be4453ae7eb08ce 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 aa44525bde2cae1..6c6c262c5f09d8e 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] 672624d - [𝘀𝗽𝗿] changes introduced through rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:33:02-08:00
New Revision: 672624d8d2daadcf402603df0fce2eb3b7cf18ec

URL: 
https://github.com/llvm/llvm-project/commit/672624d8d2daadcf402603df0fce2eb3b7cf18ec
DIFF: 
https://github.com/llvm/llvm-project/commit/672624d8d2daadcf402603df0fce2eb3b7cf18ec.diff

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] b215b63 - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:32:57-08:00
New Revision: b215b63b18fe2573f619d1f221d422df07ae2ee1

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

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] 7b66e1e - rebase

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

Author: Jon Roelofs
Date: 2023-12-01T13:33:03-08:00
New Revision: 7b66e1e0139e71da3684e1480b41a68c4b14e3e9

URL: 
https://github.com/llvm/llvm-project/commit/7b66e1e0139e71da3684e1480b41a68c4b14e3e9
DIFF: 
https://github.com/llvm/llvm-project/commit/7b66e1e0139e71da3684e1480b41a68c4b14e3e9.diff

LOG: rebase

Created using spr 1.3.4

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f19dcb5be172271..3aca166786128ee 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1821,9 +1821,9 @@ void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   // On Darwin platforms, emit a manually-constructed .symbol_resolver that
   // implements the symbol resolution duties of the IFunc.
   //
-  // Normally, this would be handled by linker magic, but unfortunately there 
are
-  // a few limitations in ld64 and ld-prime's implementation of 
.symbol_resolver
-  // that mean we can't always use them:
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
   //
   //*  resolvers cannot be the target of an alias
   //*  resolvers cannot have private linkage



___
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] [llvm] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)

2023-12-01 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 4f8fe13530fdb7b..2ad41edf20dfa01 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 5b5b2c14b4074b7..b6e342df46eb583 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 0518a8dcc831dd4..be4453ae7eb08ce 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 aa44525bde2cae1..6c6c262c5f09d8e 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] [llvm] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)

2023-12-01 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 5f5182859080c49..001467a9f7ff511 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] [clang] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-01 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] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73688)

2023-12-01 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] [llvm] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)

2023-12-01 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 5f5182859080c49..001467a9f7ff511 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] [NFC][asan] Replace asan_init and asan_init_is_running with setters/getters (PR #74085)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/74085
___
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] [NFC][asan] Replace asan_init and asan_init_is_running with setters/getters (PR #74085)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

vitalybuka wrote:

You don't need this one as well 5d6304f01742a0a7c628fe6850e921c745eaea08

https://github.com/llvm/llvm-project/pull/74085
___
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] [NFC][asan] Replace asan_init and asan_init_is_running with setters/getters (PR #74085)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/74085
___
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] Revert HWASAN failure (PR #74163)

2023-12-01 Thread Kirill Stoimenov via llvm-branch-commits

https://github.com/kstoimenov created 
https://github.com/llvm/llvm-project/pull/74163

This is the failure: 
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because there 
were a couple of patches that came after that I had to revert all 3 of them 
because of merge conflicts. 

>From 8b8496a64ef0fe1a4235e3694d898f08ab0f6e10 Mon Sep 17 00:00:00 2001
From: Kirill Stoimenov 
Date: Sat, 2 Dec 2023 01:50:19 +
Subject: [PATCH 1/3] Revert "[AArch64][MC] Fix run line in Armv9.5-A's
 FEAT_CPA test"

This reverts commit 8eb705321ed20232aa13e85e07f22b44f19e82b4.
---
 llvm/test/MC/AArch64/armv9.5a-cpa.s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/MC/AArch64/armv9.5a-cpa.s 
b/llvm/test/MC/AArch64/armv9.5a-cpa.s
index 1c338eccf6cacd6..86932feeff8e41a 100644
--- a/llvm/test/MC/AArch64/armv9.5a-cpa.s
+++ b/llvm/test/MC/AArch64/armv9.5a-cpa.s
@@ -1,5 +1,5 @@
 // RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+cpa < %s | FileCheck %s
-// RUN: not llvm-mc -triple aarch64 < %s 2>&1 | FileCheck 
--check-prefix=ERROR-NO-CPA %s
+// NORUN: not llvm-mc -triple aarch64 < %s 2>&1 | FileCheck 
--check-prefix=ERROR-NO-CPA %s
 
 addpt x0, x1, x2
 // CHECK: addpt x0, x1, x2   // encoding: [0x20,0x20,0x02,0x9a]

>From 0d1b35584ab99dc199b5cf2f20637a009b4f0da2 Mon Sep 17 00:00:00 2001
From: Kirill Stoimenov 
Date: Sat, 2 Dec 2023 01:50:38 +
Subject: [PATCH 2/3] Revert "[AArch64] Fix predicates for FEAT_CPA's
 SVE-specific instructions (#73923)"

This reverts commit 78237b70c873eb58877d91782a7f8eeb3fdf4901.
---
 .../lib/Target/AArch64/AArch64SVEInstrInfo.td |  2 +-
 llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s   | 32 +--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 25ef8e1acfa4f29..7587a07958a30c0 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -4167,7 +4167,7 @@ let Predicates = [HasSVE2orSME2, HasLUT] in {
 
//===--===//
 // Checked Pointer Arithmetic (FEAT_CPA)
 
//===--===//
-let Predicates = [HasSVE, HasCPA] in {
+let Predicates = [HasSVEorSME, HasCPA] in {
   // Add/subtract (vectors, unpredicated)
   def ADD_ZZZ_CPA : sve_int_bin_cons_arit_0<0b11, 0b010, "addpt", ZPR64>;
   def SUB_ZZZ_CPA : sve_int_bin_cons_arit_0<0b11, 0b011, "subpt", ZPR64>;
diff --git a/llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s 
b/llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
index 2d6708bd1829ae2..339f6a70ee07a2d 100644
--- a/llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
+++ b/llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
@@ -1,15 +1,15 @@
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve -mattr=+cpa < %s \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
-// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sme -mattr=+cpa < 
%s 2>&1 \
-// RUN:| FileCheck %s --check-prefixes=CHECK-ERROR-NO-SVE
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme -mattr=+cpa < %s \
+// RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 // RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-ERROR
 // RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+cpa < %s 2>&1 \
-// RUN:| FileCheck %s --check-prefix=CHECK-ERROR-NO-SVE
+// RUN:| FileCheck %s --check-prefix=CHECK-ERROR-NO-SVESME
 // RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve < %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-ERROR-NO-CPA
 // RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sme < %s 2>&1 \
-// RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+// RUN:| FileCheck %s --check-prefix=CHECK-ERROR-NO-CPA
 // RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve -mattr=+cpa < %s \
 // RUN:| llvm-objdump -d --mattr=+sve --mattr=+cpa - \
 // RUN:| FileCheck %s --check-prefix=CHECK-INST
@@ -23,47 +23,47 @@
 addpt z23.d, z13.d, z8.d
 // CHECK-INST: addpt z23.d, z13.d, z8.d
 // CHECK-ENCODING: [0xb7,0x09,0xe8,0x04]
-// CHECK-ERROR: instruction requires: cpa sve
-// CHECK-ERROR-NO-SVE: instruction requires: sve
+// CHECK-ERROR: instruction requires: cpa sve or sme
+// CHECK-ERROR-NO-SVESME: instruction requires: sve or sme
 // CHECK-ERROR-NO-CPA: instruction requires: cpa
 // CHECK-UNKNOWN: 04e809b7 
 
 addpt z23.d, p3/m, z23.d, z13.d
 // CHECK-INST: addpt z23.d, p3/m, z23.d, z13.d
 // CHECK-ENCODING: [0xb7,0x0d,0xc4,0x04]
-// CHECK-ERROR: instruction requires: cpa sve
-// CHECK-ERROR-NO-SVE: instruction requires: sve
+// CHECK-ERROR: instruction requires: cpa sve or sme
+// CHECK-ERROR-NO-SVESME: instruction requires: sve or sme
 // CHEC

[llvm-branch-commits] [llvm] [clang] Revert HWASAN failure (PR #74163)

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

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Kirill Stoimenov (kstoimenov)


Changes

This is the failure: 
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because there 
were a couple of patches that came after that I had to revert all 3 of them 
because of merge conflicts. 

---

Patch is 27.35 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74163.diff


19 Files Affected:

- (modified) clang/test/Driver/aarch64-v95a.c (-5) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+1-4) 
- (modified) llvm/lib/Target/AArch64/AArch64.td (+1-4) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (-52) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (-19) 
- (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (-21) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedA64FX.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (-18) 
- (modified) llvm/lib/Target/AArch64/SVEInstrFormats.td (-31) 
- (removed) llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s (-69) 
- (removed) llvm/test/MC/AArch64/armv9.5a-cpa.s (-50) 
- (modified) llvm/test/MC/AArch64/basic-a64-diagnostics.s (-8) 
- (modified) llvm/test/MC/AArch64/basic-a64-instructions.s (-4) 
- (removed) llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt (-42) 
- (modified) llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt (-2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+1-3) 


``diff
diff --git a/clang/test/Driver/aarch64-v95a.c b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb71..6044a4f155db02c 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a377909..17cafd146b0e75d 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,
diff --git a/llvm/lib/Target/AArch64/AArch64.td 

[llvm-branch-commits] [clang] [llvm] Revert HWASAN failure (PR #74163)

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

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: Kirill Stoimenov (kstoimenov)


Changes

This is the failure: 
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because there 
were a couple of patches that came after that I had to revert all 3 of them 
because of merge conflicts. 

---

Patch is 27.35 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74163.diff


19 Files Affected:

- (modified) clang/test/Driver/aarch64-v95a.c (-5) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+1-4) 
- (modified) llvm/lib/Target/AArch64/AArch64.td (+1-4) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (-52) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (-19) 
- (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (-21) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedA64FX.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td (+1-1) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (-18) 
- (modified) llvm/lib/Target/AArch64/SVEInstrFormats.td (-31) 
- (removed) llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s (-69) 
- (removed) llvm/test/MC/AArch64/armv9.5a-cpa.s (-50) 
- (modified) llvm/test/MC/AArch64/basic-a64-diagnostics.s (-8) 
- (modified) llvm/test/MC/AArch64/basic-a64-instructions.s (-4) 
- (removed) llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt (-42) 
- (modified) llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt (-2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+1-3) 


``diff
diff --git a/clang/test/Driver/aarch64-v95a.c b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb71..6044a4f155db02c 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a377909..17cafd146b0e75d 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,
diff --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/li

[llvm-branch-commits] [llvm] [clang] Revert HWASAN failure (PR #74163)

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

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 7ccc4ef55f9a4ebe381a980796e9c63220a48ab2 
0f9d6bfadbc6782bf30ad1e70c46f946f73fdc39 -- clang/test/Driver/aarch64-v95a.c 
llvm/include/llvm/TargetParser/AArch64TargetParser.h 
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
llvm/unittests/TargetParser/TargetParserTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index fbe1bf3c52..77963f895d 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -3663,7 +3663,7 @@ static const struct Extension {
 {"sme-lutv2", {AArch64::FeatureSME_LUTv2}},
 {"sme-f8f16", {AArch64::FeatureSMEF8F16}},
 {"sme-f8f32", {AArch64::FeatureSMEF8F32}},
-{"sme-fa64",  {AArch64::FeatureSMEFA64}},
+{"sme-fa64", {AArch64::FeatureSMEFA64}},
 };
 
 static void setRequiredFeatureString(FeatureBitset FBS, std::string &Str) {

``




https://github.com/llvm/llvm-project/pull/74163
___
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] [NFC][ASAN] Replace AsanInitIsRunning with TryAsanInitFromRtl (PR #74171)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/74171

None


___
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] [NFC][asan] Replace AsanInited/ENSURE_ASAN_INITED with TryAsanInitFromRtl (PR #74172)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/74172

None


___
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] [NFC][asan] Replace a few `#if SANITIZER_APPLE` with `if (SANITIZER_APPLE` (PR #74173)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/74173

None


___
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] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/74174

None


___
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] [NFC][ASAN] Replace AsanInitIsRunning with TryAsanInitFromRtl (PR #74171)

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

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74171.diff


4 Files Affected:

- (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+19-17) 
- (modified) compiler-rt/lib/asan/asan_internal.h (+1-1) 
- (modified) compiler-rt/lib/asan/asan_malloc_linux.cpp (+1-4) 
- (modified) compiler-rt/lib/asan/asan_rtl.cpp (+9-1) 


``diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index e80f66142b7a2fb..a364b971bda8f32 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,16 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
-ASAN_INTERCEPTOR_ENTER(ctx, func);\
-do {  \
-  if (AsanInitIsRunning())\
-return REAL(func)(__VA_ARGS__);   \
-  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
-return REAL(func)(__VA_ARGS__);   \
-  ENSURE_ASAN_INITED();   \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
+ASAN_INTERCEPTOR_ENTER(ctx, func); \
+do {   \
+  if constexpr (SANITIZER_APPLE) { \
+if (UNLIKELY(!AsanInited()))   \
+  return REAL(func)(__VA_ARGS__);  \
+  } else { \
+if (!TryAsanInitFromRtl()) \
+  return REAL(func)(__VA_ARGS__);  \
+  }\
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -534,16 +536,16 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, 
uptr size) {
 INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strcpy);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
-return REAL(strcpy)(to, from);
-#endif
-  // strcpy is called from malloc_default_purgeable_zone()
-  // in __asan::ReplaceSystemAlloc() on Mac.
-  if (AsanInitIsRunning()) {
-return REAL(strcpy)(to, from);
+  if constexpr (SANITIZER_APPLE) {
+// strcpy is called from malloc_default_purgeable_zone()
+// in __asan::ReplaceSystemAlloc() on Mac.
+if (UNLIKELY(!AsanInited()))
+  return REAL(strcpy)(to, from);
+  } else {
+if (!TryAsanInitFromRtl())
+  return REAL(strcpy)(to, from);
   }
-  ENSURE_ASAN_INITED();
+
   if (flags()->replace_str) {
 uptr from_size = internal_strlen(from) + 1;
 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
diff --git a/compiler-rt/lib/asan/asan_internal.h 
b/compiler-rt/lib/asan/asan_internal.h
index e2b1e9800f5be62..5b97e77882cd674 100644
--- a/compiler-rt/lib/asan/asan_internal.h
+++ b/compiler-rt/lib/asan/asan_internal.h
@@ -60,6 +60,7 @@ class AsanThread;
 using __sanitizer::StackTrace;
 
 void AsanInitFromRtl();
+bool TryAsanInitFromRtl();
 
 // asan_win.cpp
 void InitializePlatformExceptionHandlers();
@@ -131,7 +132,6 @@ void InstallAtExitCheckLeaks();
   __asan_on_error()
 
 bool AsanInited();
-bool AsanInitIsRunning();  // Used to avoid infinite recursion in 
__asan_init().
 extern bool replace_intrin_cached;
 extern void (*death_callback)(void);
 // These magic values are written to shadow for better error
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp 
b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index 0ba74c5d71432bd..eb29233c3cf82ff 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -31,7 +31,7 @@
 using namespace __asan;
 
 struct DlsymAlloc : public DlSymAllocator {
-  static bool UseImpl() { return AsanInitIsRunning(); }
+  static bool UseImpl() { return !TryAsanInitFromRtl(); }
   static void OnAllocate(const void *ptr, uptr size) {
 #  if CAN_SANITIZE_LEAKS
 // Suppress leaks from dlerror(). Previously dlsym hack on global array was
@@ -65,7 +65,6 @@ INTERCEPTOR(void, cfree, void *ptr) {
 INTERCEPTOR(void*, malloc, uptr size) {
   if (DlsymAlloc::Use())
 return DlsymAlloc::Allocate(size);
-  ENSURE_ASAN_INITED();
   GET_STACK_TRACE_MALLOC;
   return asan_malloc(size, &stack);
 }
@@ -73,7 +72,6 @@ INTERCEPTOR(void*, malloc, uptr size) {
 INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
   if (DlsymAlloc::Use())
 return DlsymAlloc::Callocate(nmemb, size);
-  ENSURE_ASAN_INITED();
   GET_STACK_TRACE_MALLOC;
   return asan_calloc(nmemb, size, &stack);
 }
@@ -81,7 +79,6 @@ INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
 INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
   if (DlsymAlloc::

[llvm-branch-commits] [compiler-rt] [NFC][asan] Replace AsanInited/ENSURE_ASAN_INITED with TryAsanInitFromRtl (PR #74172)

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

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74172.diff


1 Files Affected:

- (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+2-4) 


``diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index a364b971bda8f32..7f2aecae2e3a52e 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -558,9 +558,8 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);
@@ -577,9 +576,8 @@ INTERCEPTOR(char*, strdup, const char *s) {
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);

``




https://github.com/llvm/llvm-project/pull/74172
___
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] [NFC][asan] Replace a few `#if SANITIZER_APPLE` with `if (SANITIZER_APPLE` (PR #74173)

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

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74173.diff


1 Files Affected:

- (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+3-9) 


``diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index 7f2aecae2e3a52e..1a1a26a7cd8bf1d 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -635,10 +635,8 @@ INTERCEPTOR_STRTO_BASE(long long, __isoc23_strtoll)
 INTERCEPTOR(int, atoi, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atoi)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atoi)(nptr);
@@ -657,10 +655,8 @@ INTERCEPTOR(int, atoi, const char *nptr) {
 INTERCEPTOR(long, atol, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atol)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atol)(nptr);
@@ -696,10 +692,8 @@ static void AtCxaAtexit(void *unused) {
 #if ASAN_INTERCEPT___CXA_ATEXIT
 INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
 void *dso_handle) {
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(__cxa_atexit)(func, arg, dso_handle);
-#endif
   ENSURE_ASAN_INITED();
 #if CAN_SANITIZE_LEAKS
   __lsan::ScopedInterceptorDisabler disabler;

``




https://github.com/llvm/llvm-project/pull/74173
___
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] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

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

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/74174.diff


4 Files Affected:

- (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+15-12) 
- (modified) compiler-rt/lib/asan/asan_interceptors.h (-5) 
- (modified) compiler-rt/lib/asan/asan_malloc_linux.cpp (+1-1) 
- (modified) compiler-rt/lib/asan/asan_malloc_mac.cpp (+4-1) 


``diff
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index 1a1a26a7cd8bf1d..4de2fa356374a69 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -196,7 +196,10 @@ static int munmap_interceptor(Munmap real_munmap, void 
*addr, SIZE_T length) {
   __lsan::ScopedInterceptorDisabler disabler
 #endif
 
-#  define SIGNAL_INTERCEPTOR_ENTER() ENSURE_ASAN_INITED()
+#  define SIGNAL_INTERCEPTOR_ENTER() \
+do { \
+  AsanInitFromRtl(); \
+} while (false)
 
 #  include "sanitizer_common/sanitizer_common_interceptors.inc"
 #  include "sanitizer_common/sanitizer_signal_interceptors.inc"
@@ -496,7 +499,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
   INTERCEPTOR(char *, strcat, char *to, const char *from) {
 void *ctx;
 ASAN_INTERCEPTOR_ENTER(ctx, strcat);
-ENSURE_ASAN_INITED();
+AsanInitFromRtl();
 if (flags()->replace_str) {
   uptr from_length = internal_strlen(from);
   ASAN_READ_RANGE(ctx, from, from_length + 1);
@@ -517,7 +520,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
 INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strncat);
-  ENSURE_ASAN_INITED();
+  AsanInitFromRtl();
   if (flags()->replace_str) {
 uptr from_length = MaybeRealStrnlen(from, size);
 uptr copy_length = Min(size, from_length + 1);
@@ -594,7 +597,7 @@ INTERCEPTOR(char*, __strdup, const char *s) {
 INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
-  ENSURE_ASAN_INITED();
+  AsanInitFromRtl();
   if (flags()->replace_str) {
 uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
 CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
@@ -620,7 +623,7 @@ static ALWAYS_INLINE auto StrtolImpl(void *ctx, Fn real, 
const char *nptr,
 INTERCEPTOR(ret_type, func, const char *nptr, char **endptr, int base) { \
   void *ctx; \
   ASAN_INTERCEPTOR_ENTER(ctx, func); \
-  ENSURE_ASAN_INITED();  \
+  AsanInitFromRtl(); \
   return StrtolImpl(ctx, REAL(func), nptr, endptr, base);\
 }
 
@@ -637,7 +640,7 @@ INTERCEPTOR(int, atoi, const char *nptr) {
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
   if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atoi)(nptr);
-  ENSURE_ASAN_INITED();
+  AsanInitFromRtl();
   if (!flags()->replace_str) {
 return REAL(atoi)(nptr);
   }
@@ -657,7 +660,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
   if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atol)(nptr);
-  ENSURE_ASAN_INITED();
+  AsanInitFromRtl();
   if (!flags()->replace_str) {
 return REAL(atol)(nptr);
   }
@@ -671,7 +674,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
 INTERCEPTOR(long long, atoll, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoll);
-  ENSURE_ASAN_INITED();
+  AsanInitFromRtl();
   if (!flags()->replace_str) {
 return REAL(atoll)(nptr);
   }
@@ -694,8 +697,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void 
*arg,
 void *dso_handle) {
   if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(__cxa_atexit)(func, arg, dso_handle);
-  ENSURE_ASAN_INITED();
-#if CAN_SANITIZE_LEAKS
+  AsanInitFromRtl();
+#if CAN_SANITIZE_LEAKS
   __lsan::ScopedInterceptorDisabler disabler;
 #endif
   int res = REAL(__cxa_atexit)(func, arg, dso_handle);
@@ -706,8 +709,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void 
*arg,
 
 #if ASAN_INTERCEPT_ATEXIT
 INTERCEPTOR(int, atexit, void (*func)()) {
-  ENSURE_ASAN_INITED();
-#if CAN_SANITIZE_LEAKS
+  AsanInitFromRtl();
+#if CAN_SANITIZE_LEAKS
   __lsan::ScopedInterceptorDisabler disabler;
 #endif
   // Avoid calling real atexit as it is unreachable on at least on Linux.
diff --git a/compiler-rt/lib/asan/asan_interceptors.h 
b/compiler-rt/lib/asan/asan_interceptors.h
index 6a7748c8f9bb92a..826b45f5ada8c0f 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -24,11 +24,6 @@ namespace __asan {
 void InitializeAsanInterceptors();
 void InitializePlatformInterceptors(

[llvm-branch-commits] [llvm] [clang] Revert HWASAN failure (PR #74163)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

vitalybuka wrote:

Looks like buffer overflow, but not sure if this is pre-existed or new issue.
It's better to revert to recover the bot, and investigate.

https://github.com/llvm/llvm-project/pull/74163
___
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] Revert HWASAN failure (PR #74163)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/74163
___
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] Revert HWASAN failure (PR #74163)

2023-12-01 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/74163
___
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] ef876c7 - Revert HWASAN failure (#74163)

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

Author: Kirill Stoimenov
Date: 2023-12-01T19:26:46-08:00
New Revision: ef876c72f3d828055ce58d0f22ec40c7468bc6c1

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

LOG: Revert HWASAN failure (#74163)

This is the failure:
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because
there were a couple of patches that came after that I had to revert all
3 of them because of merge conflicts.

Added: 


Modified: 
clang/test/Driver/aarch64-v95a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/AArch64SchedA64FX.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/MC/AArch64/basic-a64-diagnostics.s
llvm/test/MC/AArch64/basic-a64-instructions.s
llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 
llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
llvm/test/MC/AArch64/armv9.5a-cpa.s
llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt



diff  --git a/clang/test/Driver/aarch64-v95a.c 
b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb71..6044a4f155db02c 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a377909..17cafd146b0e75d 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d1dbced2466eae3..ff256c9a8ccdf46 100644
--- a/llvm/lib/Target/AAr