[PATCH] D104161: [NFC] [DwarfEHPrepare] Add additional stats for EH
Di Mo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 17:07:46 PDT 2021
modimo created this revision.
modimo added reviewers: wenlei, lebedev.ri, nikic.
Herald added subscribers: hoy, lxfind, hiraditya.
modimo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Stats added:
1. NumFunctionsProcessed: baseline to compare against
2. NumCleanupLandingPads/NumCleanupLandingPadsUnreachable: how many cleanup landing pads exist/how many were optimized as unreachable
3. NumNoUnwind: Number of functions with nounwind attribute
DwarfEHPrepare is always run a single time as part of `TargetPassConfig::addISelPasses()` which makes it an ideal place near the end of the pipeline to record this information.
Example output from clang built with exceptions:
"dwarfehprepare.NumCleanupLandingPads": 214916,
"dwarfehprepare.NumFunctionsProcessed": 630099,
"dwarfehprepare.NumNoUnwind": 299357,
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(NumFunctionsProcessed, "Number of functions processed");
+STATISTIC(NumCleanupLandingPads, "Number of cleanup landing pads in program");
+STATISTIC(NumCleanupLandingPadsUnreachable,
+ "Number of cleanup landing pads found unreachable");
+STATISTIC(NumNoUnwind, "Number of functions with nounwind");
namespace {
@@ -163,6 +168,9 @@
bool DwarfEHPrepare::InsertUnwindResumeCalls() {
SmallVector<ResumeInst *, 16> Resumes;
SmallVector<LandingPadInst *, 16> CleanupLPads;
+ NumFunctionsProcessed++;
+ if (F.doesNotThrow())
+ NumNoUnwind++;
for (BasicBlock &BB : F) {
if (auto *RI = dyn_cast<ResumeInst>(BB.getTerminator()))
Resumes.push_back(RI);
@@ -171,6 +179,8 @@
CleanupLPads.push_back(LP);
}
+ NumCleanupLandingPads += CleanupLPads.size();
+
if (Resumes.empty())
return false;
@@ -182,8 +192,18 @@
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;
+#endif
+ }
if (ResumesLeft == 0)
return true; // We pruned them all.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104161.351591.patch
Type: text/x-patch
Size: 1776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210612/5e44634b/attachment.bin>
More information about the llvm-commits
mailing list