[all-commits] [llvm/llvm-project] d5a963: [PseudoProbe] Replace relocation with offset for e...
Hongtao Yu via All-commits
all-commits at lists.llvm.org
Thu Oct 27 13:28:48 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d5a963ab8b40fcf7a99acd834e5f10a1a30cc2e5
https://github.com/llvm/llvm-project/commit/d5a963ab8b40fcf7a99acd834e5f10a1a30cc2e5
Author: Hongtao Yu <hoy at fb.com>
Date: 2022-10-27 (Thu, 27 Oct 2022)
Changed paths:
M bolt/lib/Rewrite/RewriteInstance.cpp
M llvm/include/llvm/IR/PseudoProbe.h
M llvm/include/llvm/MC/MCObjectFileInfo.h
M llvm/include/llvm/MC/MCPseudoProbe.h
M llvm/include/llvm/MC/MCStreamer.h
M llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
M llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
M llvm/lib/MC/MCAsmStreamer.cpp
M llvm/lib/MC/MCObjectFileInfo.cpp
M llvm/lib/MC/MCParser/AsmParser.cpp
M llvm/lib/MC/MCPseudoProbe.cpp
M llvm/lib/MC/MCStreamer.cpp
M llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
M llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
M llvm/test/tools/llvm-profgen/Inputs/func-split.perfbin
M llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin
M llvm/test/tools/llvm-profgen/inline-force-dwarf.test
M llvm/tools/llvm-profgen/ProfileGenerator.cpp
M llvm/tools/llvm-profgen/ProfiledBinary.cpp
M llvm/tools/llvm-profgen/ProfiledBinary.h
Log Message:
-----------
[PseudoProbe] Replace relocation with offset for entry probe.
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.
A source function could be lowered into multiple binary functions due to outlining (e.g, coro-split). Since those binary function have independent link-time layout, to really avoid relocations from .pseudo_probe sections to .text sections, the offset to replace with should really be the offset from the probe's enclosing binary function, rather than from the entry of the source function. This requires some changes to previous section-based emission scheme which now switches to be function-based. The assembly form of pseudo probe directive is also changed correspondingly, i.e, reflecting the binary function name.
Most of the source functions end up with only one binary function. For those don't, a sentinel probe is emitted for each of the binary functions with a different name from the source. The sentinel probe indicates the binary function name to differentiate subsequent probes from the ones from a different binary function. For examples, given source function
```
Foo() {
…
Probe 1
…
Probe 2
}
```
If it is transformed into two binary functions:
```
Foo:
…
Foo.outlined:
…
```
The encoding for the two binary functions will be separate:
```
GUID of Foo
Probe 1
GUID of Foo
Sentinel probe of Foo.outlined
Probe 2
```
Then probe1 will be decoded against binary `Foo`'s address, and Probe 2 will be decoded against `Foo.outlined`. The sentinel probe of `Foo.outlined` makes sure there's not accidental relocation from `Foo.outlined`'s probes to `Foo`'s entry address.
On the BOLT side, to be minimal intrusive, the pseudo probe re-encoding sticks with the old encoding format. This is fine since unlike linker, Bolt processes the pseudo probe section as a whole and it is free from relocation overflow issues.
The change is downwards compatible as long as there's no mixed use of the old encoding and the new encoding.
Reviewed By: wenlei, maksfb
Differential Revision: https://reviews.llvm.org/D135912
Differential Revision: https://reviews.llvm.org/D135914
Differential Revision: https://reviews.llvm.org/D136394
More information about the All-commits
mailing list