[OPENMP] Improved code for generating debug info + generation of all OpenMP regions in termination scope
Patch adds proper generation of debug info for all OpenMP regions. Also, all OpenMP regions are generated in a termination scope, because standard does not allow to throw exceptions out of structured blocks, associated with the OpenMP regions
Differential Revision: http://reviews.llvm.org/D7935
llvm-svn: 231757
diff --git a/clang/test/OpenMP/atomic_codegen.cpp b/clang/test/OpenMP/atomic_codegen.cpp
new file mode 100644
index 0000000..1ceb863
--- /dev/null
+++ b/clang/test/OpenMP/atomic_codegen.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp=libiomp5 -fexceptions -fcxx-exceptions -gline-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
+// expected-no-diagnostics
+
+int a;
+int &foo() { return a; }
+
+// TERM_DEBUG-LABEL: parallel_atomic
+void parallel_atomic() {
+#pragma omp parallel
+ {
+#pragma omp atomic read
+ // TERM_DEBUG-NOT: __kmpc_global_thread_num
+ // TERM_DEBUG: invoke {{.*}}foo{{.*}}()
+ // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],
+ // TERM_DEBUG: load atomic i32, i32* @{{.+}} monotonic, {{.*}}!dbg [[READ_LOC:![0-9]+]]
+ foo() = a;
+#pragma omp atomic write
+ // TERM_DEBUG-NOT: __kmpc_global_thread_num
+ // TERM_DEBUG: invoke {{.*}}foo{{.*}}()
+ // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],
+ // TERM_DEBUG-NOT: __kmpc_global_thread_num
+ // TERM_DEBUG: store atomic i32 {{%.+}}, i32* @{{.+}} monotonic, {{.*}}!dbg [[WRITE_LOC:![0-9]+]]
+ // TERM_DEBUG: [[TERM_LPAD]]:
+ // TERM_DEBUG: call void @__clang_call_terminate
+ // TERM_DEBUG: unreachable
+ a = foo();
+ }
+}
+// TERM_DEBUG-DAG: [[READ_LOC]] = !MDLocation(line: 11,
+// TERM_DEBUG-DAG: [[WRITE_LOC]] = !MDLocation(line: 17,