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.