[PATCH] D123787: [clang][OpenMP][DebugInfo] Debug support for TLS variables when present in OpenMP consructs

Alok Kumar Sharma via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 05:45:29 PDT 2022


alok created this revision.
alok added reviewers: jmorse, aprantl, djtodoro, jini.susan.
alok added a project: debug-info.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
alok requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

In case of OpenMP programs, thread local variables can be present in any clause pertaining to
OpenMP constructs, as we know that compiler generates artificial functions and in some cases
values are passed to those artificial functions thru parameters.
 For an example, if thread local variable is present in copyin clause (testcase attached with the
patch), parameter with same name is generated as parameter to artificial function. When user
inquires the thread Local variable, its debug info is hidden by the parameter. The debug info
for parameters (for thread local) must be suppressed.

Without the patch, attached testcase behaves wrongly under debuggers.

  Thread 3 "a.out" hit Breakpoint 3, .omp_outlined._debug__ (.global_tid.=0x155547ffde20, .bound_tid.=0x155547ffde18, nt=@0x7fffffffe2b8: 4, gbl_int=@0x15555553333c: 65)
      at simple.c:29
  29                  printf ("In parallel region total threads = %d, thread id = %d data=%d gbl_addr = %p\n", nt, tid, data, &gbl_int);
  (gdb) p tid
  $1 = 2
  (gdb) p &gbl_int
  $2 = (int *) 0x15555553333c
  (gdb) c
  Continuing.
  [Switching to Thread 0x155553ad2b80 (LWP 12279)]
  
  Thread 2 "a.out" hit Breakpoint 2, .omp_outlined._debug__ (.global_tid.=0x155553ad1de0, .bound_tid.=0x155553ad1dd8, nt=@0x7fffffffe2b8: 4, gbl_int=@0x15555553333c: 65)
      at simple.c:27
  27                  printf ("In parallel region total threads = %d, thread id = %d data=%d gbl_addr = %p\n", nt, tid, data, &gbl_int);
  (gdb) p tid
  $3 = 1
  (gdb) p &gbl_int
  $4 = (int *) 0x15555553333c

Please note that same address is shown for all the threads which is wrong (for thread local variable).

With the current patch, the issue is fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123787

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123787.422829.patch
Type: text/x-patch
Size: 5217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220414/da9d5e94/attachment.bin>


More information about the cfe-commits mailing list