[fpc-devel] Question about NOP instructions

J. Gareth Moreton gareth at moreton-family.com
Sun Nov 3 18:10:20 CET 2019

Here's a larger snippet of the code in question - it's a bit too long to 
post, but there's a lot of conditional jumps to .Lj1859 earlier on:

     testl    $1024,92(%rbx)
     jne    .Lj1878
     leaq    .Ld523(%rip),%rax
     movq    %rax,-56(%rbp)
     movq    $11,-64(%rbp)
     movq    64(%rbx),%rax
     movq    %rax,-40(%rbp)
     movq    $11,-48(%rbp)
     leaq    .Ld524(%rip),%rax
     movq    %rax,-24(%rbp)
     movq    $11,-32(%rbp)
     movq    80(%rbx),%rcx
     leaq    -72(%rbp),%rdx
     movq    -72(%rbp),%rax
     movq    %rax,-8(%rbp)
     movq    $11,-16(%rbp)
     leaq    -64(%rbp),%rcx
     movl    $3,%edx
     call    FILEPROCS_$$_DEBUGLN$array_of_const
     orl    $1024,92(%rbx)
     movq    $0,24(%rbx)
     movq    %rbp,%rcx
     movq    %rsi,%rax
     movq    -88(%rbp),%rbx
     movq    -80(%rbp),%rsi
     leaq    (%rbp),%rsp
     popq    %rbp
.seh_handler __FPC_specific_handler, at unwind
     .long    1
     .long    0
     .rva    .Lj1857
     .rva    .Lj1858

The two unwind entries (.rva) are labels that come right after a NOP 
instruction, and are the only references to these labels - meanwhile, 
the conditional jumps nearer the top go to the labels that appear before 
the nop instruction and are otherwise just testing registers and memory 
locations with no calls to other routines.

In the meantime, I've got my jump code fully tested for i386-win32 and 
x86_64-win64, but am still documenting everything before I post them in 
a patch.  I'm not sure how it behaves on non-Intel platforms yet, but I 
can confirm that it at least compiles.

Gareth aka. Kit

On 03/11/2019 10:44, Florian Klaempfl wrote:
> Am 02.11.2019 um 15:08 schrieb J. Gareth Moreton:
>> Hi everyone,
>> During my optimisation travels, I frequently stumble across lone NOP
>> instructions in the compiled assembly language.  Normally I leave these
>> alone, but occasionally I stumble across things like this:
>>      ...
>>      movq    $0,24(%rbx)
>> .Lj1859:
>>      nop
>> .Lj1858:
>>      movq    %rbp,%rcx
>>      ...
> Can you please post the complete code? Without it, it's hard to say
>> And there are jumps elsewhere that go to one label or the other. Is
>> there any reason why a jump should lead to the NOP, or can they all be
>> redirected to after the NOP instruction?
> Some are the result of exception handling on x86_64-win64, see
> compiler/x86_64/nx64flw.pas
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

This email has been checked for viruses by Avast antivirus software.

More information about the fpc-devel mailing list