[PATCH] D145211: Relax cross-section branches
Daniel Hoekwater via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 16:06:05 PDT 2023
dhoekwater marked an inline comment as done.
dhoekwater added a comment.
In D145211#4537173 <https://reviews.llvm.org/D145211#4537173>, @efriedma wrote:
>> Unconditional branches are relaxed via thunk insertion by the linker, but conditional branches must be manually relaxed. Because of this, we should assume that any cross-sectional conditional jumps are out of range
>
> As-is, it looks like this patch is also relaxing cross-sectional unconditional jumps. Given we can trust the linker to relax these, and we expect the branches to be cold, is there a reason for the compiler to relax them? I guess the linker-generated stub could clobber x16/x17?
Yeah, the linker will clobber X16 to relax unconditional jumps <https://github.com/llvm/llvm-project/blob/main/lld/ELF/Thunks.cpp#L537>. The ABI seems designed around the assumption that out-of-range unconditional jumps only exist at function call boundaries, so we have to work around that.
================
Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:287
+ .addReg(Reg)
+ .addReg(AArch64::SP)
+ .addImm(-16);
----------------
efriedma wrote:
> Do we know at this point that the function isn't using the red zone? (We usually use the emergency spill slot for this sort of situation.)
Because BranchRelaxation runs after Frame Finalization, we can't add an emergency spill slot at this point.
We could add a spill slot to every function just in case spilling is necessary, but I would expect it to degrade performance.
Since Red Zone on AArch64 isn't widely used, it should be alright if it isn't compatible with MFS/BBSections on AArch64. I'll add an explicit check here to assert that we're not doing anything we shouldn't.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145211/new/
https://reviews.llvm.org/D145211
More information about the llvm-commits
mailing list