[llvm-bugs] [Bug 40043] New: Multibyte NOPs not used for padding

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 16 07:28:26 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=40043

            Bug ID: 40043
           Summary: Multibyte NOPs not used for padding
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows XP
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: sneves at dei.uc.pt
                CC: llvm-bugs at lists.llvm.org

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,

https://github.com/llvm-mirror/lld/blob/master/COFF/LTO.cpp#L44-L73

as is the case with the ELF linker: 

https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L90

Presumably when, in the course of generating X86 code, it gets to

https://github.com/llvm-mirror/llvm/blob/master/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp#L347

it will not know that the target does support multibyte nops.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181216/777dcf4c/attachment-0001.html>


More information about the llvm-bugs mailing list