[llvm] [BOLT] Preserve branches past function boundaries (PR #218400)

Adam Bzowski via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 04:07:45 PDT 2026


adam-bzowski-arm wrote:

Hi @yozhu! Thanks for the comment and sorry for the delay on my part :) I think this is the part of a much bigger issue: how to detect and deal with the code that may not obey some good practices (like a hand-written assembly may).

> If it does and we now preserve the jump, which means the code in that range (or at least some of it) is now part of the function, should we also reset the function size accordingly (since we no longer take the code in that range as padding)?

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.

> I hit the same problem with some third-party library code written in assembly last year, and at that time I changed this kind of labels in a way that the assembler won't omit them from symbol table.

This sounds like a better approach: to reconstruct the missing label and create the function out of it. But I don't have enough experience with BOLT to say right now if this is feasible or if it breaks some other principles. I'd be happy to have a look though. I just wanted to avoid the most obvious miscompilation. :)


https://github.com/llvm/llvm-project/pull/218400


More information about the llvm-commits mailing list