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

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 18 11:05:56 PDT 2019


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

            Bug ID: 41534
           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: 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

This also affects trunk -O2 and -O3

$ 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
int a;
int *b;
int main() {
  int l_1081 = 1834104526;
  int *c = &l_1081;
  b = c;
  *b = a = 9;
  optimize_me_not();
}


$ cat outer.c
optimize_me_not() {}


$ cat cmds
b 8
r
p l_1081
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 8
Breakpoint 1: where = a.out`main + 60 at abc.c:8:3, address =
0x00000000004004bc
(lldb) r
Process 7408 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004bc a.out`main at abc.c:8:3
   5      int *c = &l_1081;
   6      b = c;
   7      *b = a = 9;
-> 8      optimize_me_not();
   9    }

Process 7408 launched: '/home/ybli/Projects/LLDB-testing/reduce.llvm/a.out'
(x86_64)
(lldb) p l_1081
(int) $0 = 9
(lldb) kill
Process 7408 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 8
Breakpoint 1: where = a.out`main + 31 at abc.c:8:3, address =
0x000000000040049f
(lldb) r
Process 13547 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x000000000040049f a.out`main at abc.c:8:3
   5      int *c = &l_1081;
   6      b = c;
   7      *b = a = 9;
-> 8      optimize_me_not();
   9    }

Process 13547 launched: '/home/ybli/Projects/LLDB-testing/reduce.llvm/a.out'
(x86_64)
(lldb) p l_1081
(int) $0 = 1834104526
(lldb) kill
Process 13547 exited with status = 9 (0x00000009) 
(lldb) q

bisection suggest instcombine:

working:
BISECT: running pass (9) Dead Argument Elimination on module (abc.c)
BISECT: NOT running pass (10) Combine redundant instructions on function (main)

not working:
BISECT: running pass (10) Combine redundant instructions on function (main)
BISECT: NOT running pass (11) Simplify the CFG on function (main)

-- 
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/20190418/1298e9a5/attachment-0001.html>


More information about the llvm-bugs mailing list