[llvm] [BOLT] Profile quality stats -- CFG discontinuity (PR #109683)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 3 09:06:13 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));
----------------
ShatianWang wrote:
I removed all but "-num-top-functions" and changed its name to "-num-functions-for-continuity-check" to make it more descriptive. As suggested, whether or not to print bucketed stats is now controlled by `-v`.
https://github.com/llvm/llvm-project/pull/109683
More information about the llvm-commits
mailing list