[llvm] [PseudoProbe] Support loading pseudo probe from debug binary (PR #175698)

Wei Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 14 11:14:47 PST 2026


================
@@ -248,24 +248,33 @@ void ProfiledBinary::load() {
   // Load debug info of subprograms from DWARF section.
   // If path of debug info binary is specified, use the debug info from it,
   // otherwise use the debug info from the executable binary.
+  OwningBinary<Binary> DebugBinary;
   if (!DebugBinaryPath.empty()) {
-    OwningBinary<Binary> DebugPath =
-        unwrapOrError(createBinary(DebugBinaryPath), DebugBinaryPath);
-    loadSymbolsFromDWARF(*cast<ObjectFile>(DebugPath.getBinary()));
+    DebugBinary = unwrapOrError(createBinary(DebugBinaryPath), DebugBinaryPath);
+    ObjectFile *DebugObj = cast<ObjectFile>(DebugBinary.getBinary());
+    loadSymbolsFromDWARF(*DebugObj);
+    checkPseudoProbe(DebugObj, DebugBinaryPath);
   } else {
-    loadSymbolsFromDWARF(*cast<ObjectFile>(&ExeBinary));
+    loadSymbolsFromDWARF(*Obj);
   }
 
+  // Try to load pseudo probe from debug binary if it exists, otherwise try to
+  // load it from binary.
+  bool IsPseudoProbeInDebugBin = usePseudoProbes();
+  if (!IsPseudoProbeInDebugBin)
+    checkPseudoProbe(Obj, Path);
+
   DisassembleFunctionSet.insert_range(DisassembleFunctions);
 
-  checkPseudoProbe(Obj);
-  if (UsePseudoProbes)
+  if (usePseudoProbes())
     populateSymbolAddressList(Obj);
 
   if (ShowDisassemblyOnly)
-    decodePseudoProbe(Obj);
+    decodePseudoProbe(IsPseudoProbeInDebugBin
----------------
apolloww wrote:

You can use `decodePseudoProbe()` since `PseudoProbeBinPath` should have been set by now. We can even get rid of `checkPseudoProbe(const object::ObjectFile *Obj)`.

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


More information about the llvm-commits mailing list