[llvm] [MemProf] Don't skip direct recursion in function summary (PR #78264)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 03:56:39 PST 2024


https://github.com/lifengxiang1025 created https://github.com/llvm/llvm-project/pull/78264

I met one assert in `MemProfContextDisambiguation::applyImport` because metadata doesn't match summary. The reason is function summary skip direct recursion but metadata donen't.

>From 6abc0d937836ea9c318fa9eec86190abe1e90bd9 Mon Sep 17 00:00:00 2001
From: lifengxiang <lifengxiang.1025 at bytedance.com>
Date: Tue, 16 Jan 2024 17:58:28 +0800
Subject: [PATCH] [MemProf] Don't skip direct recursion in function summary

---
 llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 1f15e94783240a..7e09192c5f1d51 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -499,11 +499,7 @@ static void computeFunctionSummary(
                    StackContext.beginAfterSharedPrefix(InstCallsite);
                ContextIter != StackContext.end(); ++ContextIter) {
             unsigned StackIdIdx = Index.addOrGetStackIdIndex(*ContextIter);
-            // If this is a direct recursion, simply skip the duplicate
-            // entries. If this is mutual recursion, handling is left to
-            // the LTO link analysis client.
-            if (StackIdIndices.empty() || StackIdIndices.back() != StackIdIdx)
-              StackIdIndices.push_back(StackIdIdx);
+            StackIdIndices.push_back(StackIdIdx);
           }
           MIBs.push_back(
               MIBInfo(getMIBAllocType(MIBMD), std::move(StackIdIndices)));



More information about the llvm-commits mailing list