[llvm] 5c6d9b2 - [LTO, NFC] Skip generateParamAccessSummary when empty

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 19:01:30 PDT 2020


Author: Vitaly Buka
Date: 2020-08-06T19:01:19-07:00
New Revision: 5c6d9b2bbfafb47363b31ad06f2c21a9cc93e6ad

URL: https://github.com/llvm/llvm-project/commit/5c6d9b2bbfafb47363b31ad06f2c21a9cc93e6ad
DIFF: https://github.com/llvm/llvm-project/commit/5c6d9b2bbfafb47363b31ad06f2c21a9cc93e6ad.diff

LOG: [LTO,NFC] Skip generateParamAccessSummary when empty

addGlobalValueSummary can check newly added FunctionSummary
and set HasParamAccess to mark that generateParamAccessSummary
is needed.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D85182

Added: 
    

Modified: 
    llvm/include/llvm/IR/ModuleSummaryIndex.h
    llvm/lib/Analysis/StackSafetyAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 12a829b14e36..e78892cf83eb 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1061,6 +1061,9 @@ class ModuleSummaryIndex {
   // 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<std::string> CfiFunctionDefs;
   std::set<std::string> CfiFunctionDecls;
 
@@ -1213,6 +1216,8 @@ class ModuleSummaryIndex {
   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 @@ class ModuleSummaryIndex {
   /// Add a global value summary for the given ValueInfo.
   void addGlobalValueSummary(ValueInfo VI,
                              std::unique_ptr<GlobalValueSummary> Summary) {
+    if (const FunctionSummary *FS = dyn_cast<FunctionSummary>(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
index bcbe9a63c182..00650fca0594 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -921,6 +921,8 @@ bool llvm::needsParamAccessSummary(const Module &M) {
 }
 
 void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) {
+  if (!Index.hasParamAccess())
+    return;
   const ConstantRange FullSet(FunctionSummary::ParamAccess::RangeWidth, true);
   std::map<const FunctionSummary *, FunctionInfo<FunctionSummary>> Functions;
 


        


More information about the llvm-commits mailing list