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

Zequan Wu via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 08:14:40 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")));
----------------
ZequanWu wrote:

Because `-profile-correlate=binary` (though not added in this patch yet) will be used by `TargetLoweringObjectFileImpl.cpp`, if keeping those flags definitions in `InstrProfiling.cpp`, I got a linker error:
```
ld.lld: error: undefined symbol: llvm::ProfileCorrelate
>>> referenced by TargetLoweringObjectFileImpl.cpp
>>>               TargetLoweringObjectFileImpl.cpp.o:(selectExplicitSectionGlobal(llvm::GlobalObject const*, llvm::SectionKind, llvm::TargetMachine const&, llvm::MCContext&, llvm::Mangler&, unsigned int&, bool, bool)) in archive lib/libLLVMCodeGen.a
```

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


More information about the cfe-commits mailing list