Skip to content

Commit c03e651

Browse files
committed
[BOLT] Add skip-non-simple for boltdiff
Extra filtering for boltdiff, excluding non-simple functions from comparison. Reviewed By: #bolt, maksfb Differential Revision: https://reviews.llvm.org/D151510
1 parent 76647fc commit c03e651

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

bolt/lib/Rewrite/BoltDiff.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ static cl::opt<bool> NormalizeByBin1(
8383
"collection time and sampling rate for this to make sense"),
8484
cl::cat(BoltDiffCategory));
8585

86+
static cl::opt<bool>
87+
SkipNonSimple("skip-non-simple",
88+
cl::desc("skip non-simple functions in reporting"),
89+
cl::ReallyHidden, cl::cat(BoltDiffCategory));
90+
8691
} // end namespace opts
8792

8893
namespace llvm {
@@ -428,8 +433,10 @@ class RewriteInstanceDiff {
428433
llvm::make_second_range(llvm::reverse(LargestDiffs))) {
429434
const double Score2 = getNormalizedScore(*BB2, RI2);
430435
const double Score1 = getNormalizedScore(*BBMap[BB2], RI1);
431-
outs() << "BB " << BB2->getName() << " from "
432-
<< BBToFuncMap[BB2]->getDemangledName()
436+
const BinaryFunction *Func = BBToFuncMap[BB2];
437+
if (opts::SkipNonSimple && !Func->isSimple())
438+
continue;
439+
outs() << "BB " << BB2->getName() << " from " << Func->getDemangledName()
433440
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
434441
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
435442
outs() << "%\t(Difference: ";
@@ -460,9 +467,12 @@ class RewriteInstanceDiff {
460467
EdgeTy &Edge1 = EI.second;
461468
const double Score2 = std::get<2>(Edge2);
462469
const double Score1 = std::get<2>(Edge1);
470+
const BinaryFunction *Func = BBToFuncMap[std::get<0>(Edge2)];
471+
if (opts::SkipNonSimple && !Func->isSimple())
472+
continue;
463473
outs() << "Edge (" << std::get<0>(Edge2)->getName() << " -> "
464474
<< std::get<1>(Edge2)->getName() << ") in "
465-
<< BBToFuncMap[std::get<0>(Edge2)]->getDemangledName()
475+
<< Func->getDemangledName()
466476
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
467477
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
468478
outs() << "%\t(Difference: ";
@@ -537,6 +547,8 @@ class RewriteInstanceDiff {
537547
Score2 = LTOAggregatedScore2[Iter2->second];
538548
if (Score1 == 0.0 || Score2 == 0.0)
539549
continue;
550+
if (opts::SkipNonSimple && !Func1->isSimple() && !Func2->isSimple())
551+
continue;
540552
LargestDiffs.insert(
541553
std::make_pair<>(std::abs(Score1 - Score2), MapEntry));
542554
ScoreMap[Func2] = std::make_pair<>(Score1, Score2);

0 commit comments

Comments
 (0)