This is an archive of the discontinued LLVM Phabricator instance.

[clang][OpenMP][DebugInfo] Debug support for variables in shared clause of OpenMP task construct
ClosedPublic

Authored by alok on Dec 10 2021, 4:28 AM.

Details

Summary

Currently variables appearing inside shared clause of OpenMP task construct are not visible inside lldb debugger.
This is because compiler does not generate debug info for it.

* 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
error: <user expression 0>:1:1: use of undeclared identifier 'svar'
svar
^
(lldb)

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
(lldb)

Diff Detail

Event Timeline

alok created this revision.Dec 10 2021, 4:28 AM
alok requested review of this revision.Dec 10 2021, 4:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 4:29 AM
djtodoro accepted this revision.Dec 21 2021, 1:51 AM
djtodoro added inline comments.
clang/lib/CodeGen/CGStmtOpenMP.cpp
4444–4446

nit: We could improve this comment.

This revision is now accepted and ready to land.Dec 21 2021, 1:51 AM
alok marked an inline comment as done.Dec 22 2021, 6:38 AM

Thanks @djtodoro .