[llvm-branch-commits] [llvm] [ctxprof] Flatten indirect call info in pre-thinlink compilation (PR #134766)

Snehasish Kumar via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 8 15:22:29 PDT 2025


================
@@ -414,6 +417,58 @@ void removeInstrumentation(Function &F) {
         I.eraseFromParent();
 }
 
+void annotateIndirectCall(
+    Module &M, CallBase &CB,
+    const DenseMap<uint32_t, FlatIndirectTargets> &FlatProf,
+    const InstrProfCallsite &Ins) {
+  auto Idx = Ins.getIndex()->getZExtValue();
+  auto FIt = FlatProf.find(Idx);
+  if (FIt == FlatProf.end())
+    return;
+  const auto &Targets = FIt->second;
+  SmallVector<InstrProfValueData, 2> Data;
+  uint64_t Sum = 0;
+  for (auto &[Guid, Count] : Targets) {
+    Data.push_back({/*.Value=*/Guid, /*.Count=*/Count});
+    Sum += Count;
+  }
+  struct InstrProfValueDataGTComparer {
----------------
snehasish wrote:

This could be an inline lambda as an argument to llvm::sort().

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


More information about the llvm-branch-commits mailing list