Page MenuHomePhabricator

[clang][DebugInfo] Debug support for private variables inside an OpenMP task construct
ClosedPublic

Authored by alok on Nov 23 2021, 10:59 PM.

Details

Summary

Currently variables appearing inside private/firstprivate/lastprivateclause of openmp task construct are not visible inside lldb debugger.
This is because compiler does not generate debug info for it.

Please consider the testcase debug_private.c attached with patch.

   31         priv2 = n + 2;
   32         printf("Task n=%d,priv1=%d,priv2=%d,fpriv=%d\n",n,priv1,priv2,fpriv);
   33
-> 34         res = priv1 + priv2 + fpriv + foo(n - 1);
   35       }
   36   #pragma omp taskwait
   37       return res;
(lldb) p priv1
error: <user expression 0>:1:1: use of undeclared identifier 'priv1'
priv1
^
(lldb) p priv2
error: <user expression 1>:1:1: use of undeclared identifier 'priv2'
priv2
^
(lldb) p fpriv
error: <user expression 2>:1:1: use of undeclared identifier 'fpriv'
fpriv
^

After the current patch, lldb is able to show the variables

(lldb) p priv1
(int) $0 = 10
(lldb) p priv2
(int) $1 = 12
(lldb) p fpriv
(int) $2 = 14

Diff Detail

Event Timeline

alok created this revision.Nov 23 2021, 10:59 PM
alok requested review of this revision.Nov 23 2021, 10:59 PM
Herald added a project: Restricted Project. · View Herald Transcript

Thanks for doing this! Can you please update the summary, since it hard to read with the format like this (at least, just try to reformat the debugger output properly with the Phabricator formatters)?

alok edited the summary of this revision. (Show Details)Nov 24 2021, 7:01 AM

Thanks for doing this! Can you please update the summary, since it hard to read with the format like this (at least, just try to reformat the debugger output properly with the Phabricator formatters)?

Sorry for the bad formatting. I have corrected it now.

This looks reasonable to me (some nits included).

clang/lib/CodeGen/CGStmtOpenMP.cpp
4513

I think we can get rid of curly brackets.

4515
alok added inline comments.Nov 25 2021, 2:22 AM
clang/lib/CodeGen/CGStmtOpenMP.cpp
4513

Sure, I am doing it.

4515

Thanks. I am updating it.

alok updated this revision to Diff 389699.Nov 25 2021, 2:23 AM

Re-based and incorporated comments from @djtodoro

alok added a comment.Nov 25 2021, 2:24 AM

Thanks @djtodoro . I have incorporated all your comments.

This revision is now accepted and ready to land.Nov 25 2021, 4:22 AM
This revision was landed with ongoing or failed builds.Nov 25 2021, 6:26 AM
This revision was automatically updated to reflect the committed changes.