[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time
Alfredo Dal'Ava JĂșnior via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 05:30:08 PST 2020
adalava updated this revision to Diff 243520.
adalava added a comment.
fix typo found by @dim
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71600/new/
https://reviews.llvm.org/D71600
Files:
clang/lib/AST/ExprConstant.cpp
compiler-rt/lib/builtins/atomic.c
Index: compiler-rt/lib/builtins/atomic.c
===================================================================
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -119,13 +119,20 @@
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
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11206,6 +11206,15 @@
}
}
+ // Avoid emitting 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.
+ // This may need to be restricted to specific operating systems in the future,
+ // as some (perhaps AIX) might provide libatomic and prefer to use it instead
+ 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71600.243520.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200210/7e698e01/attachment.bin>
More information about the cfe-commits
mailing list