[all-commits] [llvm/llvm-project] 63e60a: [BOLT] Fix strict mode bug in removal of block ref...

Rafael Auler via All-commits all-commits at lists.llvm.org
Mon Jul 27 12:36:15 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 63e60a2853b1ff6fdac3cbaf668e2d2a63d51fae
      https://github.com/llvm/llvm-project/commit/63e60a2853b1ff6fdac3cbaf668e2d2a63d51fae
  Author: Rafael Auler <rafaelauler at meta.com>
  Date:   2026-07-27 (Mon, 27 Jul 2026)

  Changed paths:
    M bolt/lib/Passes/BinaryPasses.cpp
    A bolt/test/X86/jump-table-empty-block-strict.s

  Log Message:
  -----------
  [BOLT] Fix strict mode bug in removal of block referenced by JT (#211940)

Summary:
BOLT can create a jump table object from a PC-relative operand reference
(e.g. leaq JT(%rip)) whenever the referenced memory looks like a PIC
jump table -- see
BinaryContext::handleAddressRef. This is independent of whether BOLT
recognizes the indirect jump dispatch itself. The jump table annotation
is only attached to the jmp instruction later, in
BinaryFunction::analyzeIndirectBranch, and only when the target-specific
analyzeIndirectBranch matcher recognizes the dispatch pattern.

If the matcher does not recognize the pattern, the annotation is never
attached to the jmp, even though the jump table object and its entries
exist and reference basic blocks in the function.

In strict mode BOLT still fully processes such a function: it stays
simple, the block is marked as having unknown control flow, and the jump
table object is kept intact. Because the terminator carries no jump
table annotation, BinaryBasicBlock::hasJumpTable() returns false for it.
Later passes then transform the function normally: remove-nops can empty
a jump table target block that consists only of nops, and NormalizeCFG
then redirects the block's predecessor and deletes the empty block - it
does not recognize the block as a jump table target, since the
predecessor's hasJumpTable() is false. The jump table object still
references the deleted block by label, which produces an "Undefined
temporary symbol" error and fails emission.

Fix NormalizeCFG so it does not redirect/remove a block whose
predecessor ends in an indirect branch, not only one flagged by
hasJumpTable().



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list