<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"
href="https://bugs.llvm.org/show_bug.cgi?id=50580">50580</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Emitted binary code changes when -g is enabled at -O1
</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>Loop Optimizer
</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>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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)
---
<span class="quote">> 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)</span ></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>