forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][OpenMP][DebugInfo] Debug support for variables in shared clau…
…se of OpenMP task construct Currently variables appearing inside shared clause of OpenMP task construct are not visible inside lldb debugger. After the current patch, lldb is able to show the variable ``` * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x0000000000400934 a.out`.omp_task_entry. [inlined] .omp_outlined.(.global_tid.=0, .part_id.=0x000000000071f0d0, .privates.=0x000000000071f0e8, .copy_fn.=(a.out`.omp_task_privates_map. at testshared.cxx:8), .task_t.=0x000000000071f0c0, __context=0x000000000071f0f0) at testshared.cxx:10:34 7 else { 8 #pragma omp task shared(svar) firstprivate(n) 9 { -> 10 printf("Task svar = %d\n", svar); 11 printf("Task n = %d\n", n); 12 svar = fib(n - 1); 13 } (lldb) p svar (int) $0 = 9 ``` Reviewed By: djtodoro Differential Revision: https://reviews.llvm.org/D115510
- Loading branch information
1 parent
a9bb97e
commit 5eb2718
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// This testcase checks emission of debug info for variables | ||
// inside shared clause of task construct. | ||
|
||
// REQUIRES: x86_64-linux | ||
|
||
// RUN: %clang_cc1 -debug-info-kind=constructor -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK | ||
// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG | ||
// expected-no-diagnostics | ||
|
||
// CHECK-LABEL: define internal i32 @.omp_task_entry. | ||
|
||
// CHECK-DAG: [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8 | ||
// CHECK-DAG: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE2:![0-9]+]], metadata !DIExpression(DW_OP_deref)) | ||
// CHECK-DAG: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE3:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref)) | ||
// CHECK-DAG: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE1:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_deref)) | ||
|
||
// CHECK-DAG: [[SHARE2]] = !DILocalVariable(name: "share2" | ||
// CHECK-DAG: [[SHARE3]] = !DILocalVariable(name: "share3" | ||
// CHECK-DAG: [[SHARE1]] = !DILocalVariable(name: "share1" | ||
|
||
// NEG-LABEL: define internal i32 @.omp_task_entry. | ||
// NEG: [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8 | ||
// NEG-NOT: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata {{![0-9]+}}, metadata !DIExpression(DW_OP_deref)) | ||
|
||
extern int printf(const char *, ...); | ||
|
||
int foo(int n) { | ||
int share1 = 9, share2 = 11, share3 = 13, priv1, priv2, fpriv; | ||
fpriv = n + 4; | ||
|
||
if (n < 2) | ||
return n; | ||
else { | ||
#if SHARED | ||
#pragma omp task shared(share1, share2) private(priv1, priv2) firstprivate(fpriv) shared(share3) | ||
#else | ||
#pragma omp task private(priv1, priv2) firstprivate(fpriv) | ||
#endif | ||
{ | ||
priv1 = n; | ||
priv2 = n + 2; | ||
share2 += share3; | ||
printf("share1 = %d, share2 = %d, share3 = %d\n", share1, share2, share3); | ||
share1 = priv1 + priv2 + fpriv + foo(n - 1) + share2 + share3; | ||
} | ||
#pragma omp taskwait | ||
return share1 + share2 + share3; | ||
} | ||
} | ||
|
||
int main() { | ||
int n = 10; | ||
printf("foo(%d) = %d\n", n, foo(n)); | ||
return 0; | ||
} |