[PATCH] D97982: [MC] Introduce NeverAlign fragment type
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 21:04:30 PDT 2021
Amir added a comment.
In D97982#2811382 <https://reviews.llvm.org/D97982#2811382>, @efriedma wrote:
> Removing the NeverAlign padding can increase the distance between two symbols if .palign is involved. That might require relaxation.
I've tried to reproduce this situation, and came up with the following test case: see experiment B in llvm/test/MC/X86/directive-avoid_end_align.s.
It's a bit hard to follow, but please bear with me:
Experiment A:
1. NeverAlign is added before cmp+jcc, initially no padding.
2. cmp+jcc are both relaxable, initially short form and are split by an alignment boundary,
3. Which triggers NeverAlign padding, one byte is added before cmp+jcc.
4. Which triggers jcc relaxation (pushes out jcc to long form)
5. Which triggers cmp relaxation (pushes out cmp to long form)
6. Which makes NeverAlign redundant as cmp+jcc are not longer split by an alignment boundary.
7. Which disables NeverAlign padding (0 bytes)
8. Which in theory could shrink cmp+jcc to short forms causing an infinite loop, but as long as relaxation only increases instruction sizes, it converges at this point, leaving cmp and jcc in relaxed form.
Experiment B:
1. when NeverAlign padding is removed (step 7 in exp A),
2. causing an increased distance between two symbols (symbols .L53-.L54),
3. which might require relaxation of cmp instruction at .L52 (imm operand goes from -128 to -129),
this doesn't cause in an incorrect result - cmp instruction at L52 is of correct (relaxed) format and has a correct operand (-129, corresponding to removed NeverAlign padding).
I've made a slideshow to highlight what I think is happening: https://drive.google.com/file/d/1ORpeGj9iK6q4NUi0AOFZW3poAkn-Q-tH/view?usp=sharing
> When do we actually do this computation? At first glance, MCAssembler::layoutSectionOnce never actually goes back to recompute the size of the NeverAlign padding.
I'm not sure of the exact mechanism. It might be that layoutSectionOnce/layoutOnce actually recomputes the size of the NeverAlign padding (indirectly). I can try to debug what's going on, but relaxation is a black box to me.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97982/new/
https://reviews.llvm.org/D97982
More information about the llvm-commits
mailing list