From 32dc5b9bf134b5a98c1a22395a5cd0ca5c409fe7 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Wed, 14 Nov 2018 19:30:13 +0000 Subject: [PATCH] [ThinLTO] Update handling of vararg functions to match inliner Summary: Previously we marked all vararg functions as non-inlinable in the function summary, which prevented their importing. However, the corresponding inliner restriction was loosened in r321940/r342675 to only apply to functions calling va_start. Adjust the summary flag computation to match. Reviewers: davidxl Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D54270 llvm-svn: 346883 --- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 9 ++++++-- llvm/test/Bitcode/thinlto-function-summary.ll | 18 ++++++++++++---- .../FunctionImport/Inputs/funcimport.ll | 17 ++++++++++++--- .../Transforms/FunctionImport/funcimport.ll | 21 +++++++++++++------ 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 29b96ac746b2..f0421782b661 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -246,10 +246,15 @@ static void computeFunctionSummary( findRefEdges(Index, &F, RefEdges, Visited); bool HasInlineAsmMaybeReferencingInternal = false; + bool InitsVarArgs = false; for (const BasicBlock &BB : F) for (const Instruction &I : BB) { if (isa(I)) continue; + if (const IntrinsicInst *II = dyn_cast(&I)) { + if (II->getIntrinsicID() == Intrinsic::vastart) + InitsVarArgs = true; + } ++NumInsts; findRefEdges(Index, &I, RefEdges, Visited); auto CS = ImmutableCallSite(&I); @@ -357,9 +362,9 @@ static void computeFunctionSummary( F.hasFnAttribute(Attribute::ReadNone), F.hasFnAttribute(Attribute::ReadOnly), F.hasFnAttribute(Attribute::NoRecurse), F.returnDoesNotAlias(), - // Inliner doesn't handle variadic functions. + // Inliner doesn't handle variadic functions with va_start calls. // FIXME: refactor this to use the same code that inliner is using. - F.isVarArg() || + InitsVarArgs || // Don't try to import functions with noinline attribute. F.getAttributes().hasFnAttribute(Attribute::NoInline)}; auto FuncSummary = llvm::make_unique( diff --git a/llvm/test/Bitcode/thinlto-function-summary.ll b/llvm/test/Bitcode/thinlto-function-summary.ll index 7f59eeabd9c4..8563d127ff6e 100644 --- a/llvm/test/Bitcode/thinlto-function-summary.ll +++ b/llvm/test/Bitcode/thinlto-function-summary.ll @@ -13,18 +13,23 @@ ; BC-NEXT: