[llvm-bugs] [Bug 49769] New: Missing variables after inlining pass at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 30 02:31:19 PDT 2021


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

            Bug ID: 49769
           Summary: Missing variables after inlining pass 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, some of the variables passed
to it are not visible from frame var. 
Using -opt-bisect-limit we discovered that the pass causing the symbols
disappear is "InlinerPass on SCC". In fact if we stop the optimization process
before that, the missing variables are visible as "optimized out". 
We also did a double check performing inlining of function "c" by-hand and
again variables are visible as "optimized out", confirming the problem upon
inlining.

$ cat a.c
void test_nop();

void test_support_3382(int l_83, int l_84, int l_116, int l_118, int l_45, int
l_95, int l_96, int l_97);

int a,  b  ;
void  c()
{
for (; a < 4; a++)
{
long l_83 = 0;
int l_84 = 0,  l_116 = 0,  l_118 = 1;
for (; b <= 5; b ++)
{
char l_45 = 2;
int l_95 = 0,  l_97 = 2;
long l_96 = 1;
test_nop();
test_support_3382(l_83, l_84, l_116, l_118, l_45, l_95, l_96, l_97);
}
}
}
int main ()
{
c();
}

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

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

void test_support_3382(int l_83, int l_84, int l_116, int l_118, int l_45, int
l_95, int l_96, int l_97) {
    printf("%d %d %d %d %d %d %d %d", l_83, l_84, l_116, l_118, l_45, l_95,
l_96, l_97);

}

$ cat lib/test.h
#pragma once

void test_nop();
void test_support_3382(int l_83, int l_84, int l_116, int l_118, int l_45, int
l_95, int l_96, int l_97);

$ 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 -g -Og -o opt lib/test.c a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to
'/home/stepping/debuginfo-analysis/bug_submission/opt' (x86_64).
(lldb) b 17
Breakpoint 1: 2 locations.
(lldb) r
Process 47 launched:
'/home/stepping/debuginfo-analysis/stuff/issue3/bug_submission/opt' (x86_64)
Process 47 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.2
    frame #0: 0x0000000000400610 opt`main at a.c:17:1
   14   char l_45 = 2;
   15   int l_95 = 0,  l_97 = 2;
   16   long l_96 = 1;
-> 17   test_nop();
   18   test_support_3382(l_83, l_84, l_116, l_118, l_45, l_95, l_96, l_97);
   19   }
   20   }
(lldb) n

Process 47 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400617 opt`main at a.c:18:1
   15   int l_95 = 0,  l_97 = 2;
   16   long l_96 = 1;
   17   test_nop();
-> 18   test_support_3382(l_83, l_84, l_116, l_118, l_45, l_95, l_96, l_97);
   19   }
   20   }
   21   }
(lldb) frame var
(char) l_45 = '\x02'
(int) l_95 = 0
(int) l_97 = 2
(long) l_96 = 1
(lldb) frame var l_83
error: no variable named 'l_83' found in this frame
(lldb) frame var l_84
error: no variable named 'l_84' found in this frame
(lldb) frame var l_116
error: no variable named 'l_116' found in this frame
(lldb) frame var l_118

-- 
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/20210330/a0c08e27/attachment.html>


More information about the llvm-bugs mailing list