[llvm-bugs] [Bug 51195] New: Emitted binary code changes when -g is enabled at -O1 with -flto=thin
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 23 13:04:28 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51195
Bug ID: 51195
Summary: Emitted binary code changes when -g is enabled at -O1
with -flto=thin
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: tlwang at uwaterloo.ca
CC: cnsun at uwaterloo.ca, llvm-bugs at lists.llvm.org
Blocks: 37728
This might be related to https://bugs.llvm.org/show_bug.cgi?id=51110, but I'm
not sure because the programs look rather different.
The .text section for the following program (transformed_program0.c) changes
after toggling the -g flag.
$ cat transformed_program0.c
int d, g;
union a {
unsigned b;
} c[54] = {{1}};
void h() {
union a *e = &c[9];
int f = e != 0;
}
int main() {
d = d ^ c[g].b;
g = 1;
}
$
$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
ab5ac659c81a453a3f58df94f39fe8ba3cd35918)
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 -flto=thin -O1 transformed_program0.c ; objdump --disassemble
--section=.text a.out > no_g.txt
$ clang-trunk -g -flto=thin -O1 transformed_program0.c ; objdump --disassemble
--section=.text a.out > g.txt
$ diff no_g.txt g.txt
31,32c31,32
< 401060: b8 28 40 40 00 mov $0x404028,%eax
< 401065: 48 3d 28 40 40 00 cmp $0x404028,%rax
---
> 401060: b8 08 41 40 00 mov $0x404108,%eax
> 401065: 48 3d 08 41 40 00 cmp $0x404108,%rax
37c37
< 401077: bf 28 40 40 00 mov $0x404028,%edi
---
> 401077: bf 08 41 40 00 mov $0x404108,%edi
46,47c46,47
< 401090: be 28 40 40 00 mov $0x404028,%esi
< 401095: 48 81 ee 28 40 40 00 sub $0x404028,%rsi
---
> 401090: be 08 41 40 00 mov $0x404108,%esi
> 401095: 48 81 ee 08 41 40 00 sub $0x404108,%rsi
57c57
< 4010b9: bf 28 40 40 00 mov $0x404028,%edi
---
> 4010b9: bf 08 41 40 00 mov $0x404108,%edi
66c66
< 4010d4: 80 3d 4d 2f 00 00 00 cmpb $0x0,0x2f4d(%rip) #
404028 <__TMC_END__>
---
> 4010d4: 80 3d 2d 30 00 00 00 cmpb $0x0,0x302d(%rip) # 404108 <__TMC_END__>
71c71
< 4010e6: c6 05 3b 2f 00 00 01 movb $0x1,0x2f3b(%rip) #
404028 <__TMC_END__>
---
> 4010e6: c6 05 1b 30 00 00 01 movb $0x1,0x301b(%rip) # 404108 <__TMC_END__>
88,91c88,91
< 401110: 0f b6 05 19 2f 00 00 movzbl 0x2f19(%rip),%eax #
404030 <g>
< 401117: 8b 04 85 10 20 40 00 mov 0x402010(,%rax,4),%eax
< 40111e: 31 05 08 2f 00 00 xor %eax,0x2f08(%rip) #
40402c <d>
< 401124: c6 05 05 2f 00 00 01 movb $0x1,0x2f05(%rip) #
404030 <g>
---
> 401110: 0f b6 05 f9 2f 00 00 movzbl 0x2ff9(%rip),%eax # 404110 <g>
> 401117: 8b 04 85 30 40 40 00 mov 0x404030(,%rax,4),%eax
> 40111e: 31 05 e8 2f 00 00 xor %eax,0x2fe8(%rip) # 40410c <d>
> 401124: c6 05 e5 2f 00 00 01 movb $0x1,0x2fe5(%rip) # 404110 <g>
Referenced Bugs:
https://bugs.llvm.org/show_bug.cgi?id=37728
[Bug 37728] [meta] Make llvm passes debug info invariant
--
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/20210723/6c4288c0/attachment-0001.html>
More information about the llvm-bugs
mailing list