Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Aug 2020 19:11:24 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r363977 - in projects/clang1100-import/contrib/llvm-project: clang/lib/AST compiler-rt/lib/builtins
Message-ID:  <202008061911.076JBOwN053715@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Thu Aug  6 19:11:24 2020
New Revision: 363977
URL: https://svnweb.freebsd.org/changeset/base/363977

Log:
  r356104 | jhibbits | 2019-12-27 00:06:28 +0100 (Fri, 27 Dec 2019) | 25 lines
  
  [PowerPC] enable atomic.c in compiler_rt and do not check and forces
  lock/lock_free decisions in compiled time
  
  Summary:
  Enables atomic.c in compiler_rt and forces clang to not emit a call for runtime
  decision about lock/lock_free.  At compiling time, if clang can't decide if
  atomic operation can be lock free, it emits calls to external functions  like
  `__atomic_is_lock_free`, `__c11_atomic_is_lock_free` and
  `__atomic_always_lock_free`, postponing decision to a runtime check.  According
  to LLVM code documentation, the mechanism exists due to differences between
  x86_64 processors that can't be decided at runtime.
  
  On PowerPC and PowerPCSPE (32 bits), we already know in advance it can't be lock
  free, so we force the decision at compile time and avoid having to implement it
  in an external library.
  
  This patch was made after 32 bit users testing the PowePC32 bit ISO reported
  llvm could not be compiled with in-base llvm due to `__atomic_load8` not
  implemented.
  
  Submitted by:	alfredo.junior_eldorado.org.br
  Reviewed by:	jhibbits, dim
  
  Differential Revision:	https://reviews.freebsd.org/D22549

Modified:
  projects/clang1100-import/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
  projects/clang1100-import/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c

Modified: projects/clang1100-import/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
==============================================================================
--- projects/clang1100-import/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp	Thu Aug  6 19:08:28 2020	(r363976)
+++ projects/clang1100-import/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp	Thu Aug  6 19:11:24 2020	(r363977)
@@ -11529,6 +11529,13 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const Call
       }
     }
 
+    // Avoid emiting call for runtime decision on PowerPC 32-bit
+    // The lock free possibilities on this platform are covered by the lines 
+    // above and we know in advance other cases require lock
+    if (Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) {
+        return Success(0, E);
+    }
+
     return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
         Success(0, E) : Error(E);
   }

Modified: projects/clang1100-import/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c
==============================================================================
--- projects/clang1100-import/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c	Thu Aug  6 19:08:28 2020	(r363976)
+++ projects/clang1100-import/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c	Thu Aug  6 19:11:24 2020	(r363977)
@@ -120,13 +120,20 @@ static __inline Lock *lock_for_pointer(void *ptr) {
   return locks + (hash & SPINLOCK_MASK);
 }
 
-/// Macros for determining whether a size is lock free.  Clang can not yet
-/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are
-/// not lock free.
+/// Macros for determining whether a size is lock free.
 #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1)
 #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2)
 #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4)
+
+/// 32 bit PowerPC doesn't support 8-byte lock_free atomics
+#if !defined(__powerpc64__) && defined(__powerpc__)
+#define IS_LOCK_FREE_8 0
+#else
 #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8)
+#endif
+
+/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume
+/// 16-byte values are not lock free.
 #define IS_LOCK_FREE_16 0
 
 /// Macro that calls the compiler-generated lock-free versions of functions



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008061911.076JBOwN053715>