[PATCH] D152631: [BOLT] Fix handling of code references from unmodified code

Maksim Panchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 14:02:27 PDT 2023


maksfb created this revision.
maksfb added reviewers: yota9, Amir, rafauler.
Herald added a subscriber: pengfei.
Herald added a project: All.
maksfb requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In lite mode (default for X86), BOLT optimizes and relocates functions
with profile. The rest of the code is preserved, but if it references
relocated code such references have to be updated. The update is handled
by scanExternalRefs() function. Note that we cannot solely rely on
relocations written by the linker, as not all code references are
exposed to the linker. Additionally, the linker can modify certain
instructions and relocations will no longer match the code.

With this change, start using symbolic disassembler for scanning code
for references in scanExternalRefs(). Unlike the previous approach, the
symbolizer properly detects and creates references for instructions with
multiple/ambiguous symbolic operands and handles cases where a
relocation doesn't match any operand. See test cases for examples.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152631

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Core/BinaryFunction.cpp
  bolt/lib/Target/X86/X86MCPlusBuilder.cpp
  bolt/lib/Target/X86/X86MCSymbolizer.cpp
  bolt/lib/Target/X86/X86MCSymbolizer.h
  bolt/test/X86/double-rel-scan.s
  bolt/test/X86/double-rel.s
  bolt/test/X86/gotpcrelx.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152631.530250.patch
Type: text/x-patch
Size: 16732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230610/0501112e/attachment.bin>


More information about the llvm-commits mailing list