<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 - Multibyte NOPs not used for padding"
href="https://bugs.llvm.org/show_bug.cgi?id=40043">40043</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Multibyte NOPs not used for padding
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows XP
</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>COFF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sneves@dei.uc.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>When compiling Windows binaries using `clang[-cl] -flto=[thin,full]`, loops are
aligned using long sequences of 1-byte nops, instead of multibyte nops, as is
the case when regular linking is employed. Example:
==============================================================================
Compiled with clang-cl /MD /Ox /Zi -flto=full -fuse-ld=lld
14000100c: 48 8b 3d 7d 24 00 00 movq 9341(%rip), %rdi
140001013: 90 nop
140001014: 90 nop
140001015: 90 nop
140001016: 90 nop
140001017: 90 nop
140001018: 90 nop
140001019: 90 nop
14000101a: 90 nop
14000101b: 90 nop
14000101c: 90 nop
14000101d: 90 nop
14000101e: 90 nop
14000101f: 90 nop
140001020: ff d7 callq *%rdi
140001022: 83 c6 ff addl $-1, %esi
140001025: 75 f9 jne -7 <.text+0x20>
Compiled with clang-cl /MD /Ox /Zi -fuse-ld=lld
14000100c: 48 8b 3d 7d 24 00 00 movq 9341(%rip), %rdi
140001013: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax)
14000101d: 0f 1f 00 nopl (%rax)
140001020: ff d7 callq *%rdi
140001022: 83 c6 ff addl $-1, %esi
140001025: 75 f9 jne -7 <.text+0x20>
==============================================================================
My short investigation of this phenomenon suggests that this is due to the CPU
field not being filled with the appropriate target,
<a href="https://github.com/llvm-mirror/lld/blob/master/COFF/LTO.cpp#L44-L73">https://github.com/llvm-mirror/lld/blob/master/COFF/LTO.cpp#L44-L73</a>
as is the case with the ELF linker:
<a href="https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L90">https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L90</a>
Presumably when, in the course of generating X86 code, it gets to
<a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp#L347">https://github.com/llvm-mirror/llvm/blob/master/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp#L347</a>
it will not know that the target does support multibyte nops.</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>