mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Added statistics to count the number of retains/releases before/after optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2088d91792
commit
fe7ea985fa
@ -303,6 +303,14 @@ STATISTIC(NumRets, "Number of return value forwarding "
|
||||
"retain+autoreleaes eliminated");
|
||||
STATISTIC(NumRRs, "Number of retain+release paths eliminated");
|
||||
STATISTIC(NumPeeps, "Number of calls peephole-optimized");
|
||||
STATISTIC(NumRetainsBeforeOpt,
|
||||
"Number of retains before optimization.");
|
||||
STATISTIC(NumReleasesBeforeOpt,
|
||||
"Number of releases before optimization.");
|
||||
STATISTIC(NumRetainsAfterOpt,
|
||||
"Number of retains after optimization.");
|
||||
STATISTIC(NumReleasesAfterOpt,
|
||||
"Number of releases after optimization.");
|
||||
|
||||
namespace {
|
||||
/// \enum Sequence
|
||||
@ -1093,6 +1101,10 @@ namespace {
|
||||
|
||||
void OptimizeReturns(Function &F);
|
||||
|
||||
#ifndef NDEBUG
|
||||
void GatherStatistics(Function &F, bool AfterOptimization = false);
|
||||
#endif
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||
virtual bool doInitialization(Module &M);
|
||||
virtual bool runOnFunction(Function &F);
|
||||
@ -1480,6 +1492,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||
break;
|
||||
// FALLTHROUGH
|
||||
case IC_Retain:
|
||||
++NumRetainsBeforeOpt;
|
||||
OptimizeRetainCall(F, Inst);
|
||||
break;
|
||||
case IC_RetainRV:
|
||||
@ -1489,6 +1502,9 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||
case IC_AutoreleaseRV:
|
||||
OptimizeAutoreleaseRVCall(F, Inst, Class);
|
||||
break;
|
||||
case IC_Release:
|
||||
++NumReleasesBeforeOpt;
|
||||
break;
|
||||
}
|
||||
|
||||
// objc_autorelease(x) -> objc_release(x) if x is otherwise unused.
|
||||
@ -3006,6 +3022,30 @@ void ObjCARCOpt::OptimizeReturns(Function &F) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void
|
||||
ObjCARCOpt::GatherStatistics(Function &F, bool AfterOptimization) {
|
||||
llvm::Statistic &NumRetains =
|
||||
AfterOptimization? NumRetainsAfterOpt : NumRetainsBeforeOpt;
|
||||
llvm::Statistic &NumReleases =
|
||||
AfterOptimization? NumReleasesAfterOpt : NumReleasesBeforeOpt;
|
||||
|
||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ) {
|
||||
Instruction *Inst = &*I++;
|
||||
switch (GetBasicInstructionClass(Inst)) {
|
||||
default:
|
||||
break;
|
||||
case IC_Retain:
|
||||
++NumRetains;
|
||||
break;
|
||||
case IC_Release:
|
||||
++NumReleases;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ObjCARCOpt::doInitialization(Module &M) {
|
||||
if (!EnableARCOpts)
|
||||
return false;
|
||||
@ -3092,6 +3132,13 @@ bool ObjCARCOpt::runOnFunction(Function &F) {
|
||||
(1 << IC_AutoreleaseRV)))
|
||||
OptimizeReturns(F);
|
||||
|
||||
// Gather statistics after optimization.
|
||||
#ifndef NDEBUG
|
||||
if (AreStatisticsEnabled()) {
|
||||
GatherStatistics(F, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUG(dbgs() << "\n");
|
||||
|
||||
return Changed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user