Add `-use-dwarf-correlation` switch to allow llvm-profgen to generate AutoFDO profile for binaries built with CSSPGO (pseudo-probe).
Differential Revision: https://reviews.llvm.org/D111776
--- /dev/null
+; RUN: llvm-profgen --format=text --ignore-stack-samples --use-dwarf-correlation --perfscript=%S/Inputs/inline-cs-pseudoprobe.perfscript --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --profile-summary-cold-count=0
+; RUN: FileCheck %s --input-file %t
+
+; CHECK: main:295:0
+; CHECK-NEXT: 0: 0
+; CHECK-NEXT: 2: 0
+; CHECK-NEXT: 1: foo:295
+; CHECK-NEXT: 2: 14
+; CHECK-NEXT: 3: 15
+; CHECK-NEXT: 4: 0
+; CHECK-NEXT: 3: bar:84
+; CHECK-NEXT: 1: 14
+
+
+; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
+; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls
+; -g test.c -o a.out
+
+#include <stdio.h>
+
+int bar(int x, int y) {
+ if (x % 3) {
+ return x - y;
+ }
+ return x + y;
+}
+
+void foo() {
+ int s, i = 0;
+ while (i++ < 4000 * 4000)
+ if (i % 91) s = bar(i, s); else s += 30;
+ printf("sum is %d\n", s);
+}
+
+int main() {
+ foo();
+ return 0;
+}
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe.perfscript --binary=%S/Inputs/inline-noprobe.perfbin --output=%t --skip-symbolization
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-RAW-PROFILE
+; RUN: llvm-profgen --format=text --use-dwarf-correlation --perfscript=%S/Inputs/inline-noprobe.perfscript --binary=%S/Inputs/inline-noprobe.perfbin --output=%t --skip-symbolization
+; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-RAW-PROFILE
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe.perfscript --binary=%S/Inputs/inline-noprobe.perfbin --output=%t
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK
+; RUN: llvm-profgen --format=text --use-dwarf-correlation --perfscript=%S/Inputs/inline-noprobe.perfscript --binary=%S/Inputs/inline-noprobe.perfbin --output=%t
+; RUN: FileCheck %s --input-file %t --check-prefix=CHECK
CHECK: main:669:0
CHECK: 0: 0
#define DEBUG_TYPE "perf-reader"
-static cl::opt<bool> ShowMmapEvents("show-mmap-events", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
- cl::desc("Print binary load events."));
-
-cl::opt<bool> SkipSymbolization("skip-symbolization", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
+cl::opt<bool> SkipSymbolization("skip-symbolization", cl::init(false),
+ cl::ZeroOrMore,
cl::desc("Dump the unsymbolized profile to the "
"output file. It will show unwinder "
"output for CS profile generation."));
-cl::opt<bool> UseOffset("use-offset", cl::ReallyHidden, cl::init(true),
- cl::ZeroOrMore,
- cl::desc("Work with `--skip-symbolization` to dump the "
- "offset instead of virtual address."));
-cl::opt<bool>
- IgnoreStackSamples("ignore-stack-samples", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
+
+static cl::opt<bool> ShowMmapEvents("show-mmap-events", cl::init(false),
+ cl::ZeroOrMore,
+ cl::desc("Print binary load events."));
+
+static cl::opt<bool>
+ UseOffset("use-offset", cl::init(true), cl::ZeroOrMore,
+ cl::desc("Work with `--skip-symbolization` to dump the "
+ "offset instead of virtual address."));
+static cl::opt<bool>
+ IgnoreStackSamples("ignore-stack-samples", cl::init(false), cl::ZeroOrMore,
cl::desc("Ignore call stack samples for hybrid samples "
"and produce context-insensitive profile."));
using namespace llvm;
using namespace sampleprof;
-cl::opt<bool> ShowDisassemblyOnly("show-disassembly-only", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
+cl::opt<bool> ShowDisassemblyOnly("show-disassembly-only", cl::init(false),
+ cl::ZeroOrMore,
cl::desc("Print disassembled code."));
-cl::opt<bool> ShowSourceLocations("show-source-locations", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
+cl::opt<bool> ShowSourceLocations("show-source-locations", cl::init(false),
+ cl::ZeroOrMore,
cl::desc("Print source locations."));
-cl::opt<bool> ShowCanonicalFnName("show-canonical-fname", cl::ReallyHidden,
- cl::init(false), cl::ZeroOrMore,
- cl::desc("Print canonical function name."));
+static cl::opt<bool>
+ ShowCanonicalFnName("show-canonical-fname", cl::init(false), cl::ZeroOrMore,
+ cl::desc("Print canonical function name."));
-cl::opt<bool> ShowPseudoProbe(
- "show-pseudo-probe", cl::ReallyHidden, cl::init(false), cl::ZeroOrMore,
+static cl::opt<bool> ShowPseudoProbe(
+ "show-pseudo-probe", cl::init(false), cl::ZeroOrMore,
cl::desc("Print pseudo probe section and disassembled info."));
+static cl::opt<bool> UseDwarfCorrelation(
+ "use-dwarf-correlation", cl::init(false), cl::ZeroOrMore,
+ cl::desc("Use dwarf for profile correlation even when binary contains "
+ "pseudo probe."));
+
static cl::list<std::string> DisassembleFunctions(
"disassemble-functions", cl::CommaSeparated,
cl::desc("List of functions to print disassembly for. Accept demangled "
}
void ProfiledBinary::decodePseudoProbe(const ELFObjectFileBase *Obj) {
+ if (UseDwarfCorrelation)
+ return;
+
StringRef FileName = Obj->getFileName();
for (section_iterator SI = Obj->section_begin(), SE = Obj->section_end();
SI != SE; ++SI) {