[PATCH] D49458: Support implicit _Atomic struct load / store
JF Bastien via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 17 16:45:27 PDT 2018
jfb created this revision.
jfb added a reviewer: dexonsmith.
Herald added a subscriber: cfe-commits.
Using _Atomic to do implicit load / store is just a seq_cst atomic_load / atomic_store. Stores currently assert in Sema::ImpCastExprToType with 'can't implicitly cast lvalue to rvalue with this cast kind', but that's erroneous. The codegen is fine as the test shows.
While investigating I found that Richard had found the problem here: https://reviews.llvm.org/D46112#1113557
rdar://problem/40347123
Repository:
rC Clang
https://reviews.llvm.org/D49458
Files:
lib/Sema/Sema.cpp
test/CodeGen/atomic-ops.c
Index: test/CodeGen/atomic-ops.c
===================================================================
--- test/CodeGen/atomic-ops.c
+++ test/CodeGen/atomic-ops.c
@@ -183,6 +183,18 @@
double x;
};
+void implicit_store(_Atomic(struct S) *a, struct S s) {
+ // CHECK-LABEL: @implicit_store(
+ // CHECK: store atomic i64 %{{.*}}, i64* %{{.*}} seq_cst, align 8
+ *a = s;
+}
+
+struct S implicit_load(_Atomic(struct S) *a) {
+ // CHECK-LABEL: @implicit_load(
+ // CHECK: load atomic i64, i64* %{{.*}} seq_cst, align 8
+ return *a;
+}
+
struct S fd1(struct S *a) {
// CHECK-LABEL: @fd1
// CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4
Index: lib/Sema/Sema.cpp
===================================================================
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -481,6 +481,7 @@
case CK_ArrayToPointerDecay:
case CK_FunctionToPointerDecay:
case CK_ToVoid:
+ case CK_NonAtomicToAtomic:
break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49458.155988.patch
Type: text/x-patch
Size: 957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180717/7f938b68/attachment-0001.bin>
More information about the cfe-commits
mailing list