[CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.
authorHongtao Yu <hoy@fb.com>
Tue, 18 Aug 2020 23:28:47 +0000 (16:28 -0700)
committerHongtao Yu <hoy@fb.com>
Mon, 30 Nov 2020 18:16:54 +0000 (10:16 -0800)
commitc083fededfa63df6e1a560334bdb78797da9ee57
tree81ce35dfc3d27e1fc7450e4b25bde3fc5add1a53
parent64fa8cce225f7d8bd499e3a99caa850b764ff109
[CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

This change introduces a new clang switch `-fpseudo-probe-for-profiling` to enable AutoFDO with pseudo instrumentation. Please refer to https://reviews.llvm.org/D86193 for the whole story.

One implication from pseudo-probe instrumentation is that the profile is now sensitive to CFG changes. We perform the pseudo instrumentation very early in the pre-LTO pipeline, before any CFG transformation. This ensures that the CFG instrumented and annotated is stable and optimization-resilient.

The early instrumentation also allows the inliner to duplicate probes for inlined instances. When a probe along with the other instructions of a callee function are inlined into its caller function, the GUID of the callee function goes with the probe. This allows samples collected on inlined probes to be reported for the original callee function.

Reviewed By: wmi

Differential Revision: https://reviews.llvm.org/D86502
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/pseudo-probe-emit.c [new file with mode: 0644]
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp