[PATCH] D85182: [LTO,NFC] Skip generateParamAccessSummary when empty

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 01:01:27 PDT 2020


vitalybuka created this revision.
vitalybuka added a reviewer: tejohnson.
Herald added subscribers: llvm-commits, arphaman, dexonsmith, hiraditya, inglorion.
Herald added a project: LLVM.
vitalybuka requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85182

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


Index: llvm/lib/Analysis/StackSafetyAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ 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<const FunctionSummary *, FunctionInfo<FunctionSummary>> Functions;
 
Index: llvm/include/llvm/IR/ModuleSummaryIndex.h
===================================================================
--- llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ 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<std::string> CfiFunctionDefs;
   std::set<std::string> 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,9 @@
   /// Add a global value summary for the given ValueInfo.
   void addGlobalValueSummary(ValueInfo VI,
                              std::unique_ptr<GlobalValueSummary> Summary) {
+    if (!HasParamAccess)
+      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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85182.282819.patch
Type: text/x-patch
Size: 1951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200804/9dc7430a/attachment.bin>


More information about the llvm-commits mailing list