[llvm-bugs] [Bug 47093] New: Missing Variables information at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 10 07:52:23 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47093

            Bug ID: 47093
           Summary: Missing Variables information at Og
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

At line 9 lldb says that variables l_1876 and l_2441 are optimized out, but
they are actually used.

$ cat -n a.c
     1  short a;
     2  int b, d = 4;
     3  int *c = &b;
     4  void func_3() {
     5    int **l_1876 = &c;
     6    int e = 1;
     7    if (d) {
     8      int *l_2441 = a;
     9      (**l_1876) = l_2441;
    10    }
    11    *l_1876 = &e;
    12  }
    13  int main() { func_3(); }

$ cat a.c
short a;
int b, d = 4;
int *c = &b;
void func_3() {
  int **l_1876 = &c;
  int e = 1;
  if (d) {
    int *l_2441 = a;
    (**l_1876) = l_2441;
  }
  *l_1876 = &e;
}
int main() { func_3(); }


$ clang -v
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
bc8be3054067ac822fc6d9f4f8e64c841f530f16)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 12.0.0
  clang revision bc8be3054067ac822fc6d9f4f8e64c841f530f16
  llvm revision bc8be3054067ac822fc6d9f4f8e64c841f530f16


$ clang -g -Og -o opt a.c

$ lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b func_3
Breakpoint 1: where = opt`func_3 at a.c:6:7, address = 0x0000000000400480
(lldb) r
Process 66 launched: '/home/stepping/output/opt' (x86_64)
Process 66 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400480 opt`func_3 at a.c:6:7
   3    int *c = &b;
   4    void func_3() {
   5      int **l_1876 = &c;
-> 6      int e = 1;
   7      if (d) {
   8        int *l_2441 = a;
   9        (**l_1876) = l_2441;
(lldb) s
Process 66 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400488 opt`func_3 at a.c:7:7
   4    void func_3() {
   5      int **l_1876 = &c;
   6      int e = 1;
-> 7      if (d) {
   8        int *l_2441 = a;
   9        (**l_1876) = l_2441;
   10     }
(lldb) s
Process 66 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400491 opt`func_3 at a.c:8:19
   5      int **l_1876 = &c;
   6      int e = 1;
   7      if (d) {
-> 8        int *l_2441 = a;
   9        (**l_1876) = l_2441;
   10     }
   11     *l_1876 = &e;
(lldb) s
Process 66 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400498 opt`func_3 at a.c:9:7
   6      int e = 1;
   7      if (d) {
   8        int *l_2441 = a;
-> 9        (**l_1876) = l_2441;
   10     }
   11     *l_1876 = &e;
   12   }
(lldb) p l_2441
error: Couldn't materialize: couldn't get the value of variable l_2441: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p l_1876
error: Couldn't materialize: couldn't get the value of variable l_1876: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) di
opt`func_3:
    0x400480 <+0>:  movl   $0x1, -0x4(%rsp)
    0x400488 <+8>:  cmpl   $0x0, 0x200b99(%rip)      ; __dso_handle + 7
    0x40048f <+15>: je     0x4004a1                  ; <+33> at a.c
    0x400491 <+17>: movswl 0x200ba8(%rip), %eax      ; a
->  0x400498 <+24>: movq   0x200b91(%rip), %rcx      ; c
    0x40049f <+31>: movl   %eax, (%rcx)
    0x4004a1 <+33>: leaq   -0x4(%rsp), %rax
    0x4004a6 <+38>: movq   %rax, 0x200b83(%rip)      ; c
    0x4004ad <+45>: retq   
(lldb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200810/ad950215/attachment.html>


More information about the llvm-bugs mailing list