[PATCH] D135912: [PseudoProbe] Replace relocation with offset for entry probe.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 13:14:11 PDT 2022


hoy created this revision.
Herald added subscribers: ormris, modimo, wenlei, hiraditya.
Herald added a project: All.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently pseudo probe encoding for a function is like:

- For the first probe, a relocation from it to its physical position in the code body
- For subsequent probes, an incremental offset from the current probe to the previous probe

The relocation could potentially cause relocation overflow during link time. I'm now replacing it with an offset from the first probe to the function start address.

To avoid being too intrusive to the encoding logic and data structure, the changeset does:

1. Prior to encoding, introducing a fake sentinel probe that serves as a place holder for the function start address
2. During encoding, leveraging the sentinel probe to compute the offset of the first probe, but actually skipping encoding the sentinel probe

This reduces the .pseudo_probe section size by 1%.

Decoding change will be in separate patch.

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135912

Files:
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
  llvm/lib/CodeGen/PseudoProbeInserter.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCPseudoProbe.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135912.467583.patch
Type: text/x-patch
Size: 15369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221013/884f143d/attachment.bin>


More information about the llvm-commits mailing list