[llvm] [BOLT] Profile quality stats -- CFG discontinuity (PR #109683)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 18:23:27 PDT 2024
================
@@ -0,0 +1,288 @@
+//===- bolt/Passes/ContinuityStats.cpp - function cfg continuity analysis ---*-
+// C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Conduct function CFG continuity analysis.
+//
+//===----------------------------------------------------------------------===//
+
+#include "bolt/Passes/ContinuityStats.h"
+#include "bolt/Core/BinaryBasicBlock.h"
+#include "bolt/Core/BinaryFunction.h"
+#include "bolt/Utils/CommandLineOpts.h"
+#include "llvm/Support/CommandLine.h"
+#include <queue>
+#include <unordered_map>
+#include <unordered_set>
+
+#define DEBUG_TYPE "bolt-opts"
+
+using namespace llvm;
+using namespace bolt;
+
+namespace opts {
+extern cl::opt<unsigned> Verbosity;
+cl::opt<unsigned>
+ NumTopFunctions("num-top-functions",
+ cl::desc("number of hottest functions to print aggregated "
+ "CFG discontinuity stats of."),
+ cl::init(1000), cl::ZeroOrMore, cl::Hidden,
+ cl::cat(BoltOptCategory));
+cl::opt<bool>
+ PrintBucketedStats("print-bucketed-stats",
+ cl::desc("print CFG discontinuity stats for the top "
+ "functions divided into buckets "
+ "based on their execution counts."),
+ cl::Hidden, cl::cat(BoltCategory));
+cl::opt<unsigned>
+ NumFunctionsPerBucket("num-functions-per-bucket",
+ cl::desc("maximum number of functions per bucket."),
+ cl::init(500), cl::ZeroOrMore, cl::Hidden,
+ cl::cat(BoltOptCategory));
+cl::opt<unsigned>
+ MinNumFunctions("min-num-functions",
+ cl::desc("minimum number of hot functions in the binary to "
+ "trigger profile CFG continuity check."),
+ cl::init(5), cl::ZeroOrMore, cl::Hidden,
+ cl::cat(BoltOptCategory));
----------------
maksfb wrote:
That's a lot of pass-specific options that are sharing the global option namespace. Option names like "--num-top-functions" and "--min-num-functions" are ambiguous when taken out of the continuity context.
Rather then make these options pass-specific, I suggest we print the data they control under "-v=1". WDYT?
https://github.com/llvm/llvm-project/pull/109683
More information about the llvm-commits
mailing list