<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=50427">50427</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>clang
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tlwang@uwaterloo.ca
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The .text section for the following program (transformed_program0.c) changes
after toggling the -g flag.
$ cat transformed_program0.c
int a;
char b, c;
short d() {
{
int e;
f:;
int g = b != 7;
if (!g)
goto h;
if (!a)
goto i;
return a;
i:
b = b + 1;
goto f;
h:;
}
return c;
}
int main() {}
$
$ /home/cnsun/usr/bin/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>
ac06f6d06de408c00923708dd8a795b6ba9d23d7)
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
$
$ /home/cnsun/usr/bin/clang-trunk -O1 -w transformed_program0.c ; objdump
--disassemble a.out > "no-g.txt"
$ /home/cnsun/usr/bin/clang-trunk -O1 -g -w transformed_program0.c ; objdump
--disassemble a.out > "g.txt"
$ diff g.txt no-g.txt
104c104
< 401120: eb 28 jmp 40114a <d+0x3a>
---
<span class="quote">> 401120: eb 27 jmp 401149 <d+0x39></span >
106c106
< 401128: 80 c2 f9 add $0xf9,%dl
---
<span class="quote">> 401128: 80 c2 01 add $0x1,%dl</span >
109,123c109,122
< 401132: 75 14 jne 401148 <d+0x38>
< 401134: 8d 4a 08 lea 0x8(%rdx),%ecx
< 401137: 88 0d ef 2e 00 00 mov %cl,0x2eef(%rip) # 40402c
<b>
< 40113d: fe c2 inc %dl
< 40113f: 0f 94 c1 sete %cl
< 401142: 84 d2 test %dl,%dl
< 401144: 75 ea jne 401130 <d+0x20>
< 401146: eb 02 jmp 40114a <d+0x3a>
< 401148: 89 c1 mov %eax,%ecx
< 40114a: 0f be 05 e3 2e 00 00 movsbl 0x2ee3(%rip),%eax #
404034 <c>
< 401151: 84 c9 test %cl,%cl
< 401153: 0f 44 c6 cmove %esi,%eax
< 401156: c3 retq
< 401157: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
< 40115e: 00 00
---
<span class="quote">> 401132: 75 13 jne 401147 <d+0x37>
> 401134: 88 15 f2 2e 00 00 mov %dl,0x2ef2(%rip) # 40402c <b>
> 40113a: 80 c2 01 add $0x1,%dl
> 40113d: 80 fa 08 cmp $0x8,%dl
> 401140: 0f 94 c1 sete %cl
> 401143: 75 eb jne 401130 <d+0x20>
> 401145: eb 02 jmp 401149 <d+0x39>
> 401147: 89 c1 mov %eax,%ecx
> 401149: 0f be 05 e4 2e 00 00 movsbl 0x2ee4(%rip),%eax # 404034 <c>
> 401150: 84 c9 test %cl,%cl
> 401152: 0f 44 c6 cmove %esi,%eax
> 401155: c3 retq
> 401156: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
> 40115d: 00 00 00</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>