Skip to content

Commit 038fff3

Browse files
authored
[NFC][BOLT] Make file-local cl::opt global variables static (#126472)
#125983
1 parent 75f6fe2 commit 038fff3

16 files changed

+80
-94
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ using namespace llvm;
4646

4747
namespace opts {
4848

49-
cl::opt<bool> NoHugePages("no-huge-pages",
50-
cl::desc("use regular size pages for code alignment"),
51-
cl::Hidden, cl::cat(BoltCategory));
49+
static cl::opt<bool>
50+
NoHugePages("no-huge-pages",
51+
cl::desc("use regular size pages for code alignment"),
52+
cl::Hidden, cl::cat(BoltCategory));
5253

5354
static cl::opt<bool>
5455
PrintDebugInfo("print-debug-info",

bolt/lib/Core/BinaryData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace opts {
2424
extern cl::OptionCategory BoltCategory;
2525
extern cl::opt<unsigned> Verbosity;
2626

27-
cl::opt<bool>
27+
static cl::opt<bool>
2828
PrintSymbolAliases("print-aliases",
2929
cl::desc("print aliases when printing objects"),
3030
cl::Hidden, cl::cat(BoltCategory));

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extern cl::opt<unsigned> Verbosity;
6767

6868
extern bool processAllFunctions();
6969

70-
cl::opt<bool> CheckEncoding(
70+
static cl::opt<bool> CheckEncoding(
7171
"check-encoding",
7272
cl::desc("perform verification of LLVM instruction encoding/decoding. "
7373
"Every instruction in the input is decoded and re-encoded. "
@@ -144,14 +144,11 @@ cl::opt<bool>
144144
cl::desc("print time spent constructing binary functions"),
145145
cl::Hidden, cl::cat(BoltCategory));
146146

147-
cl::opt<bool>
148-
TrapOnAVX512("trap-avx512",
149-
cl::desc("in relocation mode trap upon entry to any function that uses "
150-
"AVX-512 instructions"),
151-
cl::init(false),
152-
cl::ZeroOrMore,
153-
cl::Hidden,
154-
cl::cat(BoltCategory));
147+
static cl::opt<bool> TrapOnAVX512(
148+
"trap-avx512",
149+
cl::desc("in relocation mode trap upon entry to any function that uses "
150+
"AVX-512 instructions"),
151+
cl::init(false), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
155152

156153
bool shouldPrint(const BinaryFunction &Function) {
157154
if (Function.isIgnored())

bolt/lib/Passes/Aligner.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ extern cl::opt<bool> AlignBlocks;
2525
extern cl::opt<bool> PreserveBlocksAlignment;
2626
extern cl::opt<unsigned> AlignFunctions;
2727

28-
cl::opt<unsigned>
29-
AlignBlocksMinSize("align-blocks-min-size",
30-
cl::desc("minimal size of the basic block that should be aligned"),
31-
cl::init(0),
32-
cl::ZeroOrMore,
33-
cl::Hidden,
34-
cl::cat(BoltOptCategory));
35-
36-
cl::opt<unsigned> AlignBlocksThreshold(
28+
static cl::opt<unsigned> AlignBlocksMinSize(
29+
"align-blocks-min-size",
30+
cl::desc("minimal size of the basic block that should be aligned"),
31+
cl::init(0), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
32+
33+
static cl::opt<unsigned> AlignBlocksThreshold(
3734
"align-blocks-threshold",
3835
cl::desc(
3936
"align only blocks with frequency larger than containing function "
@@ -42,19 +39,17 @@ cl::opt<unsigned> AlignBlocksThreshold(
4239
"containing function."),
4340
cl::init(800), cl::Hidden, cl::cat(BoltOptCategory));
4441

45-
cl::opt<unsigned> AlignFunctionsMaxBytes(
42+
static cl::opt<unsigned> AlignFunctionsMaxBytes(
4643
"align-functions-max-bytes",
4744
cl::desc("maximum number of bytes to use to align functions"), cl::init(32),
4845
cl::cat(BoltOptCategory));
4946

50-
cl::opt<unsigned>
51-
BlockAlignment("block-alignment",
52-
cl::desc("boundary to use for alignment of basic blocks"),
53-
cl::init(16),
54-
cl::ZeroOrMore,
55-
cl::cat(BoltOptCategory));
47+
static cl::opt<unsigned>
48+
BlockAlignment("block-alignment",
49+
cl::desc("boundary to use for alignment of basic blocks"),
50+
cl::init(16), cl::ZeroOrMore, cl::cat(BoltOptCategory));
5651

57-
cl::opt<bool>
52+
static cl::opt<bool>
5853
UseCompactAligner("use-compact-aligner",
5954
cl::desc("Use compact approach for aligning functions"),
6055
cl::init(true), cl::cat(BoltOptCategory));

bolt/lib/Passes/FrameOptimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ FrameOptimization("frame-opt",
4343
cl::ZeroOrMore,
4444
cl::cat(BoltOptCategory));
4545

46-
cl::opt<bool> RemoveStores(
46+
static cl::opt<bool> RemoveStores(
4747
"frame-opt-rm-stores", cl::init(FOP_NONE),
4848
cl::desc("apply additional analysis to remove stores (experimental)"),
4949
cl::cat(BoltOptCategory));

bolt/lib/Passes/PLTCall.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,16 @@ namespace opts {
2222

2323
extern cl::OptionCategory BoltOptCategory;
2424

25-
cl::opt<bolt::PLTCall::OptType>
26-
PLT("plt",
27-
cl::desc("optimize PLT calls (requires linking with -znow)"),
28-
cl::init(bolt::PLTCall::OT_NONE),
29-
cl::values(clEnumValN(bolt::PLTCall::OT_NONE,
30-
"none",
31-
"do not optimize PLT calls"),
32-
clEnumValN(bolt::PLTCall::OT_HOT,
33-
"hot",
34-
"optimize executed (hot) PLT calls"),
35-
clEnumValN(bolt::PLTCall::OT_ALL,
36-
"all",
37-
"optimize all PLT calls")),
38-
cl::ZeroOrMore,
39-
cl::cat(BoltOptCategory));
40-
25+
static cl::opt<bolt::PLTCall::OptType>
26+
PLT("plt", cl::desc("optimize PLT calls (requires linking with -znow)"),
27+
cl::init(bolt::PLTCall::OT_NONE),
28+
cl::values(clEnumValN(bolt::PLTCall::OT_NONE, "none",
29+
"do not optimize PLT calls"),
30+
clEnumValN(bolt::PLTCall::OT_HOT, "hot",
31+
"optimize executed (hot) PLT calls"),
32+
clEnumValN(bolt::PLTCall::OT_ALL, "all",
33+
"optimize all PLT calls")),
34+
cl::ZeroOrMore, cl::cat(BoltOptCategory));
4135
}
4236

4337
namespace llvm {

bolt/lib/Passes/ProfileQualityStats.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ using namespace bolt;
2424

2525
namespace opts {
2626
extern cl::opt<unsigned> Verbosity;
27-
cl::opt<unsigned> TopFunctionsForProfileQualityCheck(
27+
static cl::opt<unsigned> TopFunctionsForProfileQualityCheck(
2828
"top-functions-for-profile-quality-check",
2929
cl::desc("number of hottest functions to print aggregated "
3030
"profile quality stats of."),
3131
cl::init(1000), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
32-
cl::opt<unsigned> PercentileForProfileQualityCheck(
32+
static cl::opt<unsigned> PercentileForProfileQualityCheck(
3333
"percentile-for-profile-quality-check",
3434
cl::desc("Percentile of profile quality distributions over hottest "
3535
"functions to report."),

bolt/lib/Passes/RetpolineInsertion.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@ namespace opts {
3333

3434
extern cl::OptionCategory BoltCategory;
3535

36-
llvm::cl::opt<bool> InsertRetpolines("insert-retpolines",
37-
cl::desc("run retpoline insertion pass"),
38-
cl::cat(BoltCategory));
39-
40-
llvm::cl::opt<bool>
41-
RetpolineLfence("retpoline-lfence",
42-
cl::desc("determine if lfence instruction should exist in the retpoline"),
43-
cl::init(true),
44-
cl::ZeroOrMore,
45-
cl::Hidden,
46-
cl::cat(BoltCategory));
47-
48-
cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
36+
static llvm::cl::opt<bool>
37+
InsertRetpolines("insert-retpolines",
38+
cl::desc("run retpoline insertion pass"),
39+
cl::cat(BoltCategory));
40+
41+
static llvm::cl::opt<bool> RetpolineLfence(
42+
"retpoline-lfence",
43+
cl::desc("determine if lfence instruction should exist in the retpoline"),
44+
cl::init(true), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
45+
46+
static cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
4947
"r11-availability",
5048
cl::desc("determine the availability of r11 before indirect branches"),
5149
cl::init(RetpolineInsertion::AvailabilityOptions::NEVER),

bolt/lib/Passes/StokeInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace llvm;
2121
using namespace bolt;
2222

2323
namespace opts {
24-
cl::OptionCategory StokeOptCategory("STOKE pass options");
24+
static cl::OptionCategory StokeOptCategory("STOKE pass options");
2525

2626
static cl::opt<std::string>
2727
StokeOutputDataFilename("stoke-out",

bolt/lib/Passes/TailDuplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace opts {
2626
extern cl::OptionCategory BoltOptCategory;
2727
extern cl::opt<bool> NoThreads;
2828

29-
cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
29+
static cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
3030
"tail-duplication",
3131
cl::desc("duplicate unconditional branches that cross a cache line"),
3232
cl::init(bolt::TailDuplication::TD_NONE),

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,66 +52,66 @@ cl::opt<bool>
5252
cl::desc("Infer counts from stale profile data."),
5353
cl::init(false), cl::Hidden, cl::cat(BoltOptCategory));
5454

55-
cl::opt<unsigned> StaleMatchingMinMatchedBlock(
55+
static cl::opt<unsigned> StaleMatchingMinMatchedBlock(
5656
"stale-matching-min-matched-block",
5757
cl::desc("Percentage threshold of matched basic blocks at which stale "
5858
"profile inference is executed."),
5959
cl::init(0), cl::Hidden, cl::cat(BoltOptCategory));
6060

61-
cl::opt<unsigned> StaleMatchingMaxFuncSize(
61+
static cl::opt<unsigned> StaleMatchingMaxFuncSize(
6262
"stale-matching-max-func-size",
6363
cl::desc("The maximum size of a function to consider for inference."),
6464
cl::init(10000), cl::Hidden, cl::cat(BoltOptCategory));
6565

6666
// Parameters of the profile inference algorithm. The default values are tuned
6767
// on several benchmarks.
68-
cl::opt<bool> StaleMatchingEvenFlowDistribution(
68+
static cl::opt<bool> StaleMatchingEvenFlowDistribution(
6969
"stale-matching-even-flow-distribution",
7070
cl::desc("Try to evenly distribute flow when there are multiple equally "
7171
"likely options."),
7272
cl::init(true), cl::ReallyHidden, cl::cat(BoltOptCategory));
7373

74-
cl::opt<bool> StaleMatchingRebalanceUnknown(
74+
static cl::opt<bool> StaleMatchingRebalanceUnknown(
7575
"stale-matching-rebalance-unknown",
7676
cl::desc("Evenly re-distribute flow among unknown subgraphs."),
7777
cl::init(false), cl::ReallyHidden, cl::cat(BoltOptCategory));
7878

79-
cl::opt<bool> StaleMatchingJoinIslands(
79+
static cl::opt<bool> StaleMatchingJoinIslands(
8080
"stale-matching-join-islands",
8181
cl::desc("Join isolated components having positive flow."), cl::init(true),
8282
cl::ReallyHidden, cl::cat(BoltOptCategory));
8383

84-
cl::opt<unsigned> StaleMatchingCostBlockInc(
84+
static cl::opt<unsigned> StaleMatchingCostBlockInc(
8585
"stale-matching-cost-block-inc",
8686
cl::desc("The cost of increasing a block count by one."), cl::init(150),
8787
cl::ReallyHidden, cl::cat(BoltOptCategory));
8888

89-
cl::opt<unsigned> StaleMatchingCostBlockDec(
89+
static cl::opt<unsigned> StaleMatchingCostBlockDec(
9090
"stale-matching-cost-block-dec",
9191
cl::desc("The cost of decreasing a block count by one."), cl::init(150),
9292
cl::ReallyHidden, cl::cat(BoltOptCategory));
9393

94-
cl::opt<unsigned> StaleMatchingCostJumpInc(
94+
static cl::opt<unsigned> StaleMatchingCostJumpInc(
9595
"stale-matching-cost-jump-inc",
9696
cl::desc("The cost of increasing a jump count by one."), cl::init(150),
9797
cl::ReallyHidden, cl::cat(BoltOptCategory));
9898

99-
cl::opt<unsigned> StaleMatchingCostJumpDec(
99+
static cl::opt<unsigned> StaleMatchingCostJumpDec(
100100
"stale-matching-cost-jump-dec",
101101
cl::desc("The cost of decreasing a jump count by one."), cl::init(150),
102102
cl::ReallyHidden, cl::cat(BoltOptCategory));
103103

104-
cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
104+
static cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
105105
"stale-matching-cost-block-unknown-inc",
106106
cl::desc("The cost of increasing an unknown block count by one."),
107107
cl::init(1), cl::ReallyHidden, cl::cat(BoltOptCategory));
108108

109-
cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
109+
static cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
110110
"stale-matching-cost-jump-unknown-inc",
111111
cl::desc("The cost of increasing an unknown jump count by one."),
112112
cl::init(140), cl::ReallyHidden, cl::cat(BoltOptCategory));
113113

114-
cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
114+
static cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
115115
"stale-matching-cost-jump-unknown-ft-inc",
116116
cl::desc(
117117
"The cost of increasing an unknown fall-through jump count by one."),

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern cl::OptionCategory BoltOptCategory;
2828
extern cl::opt<bool> InferStaleProfile;
2929
extern cl::opt<bool> Lite;
3030

31-
cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
31+
static cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
3232
"name-similarity-function-matching-threshold",
3333
cl::desc("Match functions using namespace and edit distance"), cl::init(0),
3434
cl::Hidden, cl::cat(BoltOptCategory));
@@ -38,11 +38,11 @@ static llvm::cl::opt<bool>
3838
cl::desc("ignore hash while reading function profile"),
3939
cl::Hidden, cl::cat(BoltOptCategory));
4040

41-
llvm::cl::opt<bool>
41+
static llvm::cl::opt<bool>
4242
MatchProfileWithFunctionHash("match-profile-with-function-hash",
4343
cl::desc("Match profile with function hash"),
4444
cl::Hidden, cl::cat(BoltOptCategory));
45-
llvm::cl::opt<bool>
45+
static llvm::cl::opt<bool>
4646
MatchWithCallGraph("match-with-call-graph",
4747
cl::desc("Match functions with call graph"), cl::Hidden,
4848
cl::cat(BoltOptCategory));

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,18 @@ extern cl::opt<bolt::IdenticalCodeFolding::ICFLevel, false,
9191
llvm::bolt::DeprecatedICFNumericOptionParser>
9292
ICF;
9393

94-
cl::opt<bool> AllowStripped("allow-stripped",
95-
cl::desc("allow processing of stripped binaries"),
96-
cl::Hidden, cl::cat(BoltCategory));
94+
static cl::opt<bool>
95+
AllowStripped("allow-stripped",
96+
cl::desc("allow processing of stripped binaries"), cl::Hidden,
97+
cl::cat(BoltCategory));
9798

9899
static cl::opt<bool> ForceToDataRelocations(
99100
"force-data-relocations",
100101
cl::desc("force relocations to data sections to always be processed"),
101102

102103
cl::Hidden, cl::cat(BoltCategory));
103104

104-
cl::opt<std::string>
105+
static cl::opt<std::string>
105106
BoltID("bolt-id",
106107
cl::desc("add any string to tag this execution in the "
107108
"output binary via bolt info section"),
@@ -175,9 +176,10 @@ cl::opt<bool> PrintAll("print-all",
175176
cl::desc("print functions after each stage"), cl::Hidden,
176177
cl::cat(BoltCategory));
177178

178-
cl::opt<bool> PrintProfile("print-profile",
179-
cl::desc("print functions after attaching profile"),
180-
cl::Hidden, cl::cat(BoltCategory));
179+
static cl::opt<bool>
180+
PrintProfile("print-profile",
181+
cl::desc("print functions after attaching profile"),
182+
cl::Hidden, cl::cat(BoltCategory));
181183

182184
cl::opt<bool> PrintCFG("print-cfg",
183185
cl::desc("print functions after CFG construction"),
@@ -218,11 +220,10 @@ SkipFunctionNamesFile("skip-funcs-file",
218220
cl::Hidden,
219221
cl::cat(BoltCategory));
220222

221-
cl::opt<bool>
222-
TrapOldCode("trap-old-code",
223-
cl::desc("insert traps in old function bodies (relocation mode)"),
224-
cl::Hidden,
225-
cl::cat(BoltCategory));
223+
static cl::opt<bool> TrapOldCode(
224+
"trap-old-code",
225+
cl::desc("insert traps in old function bodies (relocation mode)"),
226+
cl::Hidden, cl::cat(BoltCategory));
226227

227228
static cl::opt<std::string> DWPPathName("dwp",
228229
cl::desc("Path and name to DWP file."),

bolt/tools/bat-dump/bat-dump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using namespace bolt;
3939

4040
namespace opts {
4141

42-
cl::OptionCategory BatDumpCategory("BAT dump options");
42+
static cl::OptionCategory BatDumpCategory("BAT dump options");
4343

4444
static cl::OptionCategory *BatDumpCategories[] = {&BatDumpCategory};
4545

bolt/tools/driver/llvm-bolt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BoltProfile("b",
6363
cl::aliasopt(InputDataFilename),
6464
cl::cat(BoltCategory));
6565

66-
cl::opt<std::string>
66+
static cl::opt<std::string>
6767
LogFile("log-file",
6868
cl::desc("redirect journaling to a file instead of stdout/stderr"),
6969
cl::Hidden, cl::cat(BoltCategory));

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace llvm::yaml::bolt;
3131

3232
namespace opts {
3333

34-
cl::OptionCategory MergeFdataCategory("merge-fdata options");
34+
static cl::OptionCategory MergeFdataCategory("merge-fdata options");
3535

3636
enum SortType : char {
3737
ST_NONE,

0 commit comments

Comments
 (0)