[llvm] Avoid indirect branches from cold sections when BTI is enabled (PR #194727)
Daniel Hoekwater via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 16:17:05 PDT 2026
================
@@ -401,19 +401,21 @@ void AArch64InstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
return;
}
- // If there's a free register and it's worth inflating the code size,
+ // If we are in a cold block, BTI is not enabled, and there's a free register,
----------------
dhoekwater wrote:
nit: The reason we're skipping indirect branch instruction here is to avoid inserting a BTI instruction at the (maybe hot) branch target. Can you update the comment to reflect this?
The motivation behind this logic is clear now, but documenting it in the code may provide valuable context to the reader e.g. a year from now.
https://llvm.org/docs/CodingStandards.html#commenting
https://github.com/llvm/llvm-project/pull/194727
More information about the llvm-commits
mailing list