<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 - X86AsmBackend::finishLayout causes different assembler output with and w/o -g (2-byte jmp/jcc vs 5-byte)"
href="https://bugs.llvm.org/show_bug.cgi?id=48742">48742</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>X86AsmBackend::finishLayout causes different assembler output with and w/o -g (2-byte jmp/jcc vs 5-byte)
</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>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>i@maskray.me
</td>
</tr>
<tr>
<th>CC</th>
<td>dblaikie@gmail.com, jdevlieghere@apple.com, jyknight@google.com, keith.walker@arm.com, listmail@philipreames.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr></table>
<p>
<div>
<pre><a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Different codegen with/without -g"
href="show_bug.cgi?id=42138">bug 42138</a>#c13 was reopened due to different assembler output with -O1 and -O1
-g. Because the assembler issue is so different from the original BranchFolding
bug, I am opening a new bug.
<span class="quote">> < 40: eb 0e jmp 50 <_ZN1k1lEv+0x50>
> < 42: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
> < 49: 00 00 00
> < 4c: 0f 1f 40 00 nopl 0x0(%rax)
> ---
> > 40: e9 0b 00 00 00 jmpq 50 <_ZN1k1lEv+0x50>
> > 45: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
> > 4c: 00 00 00
> > 4f: 90 nop</span >
The D75203 assembler optimization locates MCRelaxableFragment's within two
MCSymbol's and relaxes some MCRelaxableFragment's (jmp/jcc) to reduce the size
of a MCAlignFragment.
Its behavior is dependent on the MCSymbol's in the text section.
A -g compile may have more labels (due to ranges/locations referenced by
.debug_*; currently it seems that some .Ltmp* may be redundant (I am going to
investigate further) but **many cannot be removed**).
.p2align 4, 0x90 is common due to loops. For a larger program, with a lot of
temporary labels, the assembly output difference is somewhat destined.
I think the cost of D75203 overweighs the benefits, so I think we should
default to -x86-pad-for-align=false for now (<a href="https://reviews.llvm.org/D94542">https://reviews.llvm.org/D94542</a> ).
When -mbranches-within-32B-boundaries (to mitigate microcode update for Intel
JCC Erratum) is used, there are many alignment fragments. I think D75203 in
that case. In the absence of -mbranches-within-32B-boundaries, the advantage of
D75203 is questionable.
Other opinions: <a href="https://reviews.llvm.org/D75203#2496082">https://reviews.llvm.org/D75203#2496082</a> (jyknight), its
previous comment (skan).
I agree that to make the behavior of D75203 deterministic with -g and without
we will need to "find all sections referenced by a relaxable fixup in the text
section", and recursively. This will be very complex and dilute the gain of
D75203</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>