[llvm-bugs] [Bug 41925] New: Clang-trunk Generates Wrong Debug values with -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 17 11:33:20 PDT 2019


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

            Bug ID: 41925
           Summary: Clang-trunk Generates Wrong Debug values with -O1
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: wrong-debug
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: yuanboli233 at gmail.com
                CC: aprantl at apple.com, davide at freebsd.org,
                    jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com, vsk at apple.com

$ clang-trunk --version
clang version 9.0.0 (trunk 355785)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ lldb-trunk --version
lldb version 9.0.0 (https://llvm.org/svn/llvm-project/lldb/trunk revision
355785)
  clang revision 355785
  llvm revision 355785

$ cat abc.c
char a, b;
int main() {
  char l_177 = 2;
  for (; b <= 0; b++)
    for (; a >= 0; a--) {
      ++l_177;
      optimize_me_not();
    }
}

$ cat outer.c 
optimize_me_not() {}

$ cat cmds 
b 7
r
p l_177
kill
q

$ clang-trunk -O0 -g abc.c outer.c

$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/ybli/Projects/LLDB-testing/reduce.llvm/cmds'.
(lldb) b 7
Breakpoint 1: where = a.out`main + 66 at abc.c:7:7, address =
0x00000000004004c2
(lldb) r
Process 10423 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004c2 a.out`main at abc.c:7:7
   4      for (; b <= 0; b++)
   5        for (; a >= 0; a--) {
   6          ++l_177;
-> 7          optimize_me_not();
   8        }
   9    }

Process 10423 launched: '/home/ybli/Projects/LLDB-testing/reduce.llvm/a.out'
(x86_64)
(lldb) p l_177
(char) $0 = '\x03'
(lldb) kill
Process 10423 exited with status = 9 (0x00000009) 
(lldb) q

$ clang-trunk -O1 -g abc.c outer.c

$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/ybli/Projects/LLDB-testing/reduce.llvm/cmds'.
(lldb) b 7
Breakpoint 1: where = a.out`main + 32 at abc.c:7:7, address =
0x00000000004004a0
(lldb) r
Process 31526 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004a0 a.out`main at abc.c:7:7
   4      for (; b <= 0; b++)
   5        for (; a >= 0; a--) {
   6          ++l_177;
-> 7          optimize_me_not();
   8        }
   9    }

Process 31526 launched: '/home/ybli/Projects/LLDB-testing/reduce.llvm/a.out'
(x86_64)
(lldb) p l_177
(char) $0 = '\x02'
(lldb) kill
Process 31526 exited with status = 9 (0x00000009) 
(lldb) q


The bisection result is

correct: (the case shows l_177 could not materialize)
BISECT: running pass (46) Simplify the CFG on function 
BISECT: NOT running pass (47) Combine redundant instructions on function
not working:
BISECT: running pass (46) Simplify the CFG on function
BISECT: running pass (47) Combine redundant instructions on function

-- 
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/20190517/c095fa3f/attachment.html>


More information about the llvm-bugs mailing list