<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Missing variable at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=49546">49546</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing variable at Og
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cristianassaiante@outlook.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>