mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[NFC] [DwarfEHPrepare] Add additional stats for EH
Stats added: 1. NumCleanupLandingPadsUnreachable: how many cleanup landing pads were optimized as unreachable 1. NumCleanupLandingPadsRemaining: how many cleanup landing pads remain 1. NumNoUnwind: Number of functions with nounwind attribute 1. NumUnwind: Number of functions with unwind 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 cumulative during thinLTO backend (NumCleanupLandingPadsUnreachable was not incremented): "dwarfehprepare.NumCleanupLandingPadsRemaining": 123660, "dwarfehprepare.NumNoUnwind": 323836, "dwarfehprepare.NumUnwind": 472893, Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D104161
This commit is contained in:
parent
27175210c1
commit
e702056af0
@ -42,6 +42,12 @@ using namespace llvm;
|
||||
#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 +169,10 @@ size_t DwarfEHPrepare::pruneUnreachableResumes(
|
||||
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 +181,8 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
|
||||
CleanupLPads.push_back(LP);
|
||||
}
|
||||
|
||||
NumCleanupLandingPadsRemaining += CleanupLPads.size();
|
||||
|
||||
if (Resumes.empty())
|
||||
return false;
|
||||
|
||||
@ -182,8 +194,19 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user