Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Variable not visible at Og #50526

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR51559
Status CONFIRMED
Importance P enhancement
Reported by Fiorella Artuso (artuso@diag.uniroma1.it)
Reported on 2021-08-20 07:59:58 -0700
Last modified on 2021-08-24 16:15:45 -0700
Version trunk
Hardware PC Linux
CC dblaikie@gmail.com, ditaliano@apple.com, jdevlieghere@apple.com, jeremy.morse.llvm@gmail.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Comment:
When stepping on line 4 the variable g_3012 is not visible.

Steps to reproduce bug:

root@e60e0a2bba1a:/home/stepping/output# clang -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
957334382cd12ec07b46c0ddfdcc220731f6d80f)
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

root@e60e0a2bba1a:/home/stepping/output# lldb -v
lldb version 14.0.0 (https://github.com/llvm/llvm-project.git revision
957334382cd12ec07b46c0ddfdcc220731f6d80f)
  clang revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
  llvm revision 957334382cd12ec07b46c0ddfdcc220731f6d80f

root@e60e0a2bba1a:/home/stepping/output# cat a.c
int g_97 ;
       static short g_3012 ;
       void  func_30() {
         g_97 = g_3012;
       }
       int main()      {
             {
              func_30();
            }
           }

root@e60e0a2bba1a:/home/stepping/output# cat -n a.c
     1  int g_97 ;
     2         static short g_3012 ;
     3         void  func_30() {
     4           g_97 = g_3012;
     5         }
     6         int main()      {
     7               {
     8                func_30();
     9              }
    10             }

root@e60e0a2bba1a:/home/stepping/output# clang -g -Og a.c -o opt

root@e60e0a2bba1a:/home/stepping/output# lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main [inlined] func_30 at a.c:4:15, address =
0x0000000000400490
(lldb) r
Process 68731 launched: '/home/stepping/output/opt' (x86_64)
Process 68731 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400490 opt`main [inlined] func_30 at a.c:4:15
   1    int g_97 ;
   2           static short g_3012 ;
   3           void  func_30() {
-> 4             g_97 = g_3012;
   5           }
   6           int main()      {
   7                 {
(lldb) p g_3012
error: expression failed to parse:
error: <user expression 0>:1:1: use of undeclared identifier 'g_3012'
g_3012
Quuxplusone commented 3 years ago

Looks like IPSCCPPass removes the global variable & doesn't create a constant expression for the debug representation (DIGlobalVariableExpression) representing the value.

Quuxplusone commented 3 years ago

Yes, this is a bug in ISCCP as Dave said.