================
@@ -0,0 +1,162 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ 
-std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - 
-gno-column-info \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - -gno-column-info \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// Check that atomic handling code gets Key Instruction annotations.
+
+_Atomic(unsigned int) x;
+unsigned int y;
+void fun() {
+  unsigned int r1 = __c11_atomic_fetch_add(&x,- 1, __ATOMIC_RELAXED);
+// CHECK:      store i32 -1, ptr %.atomictmp, align 4,                !dbg 
[[LINE11_G2R1:!.*]]
+// CHECK-NEXT: %0 = load i32, ptr %.atomictmp, align 4,               !dbg 
[[LINE11:!.*]]
+// CHECK-NEXT: %1 = atomicrmw add ptr @x, i32 %0 monotonic, align 4,  !dbg 
[[LINE11_G2R2:!.*]]
+// CHECK-NEXT: store i32 %1, ptr %atomic-temp, align 4,               !dbg 
[[LINE11_G2R1]]
----------------
OCHyams wrote:

Yeah it's deliberate. Possibly could be argued that the first store is "setup" 
and doesn't need to be key at all. I don't have a strong opinion either way, 
both should produce identical output if the instructions remain grouped like 
this (as you point out, due to the Buoys). The difference is if they split up 
_over multiple blocks_; the current impl has you stepping on the line twice, 
whereas alternative impls may have you step on this one.

Do you have a strong opinion?

https://github.com/llvm/llvm-project/pull/141624
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to