[llvm-bugs] [Bug 45934] New: Wrong Debug Information for Oz. Stepping on dead code.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 15 02:13:27 PDT 2020


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

            Bug ID: 45934
           Summary: Wrong Debug Information for Oz. Stepping on dead code.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: wrong-debug
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    ditaliano at apple.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The debugger shows that line 2 is executed while it shouldn't be.

$ cat a.c
int add(int ui1, int ui2) {
  return ui1 + ui2;
}
int g_8 ;
int a = 4 ;
int c
 ;
int main()  {
  for (g_8 = 0; (g_8 < 49); g_8 = add(g_8, 9)) {
      for (; c ; c++)
        ;
    if (a)
      break;
  }
}

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
c25b20c0f6c13d68dbc2e185764082d61ae4a132)
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
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
  llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ clang -Oz -g -o opt a.c

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 2
Breakpoint 1: 2 locations.
(lldb) r
Process 145 launched: 'opt' (x86_64)
Process 145 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.2
    frame #0: 0x000000000040049d opt`main [inlined] add(ui1=0, ui2=9) at
a.c:2:14
   1    int add(int ui1, int ui2) {
-> 2      return ui1 + ui2;
   3    }
   4    int g_8 ;
   5    int a = 4 ;
   6    int c
   7     ;
(lldb) 

$ gdb opt
(gdb) b -l 2
Breakpoint 1 at 0x400474: -source a.c -line 2. (2 locations)
(gdb) r
Starting program: opt 

Breakpoint 1, main () at a.c:9
9         for (g_8 = 0; (g_8 < 49); g_8 = add(g_8, 9)) {
(gdb) s
add (ui1=0, ui2=9) at a.c:2
2         return ui1 + ui2;
(gdb)

-- 
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/20200515/2b23db44/attachment.html>


More information about the llvm-bugs mailing list