[llvm-bugs] [Bug 50580] New: Emitted binary code changes when -g is enabled at -O1
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 4 07:49:11 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50580
Bug ID: 50580
Summary: Emitted binary code changes when -g is enabled at -O1
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: tlwang at uwaterloo.ca
CC: llvm-bugs at lists.llvm.org
The .text section for the following program (program.c) changes after toggling
the -g flag.
$ cat program.c
short a;
int b, c;
long d, e;
long f() {
long g = ({ d == 0 ? c : c / d; }), h = e;
int i = b & g;
if (i) {
a = 0;
return b;
}
return h;
}
int main() {}
$
$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
8a96993da5ef408847505ec2e470805a71c30392)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang-trunk -O1 -w program.c ; objdump --disassemble a.out > "no-g.txt"
$ clang-trunk -O1 -g -w program.c ; objdump --disassemble a.out > "g.txt"
$ diff no-g.txt g.txt
113,115c113,116
< 401141: 48 8b 05 f8 2e 00 00 mov 0x2ef8(%rip),%rax #
404040 <e>
< 401148: c3 retq
< 401149: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
---
> 401141: 48 8b 0d f8 2e 00 00 mov 0x2ef8(%rip),%rcx # 404040 <e>
> 401148: 48 89 c8 mov %rcx,%rax
> 40114b: c3 retq
> 40114c: 0f 1f 40 00 nopl 0x0(%rax)
--
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/20210604/39a94a21/attachment-0001.html>
More information about the llvm-bugs
mailing list