Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / lib / Utils / CommandLineOpts.cpp
blob19680fa945dbc0336b50e8956757dbaa2dd90120
1 //===- bolt/Utils/CommandLineOpts.cpp - BOLT CLI options ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // BOLT CLI options
11 //===----------------------------------------------------------------------===//
13 #include "bolt/Utils/CommandLineOpts.h"
14 #include "llvm/Support/VCSRevision.h"
16 using namespace llvm;
18 namespace llvm {
19 namespace bolt {
20 const char *BoltRevision =
21 #ifdef LLVM_REVISION
22 LLVM_REVISION;
23 #else
24 "<unknown>";
25 #endif
29 namespace opts {
31 bool HeatmapMode = false;
32 bool LinuxKernelMode = false;
34 cl::OptionCategory BoltCategory("BOLT generic options");
35 cl::OptionCategory BoltDiffCategory("BOLTDIFF generic options");
36 cl::OptionCategory BoltOptCategory("BOLT optimization options");
37 cl::OptionCategory BoltRelocCategory("BOLT options in relocation mode");
38 cl::OptionCategory BoltOutputCategory("Output options");
39 cl::OptionCategory AggregatorCategory("Data aggregation options");
40 cl::OptionCategory BoltInstrCategory("BOLT instrumentation options");
41 cl::OptionCategory HeatmapCategory("Heatmap options");
43 cl::opt<unsigned> AlignText("align-text",
44 cl::desc("alignment of .text section"), cl::Hidden,
45 cl::cat(BoltCategory));
47 cl::opt<unsigned> AlignFunctions(
48 "align-functions",
49 cl::desc("align functions at a given value (relocation mode)"),
50 cl::init(64), cl::cat(BoltOptCategory));
52 cl::opt<bool>
53 AggregateOnly("aggregate-only",
54 cl::desc("exit after writing aggregated data file"),
55 cl::Hidden,
56 cl::cat(AggregatorCategory));
58 cl::opt<unsigned>
59 BucketsPerLine("line-size",
60 cl::desc("number of entries per line (default 256)"),
61 cl::init(256), cl::Optional, cl::cat(HeatmapCategory));
63 cl::opt<bool>
64 DiffOnly("diff-only",
65 cl::desc("stop processing once we have enough to compare two binaries"),
66 cl::Hidden,
67 cl::cat(BoltDiffCategory));
69 cl::opt<bool>
70 EnableBAT("enable-bat",
71 cl::desc("write BOLT Address Translation tables"),
72 cl::init(false),
73 cl::ZeroOrMore,
74 cl::cat(BoltCategory));
76 cl::opt<bool> EqualizeBBCounts(
77 "equalize-bb-counts",
78 cl::desc("use same count for BBs that should have equivalent count (used "
79 "in non-LBR and shrink wrapping)"),
80 cl::ZeroOrMore, cl::init(false), cl::Hidden, cl::cat(BoltOptCategory));
82 cl::opt<bool> RemoveSymtab("remove-symtab", cl::desc("Remove .symtab section"),
83 cl::cat(BoltCategory));
85 cl::opt<unsigned>
86 ExecutionCountThreshold("execution-count-threshold",
87 cl::desc("perform profiling accuracy-sensitive optimizations only if "
88 "function execution count >= the threshold (default: 0)"),
89 cl::init(0),
90 cl::ZeroOrMore,
91 cl::Hidden,
92 cl::cat(BoltOptCategory));
94 cl::opt<unsigned>
95 HeatmapBlock("block-size",
96 cl::desc("size of a heat map block in bytes (default 64)"),
97 cl::init(64), cl::cat(HeatmapCategory));
99 cl::opt<unsigned long long> HeatmapMaxAddress(
100 "max-address", cl::init(0xffffffff),
101 cl::desc("maximum address considered valid for heatmap (default 4GB)"),
102 cl::Optional, cl::cat(HeatmapCategory));
104 cl::opt<unsigned long long> HeatmapMinAddress(
105 "min-address", cl::init(0x0),
106 cl::desc("minimum address considered valid for heatmap (default 0)"),
107 cl::Optional, cl::cat(HeatmapCategory));
109 cl::opt<bool> HotData("hot-data",
110 cl::desc("hot data symbols support (relocation mode)"),
111 cl::cat(BoltCategory));
113 cl::opt<bool> HotFunctionsAtEnd(
114 "hot-functions-at-end",
115 cl::desc(
116 "if reorder-functions is used, order functions putting hottest last"),
117 cl::cat(BoltCategory));
119 cl::opt<bool> HotText(
120 "hot-text",
121 cl::desc(
122 "Generate hot text symbols. Apply this option to a precompiled binary "
123 "that manually calls into hugify, such that at runtime hugify call "
124 "will put hot code into 2M pages. This requires relocation."),
125 cl::ZeroOrMore, cl::cat(BoltCategory));
127 cl::opt<bool>
128 Instrument("instrument",
129 cl::desc("instrument code to generate accurate profile data"),
130 cl::cat(BoltOptCategory));
132 cl::opt<std::string>
133 OutputFilename("o",
134 cl::desc("<output file>"),
135 cl::Optional,
136 cl::cat(BoltOutputCategory));
138 cl::opt<std::string> PerfData("perfdata", cl::desc("<data file>"), cl::Optional,
139 cl::cat(AggregatorCategory),
140 cl::sub(cl::SubCommand::getAll()));
142 static cl::alias
143 PerfDataA("p",
144 cl::desc("alias for -perfdata"),
145 cl::aliasopt(PerfData),
146 cl::cat(AggregatorCategory));
148 cl::opt<bool> PrintCacheMetrics(
149 "print-cache-metrics",
150 cl::desc("calculate and print various metrics for instruction cache"),
151 cl::cat(BoltOptCategory));
153 cl::opt<bool> PrintSections("print-sections",
154 cl::desc("print all registered sections"),
155 cl::Hidden, cl::cat(BoltCategory));
157 cl::opt<ProfileFormatKind> ProfileFormat(
158 "profile-format",
159 cl::desc(
160 "format to dump profile output in aggregation mode, default is fdata"),
161 cl::init(PF_Fdata),
162 cl::values(clEnumValN(PF_Fdata, "fdata", "offset-based plaintext format"),
163 clEnumValN(PF_YAML, "yaml", "dense YAML reprensentation")),
164 cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
166 cl::opt<bool> SplitEH("split-eh", cl::desc("split C++ exception handling code"),
167 cl::Hidden, cl::cat(BoltOptCategory));
169 cl::opt<bool>
170 StrictMode("strict",
171 cl::desc("trust the input to be from a well-formed source"),
173 cl::cat(BoltCategory));
175 cl::opt<bool> TimeOpts("time-opts",
176 cl::desc("print time spent in each optimization"),
177 cl::cat(BoltOptCategory));
179 cl::opt<bool> UseOldText(
180 "use-old-text",
181 cl::desc("re-use space in old .text if possible (relocation mode)"),
182 cl::cat(BoltCategory));
184 cl::opt<bool> UpdateDebugSections(
185 "update-debug-sections",
186 cl::desc("update DWARF debug sections of the executable"),
187 cl::cat(BoltCategory));
189 cl::opt<unsigned>
190 Verbosity("v", cl::desc("set verbosity level for diagnostic output"),
191 cl::init(0), cl::ZeroOrMore, cl::cat(BoltCategory),
192 cl::sub(cl::SubCommand::getAll()));
194 bool processAllFunctions() {
195 if (opts::AggregateOnly)
196 return false;
198 if (UseOldText || StrictMode)
199 return true;
201 return false;
204 } // namespace opts