[all-commits] [llvm/llvm-project] e665cf: [BOLT] Fix handling of ambiguous jump table entrie...

Maksim Panchenko via All-commits all-commits at lists.llvm.org
Mon Aug 25 17:13:52 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e665cf397686e881cfb0728d896d2f375c0aead5
      https://github.com/llvm/llvm-project/commit/e665cf397686e881cfb0728d896d2f375c0aead5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2025-08-25 (Mon, 25 Aug 2025)

  Changed paths:
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    A bolt/test/X86/jump-table-ambiguous-unreachable.s

  Log Message:
  -----------
  [BOLT] Fix handling of ambiguous jump table entries (#155291)

Jump tables may contain entries that point immediately past the end of
their parent function. Normally, such entries are generated by the
compiler as a result of builtin_unreachable() case. We used to replace
those entries with a label belonging to their parent function assuming
the destination doesn't matter if it's an undefined behavior.

However, if such entry is at the end of the jump table, it could be a
real function pointer, not a jump table entry. We rely on heuristics to
detect such cases and can drop the trailing function pointer entries
from the table.

The problem presents when the "unreachable" ambiguous entry is followed
by another ambiguous entry corresponding to the start of the parent
function. In this case we accept pointers as entries and may incorrectly
update the function pointer.

The solution is to keep ambiguous "unreachable" jump table entries
identical to the original input, i.e. point to the same function. This
change does not affect CFG, but results in the entries being updated
with the new function address if it gets relocated.



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