[PATCH] D104161: [NFC] [DwarfEHPrepare] Add additional stats for EH

Di Mo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 19:16:25 PDT 2021


modimo updated this revision to Diff 352032.
modimo edited the summary of this revision.
modimo added a comment.

Review comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104161/new/

https://reviews.llvm.org/D104161

Files:
  llvm/lib/CodeGen/DwarfEHPrepare.cpp


Index: llvm/lib/CodeGen/DwarfEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/DwarfEHPrepare.cpp
+++ llvm/lib/CodeGen/DwarfEHPrepare.cpp
@@ -42,6 +42,11 @@
 #define DEBUG_TYPE "dwarfehprepare"
 
 STATISTIC(NumResumesLowered, "Number of resume calls lowered");
+STATISTIC(NumCleanupLandingPadsUnreachable,
+          "Number of cleanup landing pads found unreachable");
+STATISTIC(NumCleanupLandingPadsRemaining, "Number of cleanup landing pads remaining");
+STATISTIC(NumNoUnwind, "Number of functions with nounwind");
+STATISTIC(NumUnwind, "Number of functions with unwind");
 
 namespace {
 
@@ -163,6 +168,10 @@
 bool DwarfEHPrepare::InsertUnwindResumeCalls() {
   SmallVector<ResumeInst *, 16> Resumes;
   SmallVector<LandingPadInst *, 16> CleanupLPads;
+  if (F.doesNotThrow())
+    NumNoUnwind++;
+  else
+    NumUnwind++;
   for (BasicBlock &BB : F) {
     if (auto *RI = dyn_cast<ResumeInst>(BB.getTerminator()))
       Resumes.push_back(RI);
@@ -171,6 +180,8 @@
         CleanupLPads.push_back(LP);
   }
 
+  NumCleanupLandingPadsRemaining += CleanupLPads.size();
+
   if (Resumes.empty())
     return false;
 
@@ -182,8 +193,19 @@
   LLVMContext &Ctx = F.getContext();
 
   size_t ResumesLeft = Resumes.size();
-  if (OptLevel != CodeGenOpt::None)
+  if (OptLevel != CodeGenOpt::None) {
     ResumesLeft = pruneUnreachableResumes(Resumes, CleanupLPads);
+#if LLVM_ENABLE_STATS
+    unsigned NumRemainingLPs = 0;
+    for (BasicBlock &BB : F) {
+      if (auto *LP = BB.getLandingPadInst())
+        if (LP->isCleanup())
+          NumRemainingLPs++;
+    }
+    NumCleanupLandingPadsUnreachable += CleanupLPads.size() - NumRemainingLPs;
+    NumCleanupLandingPadsRemaining -= CleanupLPads.size() - NumRemainingLPs;
+#endif
+  }
 
   if (ResumesLeft == 0)
     return true; // We pruned them all.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104161.352032.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210615/b2020501/attachment.bin>


More information about the llvm-commits mailing list