<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Emitted binary code changes when -g is enabled at -O1 with -flto=thin"
href="https://bugs.llvm.org/show_bug.cgi?id=51195">51195</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Emitted binary code changes when -g is enabled at -O1 with -flto=thin
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tlwang@uwaterloo.ca
</td>
</tr>
<tr>
<th>CC</th>
<td>cnsun@uwaterloo.ca, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Blocks</th>
<td>37728
</td>
</tr></table>
<p>
<div>
<pre>This might be related to <a class="bz_bug_link
bz_status_NEW "
title="NEW - Emitted binary code changes when -g is enabled at -O3 with -flto"
href="show_bug.cgi?id=51110">https://bugs.llvm.org/show_bug.cgi?id=51110</a>, 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 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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
---
<span class="quote">> 401060: b8 08 41 40 00 mov $0x404108,%eax
> 401065: 48 3d 08 41 40 00 cmp $0x404108,%rax</span >
37c37
< 401077: bf 28 40 40 00 mov $0x404028,%edi
---
<span class="quote">> 401077: bf 08 41 40 00 mov $0x404108,%edi</span >
46,47c46,47
< 401090: be 28 40 40 00 mov $0x404028,%esi
< 401095: 48 81 ee 28 40 40 00 sub $0x404028,%rsi
---
<span class="quote">> 401090: be 08 41 40 00 mov $0x404108,%esi
> 401095: 48 81 ee 08 41 40 00 sub $0x404108,%rsi</span >
57c57
< 4010b9: bf 28 40 40 00 mov $0x404028,%edi
---
<span class="quote">> 4010b9: bf 08 41 40 00 mov $0x404108,%edi</span >
66c66
< 4010d4: 80 3d 4d 2f 00 00 00 cmpb $0x0,0x2f4d(%rip) #
404028 <__TMC_END__>
---
<span class="quote">> 4010d4: 80 3d 2d 30 00 00 00 cmpb $0x0,0x302d(%rip) # 404108 <__TMC_END__></span >
71c71
< 4010e6: c6 05 3b 2f 00 00 01 movb $0x1,0x2f3b(%rip) #
404028 <__TMC_END__>
---
<span class="quote">> 4010e6: c6 05 1b 30 00 00 01 movb $0x1,0x301b(%rip) # 404108 <__TMC_END__></span >
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>
---
<span class="quote">> 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></span ></pre>
</div>
</p>
<div id="referenced">
<hr style="border: 1px dashed #969696">
<b>Referenced Bugs:</b>
<ul>
<li>
[<a class="bz_bug_link
bz_status_NEW "
title="NEW - [meta] Make llvm passes debug info invariant"
href="https://bugs.llvm.org/show_bug.cgi?id=37728">Bug 37728</a>] [meta] Make llvm passes debug info invariant
</li>
</ul>
</div>
<br>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>