[llvm-bugs] [Bug 49580] New: Lifetime of a variable too short at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 13 12:03:08 PST 2021


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

            Bug ID: 49580
           Summary: Lifetime of a variable too short 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

Upon calling a function from an external module, the variables previously 
used by for loops which are passed to it, are not visible from frame var.

$ cat a.c
void test_nop();

void test_support_3002(int i, int j, int k);


static int func_1(void)
{
int l_6[4][1][1];
int i, j, k;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 1; j++)
{
for (k = 0; k < 1; k++)
l_6[i][j][k] = 0xE6BACD79;
}
}
test_nop();
test_support_3002(i, j, k);
return l_6[0][0][0];
}

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_3002(int i, int j, int k) {
    printf("%d %d %d", i, j, k);

}
$ cat lib/test.h
#pragma once

void test_nop();
void test_support_3002(int i, int j, int k);

$ 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.co
$ 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 + 1 [inlined] func_1 at a.c:25, address =
0x0000000000400531
(lldb) r
Process 57 launched: '/home/stepping/debuginfo-analysis/bug_submission/opt'
(x86_64)
Process 57 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400531 opt`main [inlined] func_1 at a.c:18:1
   15   l_6[i][j][k] = 0xE6BACD79;
   16   }
   17   }
-> 18   test_nop();
   19   test_support_3002(i, j, k);
   20   return l_6[0][0][0];
   21   }
(lldb) n

Process 57 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400538 opt`main [inlined] func_1 at a.c:19:1
   16   }
   17   }
   18   test_nop();
-> 19   test_support_3002(i, j, k);
   20   return l_6[0][0][0];
   21   }
   22
(lldb) frame var
(lldb) frame var i
error: no variable named 'i' found in this frame
(lldb) frame var j
error: no variable named 'j' found in this frame
(lldb) frame var k
error: no variable named 'k' 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/20210313/d10ef567/attachment.html>


More information about the llvm-bugs mailing list