[clang] [Profile] Refactor profile correlation. (PR #69656)

Ellis Hoag via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 11:42:31 PDT 2023


================
@@ -24,15 +24,38 @@
 
 using namespace llvm;
 
-/// Get the __llvm_prf_cnts section.
-Expected<object::SectionRef> getCountersSection(const object::ObjectFile &Obj) {
+namespace llvm {
+// Deprecated. Use -profile-correlate=debug-info.
+cl::opt<bool> DebugInfoCorrelate(
+    "debug-info-correlate",
+    cl::desc("Use debug info to correlate profiles (Deprecated). Use "
+             "-profile-correlate=debug-info instead."),
+    cl::init(false));
+
+cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate(
+    "profile-correlate",
+    cl::desc("Use debug info or binary file to correlate profiles."),
+    cl::init(InstrProfCorrelator::NONE),
+    cl::values(clEnumValN(InstrProfCorrelator::NONE, "",
+                          "No profile correlation"),
+               clEnumValN(InstrProfCorrelator::DEBUG_INFO, "debug-info",
+                          "Use debug info to correlate")));
----------------
ellishg wrote:

I guess the root of the problem is that `Instrumentation` depends on `ProfileData`, so we can't have `InstrProfCorrelator.cpp` use a symbol defined in `Instrumentation`. That is unfortunate because `-debug-info-correlate` (`-profile-correlate=debug-info`) is a codegen flag while `InstrProfCorrelator.cpp` is primarily used by `llvm-prodata` which will not use `-debug-info-correlate`.

I really think `-debug-info-correlate` does not belong in `InstrProfCorrelator.cpp`. I'm fine with keeping `InstrProfCorrelator::ProfCorrelatorKind` in this file, but the the flags should stay in `InstrProfiling.cpp` and if needed we can pass `ProfCorrelatorKind` as a parameter.

https://github.com/llvm/llvm-project/pull/69656


More information about the cfe-commits mailing list