[llvm] [BOLT] Preserve branches past function boundaries (PR #218400)
Rafael Auler via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 15:49:41 PDT 2026
rafaelauler wrote:
> Hmm, I'm not sure. In my case at least, this happens specifically when jumping into the code that used to be labeled by a temporary .L label. The label was removed and now BOLT thinks the jump is into padding. The code, however, does not have to be contiguous, there may a be a piece of code or data (a jump table in my case) in the middle.
You have a jump table, so this is a non-simple function? We just need to freeze it and copy it into the output without modifying, right? In that case, replacing a jump into a NOP for a non-simple function seems... wrong. By definition, a non-simple function is one in which we already assumed we don't fully understand it.
However, keeping the branch might be tricky, since we can't tell what is the target. If you jump into the padding area, that's pretty bad, because that's not code that we have disassembled.
BOLT's logic to decide what's inside a function is largely dictated by an STT_FUNCTION symbol in the symbol table with size big enough to cover the entire function, and appropriate $d/$x symbols to delimit the jump tables or constant islands inside the function. And then the fallback would be the CFI, also mandated by ABI. There are a million ways to violate this simple contract, and writing assembly by hand it is kind of easy to violate this, but how tolerant we should be is an open question.
https://github.com/llvm/llvm-project/pull/218400
More information about the llvm-commits
mailing list