[PATCH] D70157: Align branches within 32-Byte boundary
Fedor Sergeev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 9 02:21:26 PST 2019
fedor.sergeev added a comment.
In D70157#1774561 <https://reviews.llvm.org/D70157#1774561>, @skan wrote:
> I could not reproduce the phenomenon that N-byte nop becomes (N+M) bytes with your example. So according to my understanding, I slightly modified your case. (If my understand is wrong, I hope you can point it out :-). )
>
> .text
> nop
> .Ltmp0:
> .p2align 3, 0x90
> .rept 16
> nop
> .endr
> .Ltmp3:
> movl %eax, -4(%rsp)
In our case it was
andl $1, %eax
but it does not matter that much.
> .rept 2
> nop
> .endr
> jmp .Ltmp0
>
> The instruction `jmp .Ltmp0` starts at byte 0x1e and ends at byte 0x20.
Again, in our particular case start of the sequence was at xxx8, so 8 + 16(our sequence) + 3(andl) + 5(jmp) == 32.
> If we align the jump with preifx, two prefixes will be added to the `.rept2 16 nop .endr`. After prefixes are added, the 16-byte nop becomes 18-byte nop, then the label '.Ltmp3' is not 8-byte aligned any more.
Yes, thats what happened.
> I doubt whether the assumption that '.Ltmp3' is 8-byte aligned is right, since the alignment is not explicitly required.
The point is that we have explicit requirement at the start and we have a lowering into 16-byte sequence that we need to be preserved exactly as it is.
Essentially what we need is a "protection" for this sequence from any changes by machinery that generates the binary code.
How can we protect a particular byte sequence from being changed by this branch aligner?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70157/new/
https://reviews.llvm.org/D70157
More information about the cfe-commits
mailing list