[llvm-bugs] [Bug 47273] New: Variable not visible at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 21 11:28:10 PDT 2020


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

            Bug ID: 47273
           Summary: Variable not visible 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

Variable l_5 should be visible in all the scope of func_1. However, when
executing line 9 it is not visible anymore.

$ cat -n a.c
     1  int a;
     2  char b;
     3  char *c[2];
     4  void func_1() {
     5    int l_5 = 3, d = 0;
     6    for (; d < 2; d++)
     7      c[d] = b;
     8    for (;;) {
     9      if (l_5)
    10        break;
    11      a = &l_5;
    12      __assert_fail();
    13    }
    14  }
    15  int main() { func_1(); }

$ cat a.c
int a;
char b;
char *c[2];
void func_1() {
  int l_5 = 3, d = 0;
  for (; d < 2; d++)
    c[d] = b;
  for (;;) {
    if (l_5)
      break;
    a = &l_5;
    __assert_fail();
  }
}
int main() { func_1(); }

$ 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 opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b func_1
Breakpoint 1: where = opt`func_1 + 5 at a.c:5:7, address = 0x00000000004004e5
(lldb) r
Process 215 launched: 'opt' (x86_64)
Process 215 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004e5 opt`func_1 at a.c:5:7
   2    char b;
   3    char *c[2];
   4    void func_1() {
-> 5      int l_5 = 3, d = 0;
   6      for (; d < 2; d++)
   7        c[d] = b;
   8      for (;;) {
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400500 opt`func_1 at a.c:7:10
   4    void func_1() {
   5      int l_5 = 3, d = 0;
   6      for (; d < 2; d++)
-> 7        c[d] = b;
   8      for (;;) {
   9        if (l_5)
   10         break;
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400507 opt`func_1 at a.c:6:12
   3    char *c[2];
   4    void func_1() {
   5      int l_5 = 3, d = 0;
-> 6      for (; d < 2; d++)
   7        c[d] = b;
   8      for (;;) {
   9        if (l_5)
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400500 opt`func_1 at a.c:7:10
   4    void func_1() {
   5      int l_5 = 3, d = 0;
   6      for (; d < 2; d++)
-> 7        c[d] = b;
   8      for (;;) {
   9        if (l_5)
   10         break;
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400507 opt`func_1 at a.c:6:12
   3    char *c[2];
   4    void func_1() {
   5      int l_5 = 3, d = 0;
-> 6      for (; d < 2; d++)
   7        c[d] = b;
   8      for (;;) {
   9        if (l_5)
(lldb) p l_5
(int) $0 = 3
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040050d opt`func_1 at a.c:9:9
   6      for (; d < 2; d++)
   7        c[d] = b;
   8      for (;;) {
-> 9        if (l_5)
   10         break;
   11       a = &l_5;
   12       __assert_fail();
(lldb) p l_5
error: Couldn't materialize: couldn't get the value of variable l_5: variable
not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

-- 
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/20200821/8ee195db/attachment.html>


More information about the llvm-bugs mailing list