From 6264288d70610c40256f96f003e14ab5e8890fb8 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Fri, 18 Oct 2024 10:12:23 -0700 Subject: [MemProf] Fix the option to disable memprof ICP (#112917) The -enable-memprof-indirect-call-support meant to guard the recently added memprof ICP support was not used in enough places. Specifically, it was not checked in mayHaveMemprofSummary, which is called from the ThinLTO backend applyImports. This led to failures when checking the callsite records, as we incorrectly expected records for indirect calls. Fix the option to be checked in all necessary locations, and add testing. --- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp') diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 1bd9ee6..0f4e85f 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -503,6 +503,10 @@ static void computeFunctionSummary( if (!IsThinLTO) continue; + // Skip indirect calls if we haven't enabled memprof ICP. + if (!CalledFunction && !EnableMemProfIndirectCallSupport) + continue; + // Ensure we keep this analysis in sync with the handling in the ThinLTO // backend (see MemProfContextDisambiguation::applyImport). Save this call // so that we can skip it in checking the reverse case later. @@ -561,7 +565,8 @@ static void computeFunctionSummary( auto CalleeValueInfo = Index.getOrInsertValueInfo(cast(CalledValue)); Callsites.push_back({CalleeValueInfo, StackIdIndices}); - } else if (EnableMemProfIndirectCallSupport) { + } else { + assert(EnableMemProfIndirectCallSupport); // For indirect callsites, create multiple Callsites, one per target. // This enables having a different set of clone versions per target, // and we will apply the cloning decisions while speculatively @@ -1223,6 +1228,9 @@ bool llvm::mayHaveMemprofSummary(const CallBase *CB) { if (CI && CalledFunction->isIntrinsic()) return false; } else { + // Skip indirect calls if we haven't enabled memprof ICP. + if (!EnableMemProfIndirectCallSupport) + return false; // Skip inline assembly calls. if (CI && CI->isInlineAsm()) return false; -- cgit v1.1