[llvm-bugs] [Bug 41548] New: Clang-trunk generate wrong debug info under -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 20 12:13:18 PDT 2019


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

            Bug ID: 41548
           Summary: Clang-trunk generate wrong debug info under -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 problem also happens under 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
short a;
int main() {
  int l_2849 = 38358926;
  if (a)
    ;
  else
    optimize_me_not();
  l_2849 = 0;
}


$ cat outer.c 
optimize_me_not() {}


$ 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 + 42 at abc.c:7:5, address =
0x00000000004004aa
(lldb) r
Process 30735 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004aa a.out`main at abc.c:7:5
   4      if (a)
   5        ;
   6      else
-> 7        optimize_me_not();
   8      l_2849 = 0;
   9    }

Process 30735 launched: '/home/ybli/Projects/LLDB-testing/reduce.llvm/a.out'
(x86_64)
(lldb) p l_2849
(int) $0 = 38358926
(lldb) kill
Process 30735 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 + 14 at abc.c:7:5, address =
0x000000000040048e
(lldb) r
Process 6641 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x000000000040048e a.out`main at abc.c:7:5
   4      if (a)
   5        ;
   6      else
-> 7        optimize_me_not();
   8      l_2849 = 0;
   9    }

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


Pass bisection suggests that the problem is related to LEA fixup:

Correct case:
BISECT: running pass (92) X86 Atom pad short functions on function
(optimize_me_not)
BISECT: NOT running pass (93) X86 LEA Fixup on function (optimize_me_not)

Incorrect case:
BISECT: running pass (92) X86 Atom pad short functions on function
(optimize_me_not)
BISECT: running pass (93) X86 LEA Fixup on function (optimize_me_not)

-- 
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/20190420/3b9a7842/attachment.html>


More information about the llvm-bugs mailing list