diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -1061,6 +1061,9 @@ // some were not. Set when the combined index is created during the thin link. bool PartiallySplitLTOUnits = false; + /// True if some of the FunctionSummary contains a ParamAccess. + bool HasParamAccess = false; + std::set CfiFunctionDefs; std::set CfiFunctionDecls; @@ -1213,6 +1216,8 @@ bool partiallySplitLTOUnits() const { return PartiallySplitLTOUnits; } void setPartiallySplitLTOUnits() { PartiallySplitLTOUnits = true; } + bool hasParamAccess() const { return HasParamAccess; } + bool isGlobalValueLive(const GlobalValueSummary *GVS) const { return !WithGlobalValueDeadStripping || GVS->isLive(); } @@ -1284,6 +1289,8 @@ /// Add a global value summary for the given ValueInfo. void addGlobalValueSummary(ValueInfo VI, std::unique_ptr Summary) { + if (const FunctionSummary *FS = dyn_cast(Summary.get())) + HasParamAccess |= !FS->paramAccesses().empty(); addOriginalName(VI.getGUID(), Summary->getOriginalName()); // Here we have a notionally const VI, but the value it points to is owned // by the non-const *this. diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp --- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp +++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp @@ -921,6 +921,8 @@ } void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) { + if (!Index.hasParamAccess()) + return; const ConstantRange FullSet(FunctionSummary::ParamAccess::RangeWidth, true); std::map> Functions;