[llvm-bugs] [Bug 49546] New: Missing variable at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 11 11:30:14 PST 2021


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

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

Looping variable not visible in optimized version.
Upon calling a function from an external module, the looping variable j which
is passed to it, is not visible from frame var.

$ cat a.c
void test_nop();

void test_support_3308(int i, int j);


static long long func_1()
{
int l_127[4];
int l_128[8][1][10];
long long l_131 = 18446744073709551614UL;
int i, j, k;
for (i = 0; i < 4; i++)
l_127[i] = (-1L);
for (i = 0; i < 8; i++)
{
for (j = 0; j < 1; j++)
{
test_nop();
test_support_3308(i, j);
for (k = 0; k < 10; k++)
l_128[i][j][k] = 0x60E86605L;
}
}
l_128[6][0][2]--;
return l_131;
}

int main (void)
{
func_1();
return 0;
}

$ cat lib/test.c
#include <stdio.h>
#include <stdint.h>
#include "test.h"

void test_nop() {
    printf("\n");
}

void test_support_3308(int i, int j) {
    printf("%d %d", i, j);
}
$ cat lib/test.h
#pragma once

void test_nop();
void test_support_3308(int i, int j);

$ clang -v
clang version 13.0.0
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 13.0.0

clang revision c2c977ce50597b0e5186afc342c5784bd0aa6973
lldb revision c2c977ce50597b0e5186afc342c5784bd0aa6973

$ clang -c -o lib/test.o -I lib lib/test.c
$ clang -g -Og -o opt -I lib/ lib/test.o a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to
'/home/stepping/debuginfo-analysis/bug_submission/opt' (x86_64).
(lldb) b func_1
Breakpoint 1: where = opt`main + 16 [inlined] func_1 at a.c:30, address =
0x0000000000400530
(lldb) r
Process 61 launched: '/home/stepping/debuginfo-analysis/bug_submission/opt'
(x86_64)
Process 61 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400530 opt`main [inlined] func_1 at a.c:18:4
   15   {
   16   for (j = 0; j < 1; j++)
   17   {
-> 18   test_nop();
   19   test_support_3308(i, j);
   20   for (k = 0; k < 10; k++)
   21   l_128[i][j][k] = 0x60E86605L;
(lldb) n

Process 61 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400537 opt`main [inlined] func_1 at a.c:19:4
   16   for (j = 0; j < 1; j++)
   17   {
   18   test_nop();
-> 19   test_support_3308(i, j);
   20   for (k = 0; k < 10; k++)
   21   l_128[i][j][k] = 0x60E86605L;
   22   }
(lldb) frame var
(int [8][1][10]) l_128 = {
  [0] = {
    [0] = ([0] = 0, [1] = 0, [2] = 1700966438, [3] = 0, [4] = -134223208, [5] =
32767, [6] = -6632, [7] = 32767, [8] = -6576, [9] = 32767)
  }
  [1] = {
    [0] = ([0] = -134224112, [1] = 32767, [2] = 0, [3] = 0, [4] = -136453217,
[5] = 32767, [6] = 0, [7] = 0, [8] = -6576, [9] = 32767)
  }
  [2] = {
    [0] = ([0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] =
-134224112, [7] = 32767, [8] = -138848505, [9] = 32767)
  }
  [3] = {
    [0] = ([0] = 2496, [1] = 0, [2] = -6800, [3] = 32767, [4] = -6784, [5] =
32767, [6] = -134223208, [7] = 32767, [8] = 0, [9] = 0)
  }
  [4] = {
    [0] = ([0] = 0, [1] = 64, [2] = 512, [3] = 1024, [4] = -1, [5] = 0, [6] =
0, [7] = 0, [8] = -134241688, [9] = 32767)
  }
  [5] = {
    [0] = ([0] = -134224112, [1] = 32767, [2] = 0, [3] = 0, [4] = 0, [5] = 0,
[6] = 0, [7] = 0, [8] = 0, [9] = 0)
  }
  [6] = {
    [0] = ([0] = 9, [1] = 0, [2] = -136489376, [3] = 32767, [4] = -6616, [5] =
32767, [6] = 15775231, [7] = 0, [8] = 1, [9] = 0)
  }
  [7] = {
    [0] = ([0] = 4195789, [1] = 0, [2] = -136430784, [3] = 32767, [4] = 0, [5]
= 0, [6] = 4195712, [7] = 0, [8] = 4195296, [9] = 0)
  }
}
(int) i = 0
(long long) l_131 = -2
(int) k = <variable not available>

(lldb) frame var j
error: no variable named 'j' found in this frame

-- 
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/20210311/7e0ee219/attachment.html>


More information about the llvm-bugs mailing list