[llvm-bugs] [Bug 40857] New: Wrong debug info generated at -O2 (-O0 is correct)

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 25 18:25:48 PST 2019


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

            Bug ID: 40857
           Summary: Wrong debug info generated at -O2 (-O0 is correct)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Keywords: wrong-debug
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: aprantl at apple.com, cmtice at google.com,
                    david.stenberg at ericsson.com, dblaikie at gmail.com,
                    echristo at gmail.com, florian_hahn at apple.com,
                    jeremy.morse.llvm at gmail.com, llvm-bugs at lists.llvm.org,
                    vsk at apple.com

$ cat outer.c
void optimize_me_not() {}

$ cat 7.c
int a[6];
int b;
int main() {
  int i, c = 8;
  for (; c; c--)
    b = b >> 5;
  i = 0;
  for (; i < 7; i++)
    for (; c < 2; c++)
      b = b & 4095 ^ a[b & 255];
  i = 0;
  for (; i < 5; i++)
    ;
  b = b >> 8 ^ 5;
  optimize_me_not();
}

### -O2

(lldb) r
Process 16600 launched: '/home/davide/finished_reducing/a.out' (x86_64)
Process 16600 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004be a.out`main at 7.c:15:3
   12     for (; i < 5; i++)
   13       ;
   14     b = b >> 8 ^ 5;
-> 15     optimize_me_not();
   16   }
(lldb) frame var
(int) c = 0
(int) i = 0


### -O0

Process 18140 launched: '/home/davide/finished_reducing/a.out' (x86_64)
Process 18140 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400562 a.out`main at 7.c:15:3
   12     for (; i < 5; i++)
   13       ;
   14     b = b >> 8 ^ 5;
-> 15     optimize_me_not();
   16   }
(lldb) frame var
(int) i = 5
(int) c = 2

-- 
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/20190226/7ba2916b/attachment-0001.html>


More information about the llvm-bugs mailing list