Skip to content

Add static to command line option (cl::opt) #126243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

chrisPyr
Copy link
Contributor

@chrisPyr chrisPyr commented Feb 7, 2025

Copy link

github-actions bot commented Feb 7, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra lldb backend:ARM backend:AArch64 backend:AMDGPU backend:Hexagon backend:WebAssembly backend:X86 clangd mlir:core MLIR Core Infrastructure tablegen debuginfo llvm:globalisel vectorizers PGO Profile Guided Optimizations mlir BOLT flang Flang issues not falling into any other category LTO Link time optimization (regular/full LTO or ThinLTO) llvm:support labels Feb 7, 2025
@llvmbot llvmbot added the offload label Feb 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-offload
@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-pgo
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-lto
@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-backend-aarch64
@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-clang

Author: None (chrisPyr)

Changes

#125983


Patch is 216.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126243.diff

128 Files Affected:

  • (modified) bolt/lib/Core/BinaryContext.cpp (+4-3)
  • (modified) bolt/lib/Core/BinaryData.cpp (+1-1)
  • (modified) bolt/lib/Core/BinaryFunction.cpp (+6-9)
  • (modified) bolt/lib/Passes/Aligner.cpp (+12-17)
  • (modified) bolt/lib/Passes/ContinuityStats.cpp (+1-1)
  • (modified) bolt/lib/Passes/FrameOptimizer.cpp (+1-1)
  • (modified) bolt/lib/Passes/Instrumentation.cpp (+1-1)
  • (modified) bolt/lib/Passes/PLTCall.cpp (+10-16)
  • (modified) bolt/lib/Passes/RetpolineInsertion.cpp (+11-13)
  • (modified) bolt/lib/Passes/StokeInfo.cpp (+1-1)
  • (modified) bolt/lib/Passes/TailDuplication.cpp (+1-1)
  • (modified) bolt/lib/Profile/StaleProfileMatching.cpp (+12-12)
  • (modified) bolt/lib/Profile/YAMLProfileReader.cpp (+3-3)
  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+13-12)
  • (modified) bolt/tools/bat-dump/bat-dump.cpp (+1-1)
  • (modified) bolt/tools/driver/llvm-bolt.cpp (+1-1)
  • (modified) bolt/tools/merge-fdata/merge-fdata.cpp (+1-1)
  • (modified) clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp (+18-17)
  • (modified) clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp (+16-16)
  • (modified) clang-tools-extra/clang-move/tool/ClangMove.cpp (+12-12)
  • (modified) clang-tools-extra/clang-reorder-fields/tool/ClangReorderFields.cpp (+2-1)
  • (modified) clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp (+3-3)
  • (modified) clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp (+1-1)
  • (modified) clang-tools-extra/clangd/index/remote/server/Server.cpp (+14-12)
  • (modified) clang-tools-extra/clangd/tool/Check.cpp (+6-7)
  • (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+8-8)
  • (modified) clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp (+37-37)
  • (modified) clang/unittests/Tooling/ExecutionTest.cpp (+1-1)
  • (modified) clang/utils/TableGen/TableGen.cpp (+5-5)
  • (modified) flang/lib/Lower/OpenMP/Utils.cpp (+3-3)
  • (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1)
  • (modified) flang/lib/Optimizer/Passes/CommandLineOpts.cpp (+10-10)
  • (modified) lldb/tools/lldb-test/lldb-test.cpp (+13-12)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp (+4-4)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/cached/toy.cpp (+9-9)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/complete/toy.cpp (+26-25)
  • (modified) llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp (+9-9)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp (+2-2)
  • (modified) llvm/lib/Analysis/AliasAnalysis.cpp (+2-1)
  • (modified) llvm/lib/Analysis/BranchProbabilityInfo.cpp (+1-1)
  • (modified) llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp (+2-2)
  • (modified) llvm/lib/Analysis/IRSimilarityIdentifier.cpp (+1-1)
  • (modified) llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp (+1-1)
  • (modified) llvm/lib/Analysis/MemoryProfileInfo.cpp (+1-1)
  • (modified) llvm/lib/CGData/CodeGenData.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachinePipeliner.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineScheduler.cpp (+9-9)
  • (modified) llvm/lib/CodeGen/MachineStripDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/WindowScheduler.cpp (+6-6)
  • (modified) llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp (+16-14)
  • (modified) llvm/lib/LTO/LTOCodeGenerator.cpp (+6-7)
  • (modified) llvm/lib/Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AArch64StackTaggingPreRA.cpp (+2-3)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+2-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp (+1-1)
  • (modified) llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1)
  • (modified) llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp (+5-6)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp (+11-14)
  • (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+9-9)
  • (modified) llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp (+31-31)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (+18-17)
  • (modified) llvm/lib/Transforms/IPO/ElimAvailExtern.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/ModuleInliner.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+18-17)
  • (modified) llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp (+13-12)
  • (modified) llvm/lib/Transforms/Scalar/LICM.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+4-4)
  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp (+3-3)
  • (modified) llvm/tools/bugpoint/BugDriver.cpp (+3-3)
  • (modified) llvm/tools/bugpoint/CrashDebugger.cpp (+34-28)
  • (modified) llvm/tools/bugpoint/ExecutionDriver.cpp (+16-16)
  • (modified) llvm/tools/bugpoint/ExtractFunction.cpp (+4-3)
  • (modified) llvm/tools/bugpoint/OptimizerDriver.cpp (+1-1)
  • (modified) llvm/tools/bugpoint/ToolRunner.cpp (+8-8)
  • (modified) llvm/tools/lli/lli.cpp (+77-75)
  • (modified) llvm/tools/llvm-as/llvm-as.cpp (+1-1)
  • (modified) llvm/tools/llvm-cat/llvm-cat.cpp (+1-1)
  • (modified) llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp (+13-11)
  • (modified) llvm/tools/llvm-cov/CodeCoverage.cpp (+62-60)
  • (modified) llvm/tools/llvm-cov/TestingSupport.cpp (+3-3)
  • (modified) llvm/tools/llvm-cov/gcov.cpp (+40-36)
  • (modified) llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp (+1-1)
  • (modified) llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp (+17-16)
  • (modified) llvm/tools/llvm-diff/llvm-diff.cpp (+1-1)
  • (modified) llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (+6-5)
  • (modified) llvm/tools/llvm-extract/llvm-extract.cpp (+1-1)
  • (modified) llvm/tools/llvm-jitlink/llvm-jitlink.cpp (+3-3)
  • (modified) llvm/tools/llvm-lto/llvm-lto.cpp (+1-1)
  • (modified) llvm/tools/llvm-lto2/llvm-lto2.cpp (+1-1)
  • (modified) llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp (+13-13)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+97-93)
  • (modified) llvm/tools/llvm-undname/llvm-undname.cpp (+27-24)
  • (modified) llvm/tools/reduce-chunk-list/reduce-chunk-list.cpp (+3-3)
  • (modified) llvm/tools/yaml2obj/yaml2obj.cpp (+11-9)
  • (modified) llvm/unittests/Support/CommandLineTest.cpp (+6-6)
  • (modified) llvm/utils/KillTheDoctor/KillTheDoctor.cpp (+30-37)
  • (modified) llvm/utils/TableGen/DAGISelMatcherEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/DecoderEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp (+6-6)
  • (modified) llvm/utils/TableGen/GlobalISelEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/RegisterInfoEmitter.cpp (+1-1)
  • (modified) llvm/utils/fpcmp/fpcmp.cpp (+8-8)
  • (modified) llvm/utils/yaml-bench/YAMLBench.cpp (+1-1)
  • (modified) mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp (+4-4)
  • (modified) mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp (+4-4)
  • (modified) mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp (+4-3)
  • (modified) mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp (+4-4)
  • (modified) mlir/tools/mlir-pdll/mlir-pdll.cpp (+8-8)
  • (modified) mlir/tools/mlir-rewrite/mlir-rewrite.cpp (+2-1)
  • (modified) mlir/tools/mlir-runner/mlir-runner.cpp (+1-1)
  • (modified) mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp (+7-7)
  • (modified) mlir/tools/mlir-tblgen/DialectGen.cpp (+1-1)
  • (modified) mlir/tools/mlir-tblgen/OpDocGen.cpp (+2-2)
  • (modified) mlir/tools/mlir-tblgen/OpGenHelpers.cpp (+1-1)
  • (modified) mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp (+1-1)
  • (modified) offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp (+1-1)
  • (modified) offload/tools/offload-tblgen/offload-tblgen.cpp (+1-1)
  • (modified) polly/lib/CodeGen/LoopGenerators.cpp (+1-1)
  • (modified) polly/lib/Transform/DeLICM.cpp (+7-7)
  • (modified) polly/lib/Transform/DeadCodeElimination.cpp (+1-1)
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index f9fc536f3569ad3..637b6785916fed3 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -46,9 +46,10 @@ using namespace llvm;
 
 namespace opts {
 
-cl::opt<bool> NoHugePages("no-huge-pages",
-                          cl::desc("use regular size pages for code alignment"),
-                          cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    NoHugePages("no-huge-pages",
+                cl::desc("use regular size pages for code alignment"),
+                cl::Hidden, cl::cat(BoltCategory));
 
 static cl::opt<bool>
 PrintDebugInfo("print-debug-info",
diff --git a/bolt/lib/Core/BinaryData.cpp b/bolt/lib/Core/BinaryData.cpp
index e9ddf08d8695f46..88f13eafd614d95 100644
--- a/bolt/lib/Core/BinaryData.cpp
+++ b/bolt/lib/Core/BinaryData.cpp
@@ -24,7 +24,7 @@ namespace opts {
 extern cl::OptionCategory BoltCategory;
 extern cl::opt<unsigned> Verbosity;
 
-cl::opt<bool>
+static cl::opt<bool>
     PrintSymbolAliases("print-aliases",
                        cl::desc("print aliases when printing objects"),
                        cl::Hidden, cl::cat(BoltCategory));
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index bc45caf3ec8b749..4dcf9534fd36081 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -66,7 +66,7 @@ extern cl::opt<unsigned> Verbosity;
 
 extern bool processAllFunctions();
 
-cl::opt<bool> CheckEncoding(
+static cl::opt<bool> CheckEncoding(
     "check-encoding",
     cl::desc("perform verification of LLVM instruction encoding/decoding. "
              "Every instruction in the input is decoded and re-encoded. "
@@ -143,14 +143,11 @@ cl::opt<bool>
               cl::desc("print time spent constructing binary functions"),
               cl::Hidden, cl::cat(BoltCategory));
 
-cl::opt<bool>
-TrapOnAVX512("trap-avx512",
-  cl::desc("in relocation mode trap upon entry to any function that uses "
-            "AVX-512 instructions"),
-  cl::init(false),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltCategory));
+static cl::opt<bool> TrapOnAVX512(
+    "trap-avx512",
+    cl::desc("in relocation mode trap upon entry to any function that uses "
+             "AVX-512 instructions"),
+    cl::init(false), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
 
 bool shouldPrint(const BinaryFunction &Function) {
   if (Function.isIgnored())
diff --git a/bolt/lib/Passes/Aligner.cpp b/bolt/lib/Passes/Aligner.cpp
index 555f82a5a817808..c3ddedaaa14660a 100644
--- a/bolt/lib/Passes/Aligner.cpp
+++ b/bolt/lib/Passes/Aligner.cpp
@@ -25,15 +25,12 @@ extern cl::opt<bool> AlignBlocks;
 extern cl::opt<bool> PreserveBlocksAlignment;
 extern cl::opt<unsigned> AlignFunctions;
 
-cl::opt<unsigned>
-AlignBlocksMinSize("align-blocks-min-size",
-  cl::desc("minimal size of the basic block that should be aligned"),
-  cl::init(0),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltOptCategory));
-
-cl::opt<unsigned> AlignBlocksThreshold(
+static cl::opt<unsigned> AlignBlocksMinSize(
+    "align-blocks-min-size",
+    cl::desc("minimal size of the basic block that should be aligned"),
+    cl::init(0), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
+
+static cl::opt<unsigned> AlignBlocksThreshold(
     "align-blocks-threshold",
     cl::desc(
         "align only blocks with frequency larger than containing function "
@@ -42,19 +39,17 @@ cl::opt<unsigned> AlignBlocksThreshold(
         "containing function."),
     cl::init(800), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> AlignFunctionsMaxBytes(
+static cl::opt<unsigned> AlignFunctionsMaxBytes(
     "align-functions-max-bytes",
     cl::desc("maximum number of bytes to use to align functions"), cl::init(32),
     cl::cat(BoltOptCategory));
 
-cl::opt<unsigned>
-BlockAlignment("block-alignment",
-  cl::desc("boundary to use for alignment of basic blocks"),
-  cl::init(16),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
+static cl::opt<unsigned>
+    BlockAlignment("block-alignment",
+                   cl::desc("boundary to use for alignment of basic blocks"),
+                   cl::init(16), cl::ZeroOrMore, cl::cat(BoltOptCategory));
 
-cl::opt<bool>
+static cl::opt<bool>
     UseCompactAligner("use-compact-aligner",
                       cl::desc("Use compact approach for aligning functions"),
                       cl::init(true), cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Passes/ContinuityStats.cpp b/bolt/lib/Passes/ContinuityStats.cpp
index b32365b59065dce..af5fb6285a90b5d 100644
--- a/bolt/lib/Passes/ContinuityStats.cpp
+++ b/bolt/lib/Passes/ContinuityStats.cpp
@@ -26,7 +26,7 @@ using namespace bolt;
 
 namespace opts {
 extern cl::opt<unsigned> Verbosity;
-cl::opt<unsigned> NumFunctionsForContinuityCheck(
+static cl::opt<unsigned> NumFunctionsForContinuityCheck(
     "num-functions-for-continuity-check",
     cl::desc("number of hottest functions to print aggregated "
              "CFG discontinuity stats of."),
diff --git a/bolt/lib/Passes/FrameOptimizer.cpp b/bolt/lib/Passes/FrameOptimizer.cpp
index 1c0f9555f9eb9be..81d4d9367f58ccb 100644
--- a/bolt/lib/Passes/FrameOptimizer.cpp
+++ b/bolt/lib/Passes/FrameOptimizer.cpp
@@ -43,7 +43,7 @@ FrameOptimization("frame-opt",
   cl::ZeroOrMore,
   cl::cat(BoltOptCategory));
 
-cl::opt<bool> RemoveStores(
+static cl::opt<bool> RemoveStores(
     "frame-opt-rm-stores", cl::init(FOP_NONE),
     cl::desc("apply additional analysis to remove stores (experimental)"),
     cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp
index 76766b05b917607..ed40e63611abd52 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -71,7 +71,7 @@ cl::opt<bool> InstrumentationWaitForks(
              "(use with instrumentation-sleep-time option)"),
     cl::init(false), cl::Optional, cl::cat(BoltInstrCategory));
 
-cl::opt<bool>
+static cl::opt<bool>
     InstrumentHotOnly("instrument-hot-only",
                       cl::desc("only insert instrumentation on hot functions "
                                "(needs profile, default: false)"),
diff --git a/bolt/lib/Passes/PLTCall.cpp b/bolt/lib/Passes/PLTCall.cpp
index 31c2d92ebc20413..90b5f586a7bad6d 100644
--- a/bolt/lib/Passes/PLTCall.cpp
+++ b/bolt/lib/Passes/PLTCall.cpp
@@ -22,22 +22,16 @@ namespace opts {
 
 extern cl::OptionCategory BoltOptCategory;
 
-cl::opt<bolt::PLTCall::OptType>
-PLT("plt",
-  cl::desc("optimize PLT calls (requires linking with -znow)"),
-  cl::init(bolt::PLTCall::OT_NONE),
-  cl::values(clEnumValN(bolt::PLTCall::OT_NONE,
-      "none",
-      "do not optimize PLT calls"),
-    clEnumValN(bolt::PLTCall::OT_HOT,
-      "hot",
-      "optimize executed (hot) PLT calls"),
-    clEnumValN(bolt::PLTCall::OT_ALL,
-      "all",
-      "optimize all PLT calls")),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
-
+static cl::opt<bolt::PLTCall::OptType>
+    PLT("plt", cl::desc("optimize PLT calls (requires linking with -znow)"),
+        cl::init(bolt::PLTCall::OT_NONE),
+        cl::values(clEnumValN(bolt::PLTCall::OT_NONE, "none",
+                              "do not optimize PLT calls"),
+                   clEnumValN(bolt::PLTCall::OT_HOT, "hot",
+                              "optimize executed (hot) PLT calls"),
+                   clEnumValN(bolt::PLTCall::OT_ALL, "all",
+                              "optimize all PLT calls")),
+        cl::ZeroOrMore, cl::cat(BoltOptCategory));
 }
 
 namespace llvm {
diff --git a/bolt/lib/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp
index 171177d9e933326..f8702893a222b16 100644
--- a/bolt/lib/Passes/RetpolineInsertion.cpp
+++ b/bolt/lib/Passes/RetpolineInsertion.cpp
@@ -33,19 +33,17 @@ namespace opts {
 
 extern cl::OptionCategory BoltCategory;
 
-llvm::cl::opt<bool> InsertRetpolines("insert-retpolines",
-                                     cl::desc("run retpoline insertion pass"),
-                                     cl::cat(BoltCategory));
-
-llvm::cl::opt<bool>
-RetpolineLfence("retpoline-lfence",
-  cl::desc("determine if lfence instruction should exist in the retpoline"),
-  cl::init(true),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltCategory));
-
-cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
+static llvm::cl::opt<bool>
+    InsertRetpolines("insert-retpolines",
+                     cl::desc("run retpoline insertion pass"),
+                     cl::cat(BoltCategory));
+
+static llvm::cl::opt<bool> RetpolineLfence(
+    "retpoline-lfence",
+    cl::desc("determine if lfence instruction should exist in the retpoline"),
+    cl::init(true), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
+
+static cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
     "r11-availability",
     cl::desc("determine the availability of r11 before indirect branches"),
     cl::init(RetpolineInsertion::AvailabilityOptions::NEVER),
diff --git a/bolt/lib/Passes/StokeInfo.cpp b/bolt/lib/Passes/StokeInfo.cpp
index dd033508d200c10..9da460a2877c907 100644
--- a/bolt/lib/Passes/StokeInfo.cpp
+++ b/bolt/lib/Passes/StokeInfo.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
 using namespace bolt;
 
 namespace opts {
-cl::OptionCategory StokeOptCategory("STOKE pass options");
+static cl::OptionCategory StokeOptCategory("STOKE pass options");
 
 static cl::opt<std::string>
 StokeOutputDataFilename("stoke-out",
diff --git a/bolt/lib/Passes/TailDuplication.cpp b/bolt/lib/Passes/TailDuplication.cpp
index 463ea49527fa6cd..354f9b78830c301 100644
--- a/bolt/lib/Passes/TailDuplication.cpp
+++ b/bolt/lib/Passes/TailDuplication.cpp
@@ -26,7 +26,7 @@ namespace opts {
 extern cl::OptionCategory BoltOptCategory;
 extern cl::opt<bool> NoThreads;
 
-cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
+static cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
     "tail-duplication",
     cl::desc("duplicate unconditional branches that cross a cache line"),
     cl::init(bolt::TailDuplication::TD_NONE),
diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp
index b66a3f478f1a7b0..1a61949d774726d 100644
--- a/bolt/lib/Profile/StaleProfileMatching.cpp
+++ b/bolt/lib/Profile/StaleProfileMatching.cpp
@@ -52,66 +52,66 @@ cl::opt<bool>
                       cl::desc("Infer counts from stale profile data."),
                       cl::init(false), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingMinMatchedBlock(
+static cl::opt<unsigned> StaleMatchingMinMatchedBlock(
     "stale-matching-min-matched-block",
     cl::desc("Percentage threshold of matched basic blocks at which stale "
              "profile inference is executed."),
     cl::init(0), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingMaxFuncSize(
+static cl::opt<unsigned> StaleMatchingMaxFuncSize(
     "stale-matching-max-func-size",
     cl::desc("The maximum size of a function to consider for inference."),
     cl::init(10000), cl::Hidden, cl::cat(BoltOptCategory));
 
 // Parameters of the profile inference algorithm. The default values are tuned
 // on several benchmarks.
-cl::opt<bool> StaleMatchingEvenFlowDistribution(
+static cl::opt<bool> StaleMatchingEvenFlowDistribution(
     "stale-matching-even-flow-distribution",
     cl::desc("Try to evenly distribute flow when there are multiple equally "
              "likely options."),
     cl::init(true), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<bool> StaleMatchingRebalanceUnknown(
+static cl::opt<bool> StaleMatchingRebalanceUnknown(
     "stale-matching-rebalance-unknown",
     cl::desc("Evenly re-distribute flow among unknown subgraphs."),
     cl::init(false), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<bool> StaleMatchingJoinIslands(
+static cl::opt<bool> StaleMatchingJoinIslands(
     "stale-matching-join-islands",
     cl::desc("Join isolated components having positive flow."), cl::init(true),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockInc(
+static cl::opt<unsigned> StaleMatchingCostBlockInc(
     "stale-matching-cost-block-inc",
     cl::desc("The cost of increasing a block count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockDec(
+static cl::opt<unsigned> StaleMatchingCostBlockDec(
     "stale-matching-cost-block-dec",
     cl::desc("The cost of decreasing a block count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpInc(
+static cl::opt<unsigned> StaleMatchingCostJumpInc(
     "stale-matching-cost-jump-inc",
     cl::desc("The cost of increasing a jump count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpDec(
+static cl::opt<unsigned> StaleMatchingCostJumpDec(
     "stale-matching-cost-jump-dec",
     cl::desc("The cost of decreasing a jump count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
+static cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
     "stale-matching-cost-block-unknown-inc",
     cl::desc("The cost of increasing an unknown block count by one."),
     cl::init(1), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
+static cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
     "stale-matching-cost-jump-unknown-inc",
     cl::desc("The cost of increasing an unknown jump count by one."),
     cl::init(140), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
+static cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
     "stale-matching-cost-jump-unknown-ft-inc",
     cl::desc(
         "The cost of increasing an unknown fall-through jump count by one."),
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index e3872b373f41788..f5636bfe3e1f19e 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -28,7 +28,7 @@ extern cl::OptionCategory BoltOptCategory;
 extern cl::opt<bool> InferStaleProfile;
 extern cl::opt<bool> Lite;
 
-cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
+static cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
     "name-similarity-function-matching-threshold",
     cl::desc("Match functions using namespace and edit distance"), cl::init(0),
     cl::Hidden, cl::cat(BoltOptCategory));
@@ -38,11 +38,11 @@ static llvm::cl::opt<bool>
                cl::desc("ignore hash while reading function profile"),
                cl::Hidden, cl::cat(BoltOptCategory));
 
-llvm::cl::opt<bool>
+static llvm::cl::opt<bool>
     MatchProfileWithFunctionHash("match-profile-with-function-hash",
                                  cl::desc("Match profile with function hash"),
                                  cl::Hidden, cl::cat(BoltOptCategory));
-llvm::cl::opt<bool>
+static llvm::cl::opt<bool>
     MatchWithCallGraph("match-with-call-graph",
                        cl::desc("Match functions with call graph"), cl::Hidden,
                        cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 4329235d4704972..a5a23a19256712a 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -90,9 +90,10 @@ extern cl::opt<bolt::IdenticalCodeFolding::ICFLevel, false,
                llvm::bolt::DeprecatedICFNumericOptionParser>
     ICF;
 
-cl::opt<bool> AllowStripped("allow-stripped",
-                            cl::desc("allow processing of stripped binaries"),
-                            cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    AllowStripped("allow-stripped",
+                  cl::desc("allow processing of stripped binaries"), cl::Hidden,
+                  cl::cat(BoltCategory));
 
 static cl::opt<bool> ForceToDataRelocations(
     "force-data-relocations",
@@ -100,7 +101,7 @@ static cl::opt<bool> ForceToDataRelocations(
 
     cl::Hidden, cl::cat(BoltCategory));
 
-cl::opt<std::string>
+static cl::opt<std::string>
     BoltID("bolt-id",
            cl::desc("add any string to tag this execution in the "
                     "output binary via bolt info section"),
@@ -174,9 +175,10 @@ cl::opt<bool> PrintAll("print-all",
                        cl::desc("print functions after each stage"), cl::Hidden,
                        cl::cat(BoltCategory));
 
-cl::opt<bool> PrintProfile("print-profile",
-                           cl::desc("print functions after attaching profile"),
-                           cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    PrintProfile("print-profile",
+                 cl::desc("print functions after attaching profile"),
+                 cl::Hidden, cl::cat(BoltCategory));
 
 cl::opt<bool> PrintCFG("print-cfg",
                        cl::desc("print functions after CFG construction"),
@@ -217,11 +219,10 @@ SkipFunctionNamesFile("skip-funcs-file",
   cl::Hidden,
   cl::cat(BoltCategory));
 
-cl::opt<bool>
-TrapOldCode("trap-old-code",
-  cl::desc("insert traps in old function bodies (relocation mode)"),
-  cl::Hidden,
-  cl::cat(BoltCategory));
+static cl::opt<bool> TrapOldCode(
+    "trap-old-code",
+    cl::desc("insert traps in old function bodies (relocation mode)"),
+    cl::Hidden, cl::cat(BoltCategory));
 
 static cl::opt<std::string> DWPPathName("dwp",
                                         cl::desc("Path and name to DWP file."),
diff --git a/bolt/tools/bat-dump/bat-dump.cpp b/bolt/tools/bat-dump/bat-dump.cpp
index 709eb076bca2da7..8a743cba175401f 100644
--- a/bolt/tools/bat-dump/bat-dump.cpp
+++ b/bolt/tools/bat-dump/bat-dump.cpp
@@ -39,7 +39,7 @@ using namespace bolt;
 
 namespace opts {
 
-cl::OptionCategory BatDumpCategory("BAT dump options");
+static cl::OptionCategory BatDumpCategory("BAT dump options");
 
 static cl::OptionCategory *BatDumpCategories[] = {&BatDumpCategory};
 
diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp
index efa06cd68cb997d..4ce699e501de0a1 100644
--- a/bolt/tools/driver/llvm-bolt.cpp
+++ b/bolt/tools/driver/llvm-bolt.cpp
@@ -63,7 +63,7 @@ BoltProfile("b",
   cl::aliasopt(InputDataFilename),
   cl::cat(BoltCategory));
 
-cl::opt<std::string>
+static cl::opt<std::string>
     LogFile("log-file",
             cl::desc("redirect journaling to a file instead of stdout/stderr"),
             cl::Hidden, cl::cat(BoltCategory));
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp
index 74a5f8ca2d47780..864aa674741997b 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -31,7 +31,7 @@ using namespace llvm::yaml::bolt;
 
 namespace opts {
 
-cl::OptionCategory MergeFdataCategory("merge-fdata options");
+static cl::OptionCategory MergeFdataCategory("merge-fdata options");
 
 enum SortType : char {
   ST_NONE,
diff --git a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
index 22d26db0c11bcf0..d5457aaf67ea1f3 100644
--- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
@@ -45,34 +45,35 @@ using namespace llvm;
 
 namespace {
 
-cl::OptionCategory ChangeNamespaceCategory("Change namespace.");
+static cl::OptionCategory ChangeNamespaceCategory("Change namespace.");
 
-cl::opt<std::string> OldNamespace("old_namespace", cl::Required,
-                                  cl::desc("Old namespace."),
-                                  cl::cat(ChangeNamespaceCategory));
+static cl::opt<std::string> OldNamespace("old_namespace", cl::Required,
+                                         cl::desc("Old namespace."),
+                                         cl::cat(ChangeNamespaceCategory));
 
-cl::opt<std::string> NewNamespace("new_namespace", cl::Required,
-                                  cl::desc("New namespace."),
-                                  cl::cat(ChangeNamespaceCategory));
+static cl::opt<std::string> NewNamespace("new_namespace", cl::...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: None (chrisPyr)

Changes

#125983


Patch is 216.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126243.diff

128 Files Affected:

  • (modified) bolt/lib/Core/BinaryContext.cpp (+4-3)
  • (modified) bolt/lib/Core/BinaryData.cpp (+1-1)
  • (modified) bolt/lib/Core/BinaryFunction.cpp (+6-9)
  • (modified) bolt/lib/Passes/Aligner.cpp (+12-17)
  • (modified) bolt/lib/Passes/ContinuityStats.cpp (+1-1)
  • (modified) bolt/lib/Passes/FrameOptimizer.cpp (+1-1)
  • (modified) bolt/lib/Passes/Instrumentation.cpp (+1-1)
  • (modified) bolt/lib/Passes/PLTCall.cpp (+10-16)
  • (modified) bolt/lib/Passes/RetpolineInsertion.cpp (+11-13)
  • (modified) bolt/lib/Passes/StokeInfo.cpp (+1-1)
  • (modified) bolt/lib/Passes/TailDuplication.cpp (+1-1)
  • (modified) bolt/lib/Profile/StaleProfileMatching.cpp (+12-12)
  • (modified) bolt/lib/Profile/YAMLProfileReader.cpp (+3-3)
  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+13-12)
  • (modified) bolt/tools/bat-dump/bat-dump.cpp (+1-1)
  • (modified) bolt/tools/driver/llvm-bolt.cpp (+1-1)
  • (modified) bolt/tools/merge-fdata/merge-fdata.cpp (+1-1)
  • (modified) clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp (+18-17)
  • (modified) clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp (+16-16)
  • (modified) clang-tools-extra/clang-move/tool/ClangMove.cpp (+12-12)
  • (modified) clang-tools-extra/clang-reorder-fields/tool/ClangReorderFields.cpp (+2-1)
  • (modified) clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp (+3-3)
  • (modified) clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp (+1-1)
  • (modified) clang-tools-extra/clangd/index/remote/server/Server.cpp (+14-12)
  • (modified) clang-tools-extra/clangd/tool/Check.cpp (+6-7)
  • (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+8-8)
  • (modified) clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp (+37-37)
  • (modified) clang/unittests/Tooling/ExecutionTest.cpp (+1-1)
  • (modified) clang/utils/TableGen/TableGen.cpp (+5-5)
  • (modified) flang/lib/Lower/OpenMP/Utils.cpp (+3-3)
  • (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1)
  • (modified) flang/lib/Optimizer/Passes/CommandLineOpts.cpp (+10-10)
  • (modified) lldb/tools/lldb-test/lldb-test.cpp (+13-12)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp (+4-4)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/cached/toy.cpp (+9-9)
  • (modified) llvm/examples/Kaleidoscope/MCJIT/complete/toy.cpp (+26-25)
  • (modified) llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp (+9-9)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp (+2-2)
  • (modified) llvm/lib/Analysis/AliasAnalysis.cpp (+2-1)
  • (modified) llvm/lib/Analysis/BranchProbabilityInfo.cpp (+1-1)
  • (modified) llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp (+2-2)
  • (modified) llvm/lib/Analysis/IRSimilarityIdentifier.cpp (+1-1)
  • (modified) llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp (+1-1)
  • (modified) llvm/lib/Analysis/MemoryProfileInfo.cpp (+1-1)
  • (modified) llvm/lib/CGData/CodeGenData.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachinePipeliner.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineScheduler.cpp (+9-9)
  • (modified) llvm/lib/CodeGen/MachineStripDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/WindowScheduler.cpp (+6-6)
  • (modified) llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp (+16-14)
  • (modified) llvm/lib/LTO/LTOCodeGenerator.cpp (+6-7)
  • (modified) llvm/lib/Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AArch64StackTaggingPreRA.cpp (+2-3)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+2-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp (+1-1)
  • (modified) llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1)
  • (modified) llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp (+5-6)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp (+11-14)
  • (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+9-9)
  • (modified) llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp (+31-31)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (+18-17)
  • (modified) llvm/lib/Transforms/IPO/ElimAvailExtern.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/ModuleInliner.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+18-17)
  • (modified) llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp (+13-12)
  • (modified) llvm/lib/Transforms/Scalar/LICM.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+4-4)
  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp (+3-3)
  • (modified) llvm/tools/bugpoint/BugDriver.cpp (+3-3)
  • (modified) llvm/tools/bugpoint/CrashDebugger.cpp (+34-28)
  • (modified) llvm/tools/bugpoint/ExecutionDriver.cpp (+16-16)
  • (modified) llvm/tools/bugpoint/ExtractFunction.cpp (+4-3)
  • (modified) llvm/tools/bugpoint/OptimizerDriver.cpp (+1-1)
  • (modified) llvm/tools/bugpoint/ToolRunner.cpp (+8-8)
  • (modified) llvm/tools/lli/lli.cpp (+77-75)
  • (modified) llvm/tools/llvm-as/llvm-as.cpp (+1-1)
  • (modified) llvm/tools/llvm-cat/llvm-cat.cpp (+1-1)
  • (modified) llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp (+13-11)
  • (modified) llvm/tools/llvm-cov/CodeCoverage.cpp (+62-60)
  • (modified) llvm/tools/llvm-cov/TestingSupport.cpp (+3-3)
  • (modified) llvm/tools/llvm-cov/gcov.cpp (+40-36)
  • (modified) llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp (+1-1)
  • (modified) llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp (+17-16)
  • (modified) llvm/tools/llvm-diff/llvm-diff.cpp (+1-1)
  • (modified) llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (+6-5)
  • (modified) llvm/tools/llvm-extract/llvm-extract.cpp (+1-1)
  • (modified) llvm/tools/llvm-jitlink/llvm-jitlink.cpp (+3-3)
  • (modified) llvm/tools/llvm-lto/llvm-lto.cpp (+1-1)
  • (modified) llvm/tools/llvm-lto2/llvm-lto2.cpp (+1-1)
  • (modified) llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp (+13-13)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+97-93)
  • (modified) llvm/tools/llvm-undname/llvm-undname.cpp (+27-24)
  • (modified) llvm/tools/reduce-chunk-list/reduce-chunk-list.cpp (+3-3)
  • (modified) llvm/tools/yaml2obj/yaml2obj.cpp (+11-9)
  • (modified) llvm/unittests/Support/CommandLineTest.cpp (+6-6)
  • (modified) llvm/utils/KillTheDoctor/KillTheDoctor.cpp (+30-37)
  • (modified) llvm/utils/TableGen/DAGISelMatcherEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/DecoderEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp (+6-6)
  • (modified) llvm/utils/TableGen/GlobalISelEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/RegisterInfoEmitter.cpp (+1-1)
  • (modified) llvm/utils/fpcmp/fpcmp.cpp (+8-8)
  • (modified) llvm/utils/yaml-bench/YAMLBench.cpp (+1-1)
  • (modified) mlir/lib/Tools/mlir-lsp-server/MlirLspServerMain.cpp (+4-4)
  • (modified) mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp (+4-4)
  • (modified) mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp (+4-3)
  • (modified) mlir/lib/Tools/tblgen-lsp-server/TableGenLspServerMain.cpp (+4-4)
  • (modified) mlir/tools/mlir-pdll/mlir-pdll.cpp (+8-8)
  • (modified) mlir/tools/mlir-rewrite/mlir-rewrite.cpp (+2-1)
  • (modified) mlir/tools/mlir-runner/mlir-runner.cpp (+1-1)
  • (modified) mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp (+7-7)
  • (modified) mlir/tools/mlir-tblgen/DialectGen.cpp (+1-1)
  • (modified) mlir/tools/mlir-tblgen/OpDocGen.cpp (+2-2)
  • (modified) mlir/tools/mlir-tblgen/OpGenHelpers.cpp (+1-1)
  • (modified) mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp (+1-1)
  • (modified) offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp (+1-1)
  • (modified) offload/tools/offload-tblgen/offload-tblgen.cpp (+1-1)
  • (modified) polly/lib/CodeGen/LoopGenerators.cpp (+1-1)
  • (modified) polly/lib/Transform/DeLICM.cpp (+7-7)
  • (modified) polly/lib/Transform/DeadCodeElimination.cpp (+1-1)
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index f9fc536f3569ad3..637b6785916fed3 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -46,9 +46,10 @@ using namespace llvm;
 
 namespace opts {
 
-cl::opt<bool> NoHugePages("no-huge-pages",
-                          cl::desc("use regular size pages for code alignment"),
-                          cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    NoHugePages("no-huge-pages",
+                cl::desc("use regular size pages for code alignment"),
+                cl::Hidden, cl::cat(BoltCategory));
 
 static cl::opt<bool>
 PrintDebugInfo("print-debug-info",
diff --git a/bolt/lib/Core/BinaryData.cpp b/bolt/lib/Core/BinaryData.cpp
index e9ddf08d8695f46..88f13eafd614d95 100644
--- a/bolt/lib/Core/BinaryData.cpp
+++ b/bolt/lib/Core/BinaryData.cpp
@@ -24,7 +24,7 @@ namespace opts {
 extern cl::OptionCategory BoltCategory;
 extern cl::opt<unsigned> Verbosity;
 
-cl::opt<bool>
+static cl::opt<bool>
     PrintSymbolAliases("print-aliases",
                        cl::desc("print aliases when printing objects"),
                        cl::Hidden, cl::cat(BoltCategory));
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index bc45caf3ec8b749..4dcf9534fd36081 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -66,7 +66,7 @@ extern cl::opt<unsigned> Verbosity;
 
 extern bool processAllFunctions();
 
-cl::opt<bool> CheckEncoding(
+static cl::opt<bool> CheckEncoding(
     "check-encoding",
     cl::desc("perform verification of LLVM instruction encoding/decoding. "
              "Every instruction in the input is decoded and re-encoded. "
@@ -143,14 +143,11 @@ cl::opt<bool>
               cl::desc("print time spent constructing binary functions"),
               cl::Hidden, cl::cat(BoltCategory));
 
-cl::opt<bool>
-TrapOnAVX512("trap-avx512",
-  cl::desc("in relocation mode trap upon entry to any function that uses "
-            "AVX-512 instructions"),
-  cl::init(false),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltCategory));
+static cl::opt<bool> TrapOnAVX512(
+    "trap-avx512",
+    cl::desc("in relocation mode trap upon entry to any function that uses "
+             "AVX-512 instructions"),
+    cl::init(false), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
 
 bool shouldPrint(const BinaryFunction &Function) {
   if (Function.isIgnored())
diff --git a/bolt/lib/Passes/Aligner.cpp b/bolt/lib/Passes/Aligner.cpp
index 555f82a5a817808..c3ddedaaa14660a 100644
--- a/bolt/lib/Passes/Aligner.cpp
+++ b/bolt/lib/Passes/Aligner.cpp
@@ -25,15 +25,12 @@ extern cl::opt<bool> AlignBlocks;
 extern cl::opt<bool> PreserveBlocksAlignment;
 extern cl::opt<unsigned> AlignFunctions;
 
-cl::opt<unsigned>
-AlignBlocksMinSize("align-blocks-min-size",
-  cl::desc("minimal size of the basic block that should be aligned"),
-  cl::init(0),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltOptCategory));
-
-cl::opt<unsigned> AlignBlocksThreshold(
+static cl::opt<unsigned> AlignBlocksMinSize(
+    "align-blocks-min-size",
+    cl::desc("minimal size of the basic block that should be aligned"),
+    cl::init(0), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
+
+static cl::opt<unsigned> AlignBlocksThreshold(
     "align-blocks-threshold",
     cl::desc(
         "align only blocks with frequency larger than containing function "
@@ -42,19 +39,17 @@ cl::opt<unsigned> AlignBlocksThreshold(
         "containing function."),
     cl::init(800), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> AlignFunctionsMaxBytes(
+static cl::opt<unsigned> AlignFunctionsMaxBytes(
     "align-functions-max-bytes",
     cl::desc("maximum number of bytes to use to align functions"), cl::init(32),
     cl::cat(BoltOptCategory));
 
-cl::opt<unsigned>
-BlockAlignment("block-alignment",
-  cl::desc("boundary to use for alignment of basic blocks"),
-  cl::init(16),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
+static cl::opt<unsigned>
+    BlockAlignment("block-alignment",
+                   cl::desc("boundary to use for alignment of basic blocks"),
+                   cl::init(16), cl::ZeroOrMore, cl::cat(BoltOptCategory));
 
-cl::opt<bool>
+static cl::opt<bool>
     UseCompactAligner("use-compact-aligner",
                       cl::desc("Use compact approach for aligning functions"),
                       cl::init(true), cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Passes/ContinuityStats.cpp b/bolt/lib/Passes/ContinuityStats.cpp
index b32365b59065dce..af5fb6285a90b5d 100644
--- a/bolt/lib/Passes/ContinuityStats.cpp
+++ b/bolt/lib/Passes/ContinuityStats.cpp
@@ -26,7 +26,7 @@ using namespace bolt;
 
 namespace opts {
 extern cl::opt<unsigned> Verbosity;
-cl::opt<unsigned> NumFunctionsForContinuityCheck(
+static cl::opt<unsigned> NumFunctionsForContinuityCheck(
     "num-functions-for-continuity-check",
     cl::desc("number of hottest functions to print aggregated "
              "CFG discontinuity stats of."),
diff --git a/bolt/lib/Passes/FrameOptimizer.cpp b/bolt/lib/Passes/FrameOptimizer.cpp
index 1c0f9555f9eb9be..81d4d9367f58ccb 100644
--- a/bolt/lib/Passes/FrameOptimizer.cpp
+++ b/bolt/lib/Passes/FrameOptimizer.cpp
@@ -43,7 +43,7 @@ FrameOptimization("frame-opt",
   cl::ZeroOrMore,
   cl::cat(BoltOptCategory));
 
-cl::opt<bool> RemoveStores(
+static cl::opt<bool> RemoveStores(
     "frame-opt-rm-stores", cl::init(FOP_NONE),
     cl::desc("apply additional analysis to remove stores (experimental)"),
     cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp
index 76766b05b917607..ed40e63611abd52 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -71,7 +71,7 @@ cl::opt<bool> InstrumentationWaitForks(
              "(use with instrumentation-sleep-time option)"),
     cl::init(false), cl::Optional, cl::cat(BoltInstrCategory));
 
-cl::opt<bool>
+static cl::opt<bool>
     InstrumentHotOnly("instrument-hot-only",
                       cl::desc("only insert instrumentation on hot functions "
                                "(needs profile, default: false)"),
diff --git a/bolt/lib/Passes/PLTCall.cpp b/bolt/lib/Passes/PLTCall.cpp
index 31c2d92ebc20413..90b5f586a7bad6d 100644
--- a/bolt/lib/Passes/PLTCall.cpp
+++ b/bolt/lib/Passes/PLTCall.cpp
@@ -22,22 +22,16 @@ namespace opts {
 
 extern cl::OptionCategory BoltOptCategory;
 
-cl::opt<bolt::PLTCall::OptType>
-PLT("plt",
-  cl::desc("optimize PLT calls (requires linking with -znow)"),
-  cl::init(bolt::PLTCall::OT_NONE),
-  cl::values(clEnumValN(bolt::PLTCall::OT_NONE,
-      "none",
-      "do not optimize PLT calls"),
-    clEnumValN(bolt::PLTCall::OT_HOT,
-      "hot",
-      "optimize executed (hot) PLT calls"),
-    clEnumValN(bolt::PLTCall::OT_ALL,
-      "all",
-      "optimize all PLT calls")),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
-
+static cl::opt<bolt::PLTCall::OptType>
+    PLT("plt", cl::desc("optimize PLT calls (requires linking with -znow)"),
+        cl::init(bolt::PLTCall::OT_NONE),
+        cl::values(clEnumValN(bolt::PLTCall::OT_NONE, "none",
+                              "do not optimize PLT calls"),
+                   clEnumValN(bolt::PLTCall::OT_HOT, "hot",
+                              "optimize executed (hot) PLT calls"),
+                   clEnumValN(bolt::PLTCall::OT_ALL, "all",
+                              "optimize all PLT calls")),
+        cl::ZeroOrMore, cl::cat(BoltOptCategory));
 }
 
 namespace llvm {
diff --git a/bolt/lib/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp
index 171177d9e933326..f8702893a222b16 100644
--- a/bolt/lib/Passes/RetpolineInsertion.cpp
+++ b/bolt/lib/Passes/RetpolineInsertion.cpp
@@ -33,19 +33,17 @@ namespace opts {
 
 extern cl::OptionCategory BoltCategory;
 
-llvm::cl::opt<bool> InsertRetpolines("insert-retpolines",
-                                     cl::desc("run retpoline insertion pass"),
-                                     cl::cat(BoltCategory));
-
-llvm::cl::opt<bool>
-RetpolineLfence("retpoline-lfence",
-  cl::desc("determine if lfence instruction should exist in the retpoline"),
-  cl::init(true),
-  cl::ZeroOrMore,
-  cl::Hidden,
-  cl::cat(BoltCategory));
-
-cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
+static llvm::cl::opt<bool>
+    InsertRetpolines("insert-retpolines",
+                     cl::desc("run retpoline insertion pass"),
+                     cl::cat(BoltCategory));
+
+static llvm::cl::opt<bool> RetpolineLfence(
+    "retpoline-lfence",
+    cl::desc("determine if lfence instruction should exist in the retpoline"),
+    cl::init(true), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
+
+static cl::opt<RetpolineInsertion::AvailabilityOptions> R11Availability(
     "r11-availability",
     cl::desc("determine the availability of r11 before indirect branches"),
     cl::init(RetpolineInsertion::AvailabilityOptions::NEVER),
diff --git a/bolt/lib/Passes/StokeInfo.cpp b/bolt/lib/Passes/StokeInfo.cpp
index dd033508d200c10..9da460a2877c907 100644
--- a/bolt/lib/Passes/StokeInfo.cpp
+++ b/bolt/lib/Passes/StokeInfo.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
 using namespace bolt;
 
 namespace opts {
-cl::OptionCategory StokeOptCategory("STOKE pass options");
+static cl::OptionCategory StokeOptCategory("STOKE pass options");
 
 static cl::opt<std::string>
 StokeOutputDataFilename("stoke-out",
diff --git a/bolt/lib/Passes/TailDuplication.cpp b/bolt/lib/Passes/TailDuplication.cpp
index 463ea49527fa6cd..354f9b78830c301 100644
--- a/bolt/lib/Passes/TailDuplication.cpp
+++ b/bolt/lib/Passes/TailDuplication.cpp
@@ -26,7 +26,7 @@ namespace opts {
 extern cl::OptionCategory BoltOptCategory;
 extern cl::opt<bool> NoThreads;
 
-cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
+static cl::opt<bolt::TailDuplication::DuplicationMode> TailDuplicationMode(
     "tail-duplication",
     cl::desc("duplicate unconditional branches that cross a cache line"),
     cl::init(bolt::TailDuplication::TD_NONE),
diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp
index b66a3f478f1a7b0..1a61949d774726d 100644
--- a/bolt/lib/Profile/StaleProfileMatching.cpp
+++ b/bolt/lib/Profile/StaleProfileMatching.cpp
@@ -52,66 +52,66 @@ cl::opt<bool>
                       cl::desc("Infer counts from stale profile data."),
                       cl::init(false), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingMinMatchedBlock(
+static cl::opt<unsigned> StaleMatchingMinMatchedBlock(
     "stale-matching-min-matched-block",
     cl::desc("Percentage threshold of matched basic blocks at which stale "
              "profile inference is executed."),
     cl::init(0), cl::Hidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingMaxFuncSize(
+static cl::opt<unsigned> StaleMatchingMaxFuncSize(
     "stale-matching-max-func-size",
     cl::desc("The maximum size of a function to consider for inference."),
     cl::init(10000), cl::Hidden, cl::cat(BoltOptCategory));
 
 // Parameters of the profile inference algorithm. The default values are tuned
 // on several benchmarks.
-cl::opt<bool> StaleMatchingEvenFlowDistribution(
+static cl::opt<bool> StaleMatchingEvenFlowDistribution(
     "stale-matching-even-flow-distribution",
     cl::desc("Try to evenly distribute flow when there are multiple equally "
              "likely options."),
     cl::init(true), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<bool> StaleMatchingRebalanceUnknown(
+static cl::opt<bool> StaleMatchingRebalanceUnknown(
     "stale-matching-rebalance-unknown",
     cl::desc("Evenly re-distribute flow among unknown subgraphs."),
     cl::init(false), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<bool> StaleMatchingJoinIslands(
+static cl::opt<bool> StaleMatchingJoinIslands(
     "stale-matching-join-islands",
     cl::desc("Join isolated components having positive flow."), cl::init(true),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockInc(
+static cl::opt<unsigned> StaleMatchingCostBlockInc(
     "stale-matching-cost-block-inc",
     cl::desc("The cost of increasing a block count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockDec(
+static cl::opt<unsigned> StaleMatchingCostBlockDec(
     "stale-matching-cost-block-dec",
     cl::desc("The cost of decreasing a block count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpInc(
+static cl::opt<unsigned> StaleMatchingCostJumpInc(
     "stale-matching-cost-jump-inc",
     cl::desc("The cost of increasing a jump count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpDec(
+static cl::opt<unsigned> StaleMatchingCostJumpDec(
     "stale-matching-cost-jump-dec",
     cl::desc("The cost of decreasing a jump count by one."), cl::init(150),
     cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
+static cl::opt<unsigned> StaleMatchingCostBlockUnknownInc(
     "stale-matching-cost-block-unknown-inc",
     cl::desc("The cost of increasing an unknown block count by one."),
     cl::init(1), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
+static cl::opt<unsigned> StaleMatchingCostJumpUnknownInc(
     "stale-matching-cost-jump-unknown-inc",
     cl::desc("The cost of increasing an unknown jump count by one."),
     cl::init(140), cl::ReallyHidden, cl::cat(BoltOptCategory));
 
-cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
+static cl::opt<unsigned> StaleMatchingCostJumpUnknownFTInc(
     "stale-matching-cost-jump-unknown-ft-inc",
     cl::desc(
         "The cost of increasing an unknown fall-through jump count by one."),
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index e3872b373f41788..f5636bfe3e1f19e 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -28,7 +28,7 @@ extern cl::OptionCategory BoltOptCategory;
 extern cl::opt<bool> InferStaleProfile;
 extern cl::opt<bool> Lite;
 
-cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
+static cl::opt<unsigned> NameSimilarityFunctionMatchingThreshold(
     "name-similarity-function-matching-threshold",
     cl::desc("Match functions using namespace and edit distance"), cl::init(0),
     cl::Hidden, cl::cat(BoltOptCategory));
@@ -38,11 +38,11 @@ static llvm::cl::opt<bool>
                cl::desc("ignore hash while reading function profile"),
                cl::Hidden, cl::cat(BoltOptCategory));
 
-llvm::cl::opt<bool>
+static llvm::cl::opt<bool>
     MatchProfileWithFunctionHash("match-profile-with-function-hash",
                                  cl::desc("Match profile with function hash"),
                                  cl::Hidden, cl::cat(BoltOptCategory));
-llvm::cl::opt<bool>
+static llvm::cl::opt<bool>
     MatchWithCallGraph("match-with-call-graph",
                        cl::desc("Match functions with call graph"), cl::Hidden,
                        cl::cat(BoltOptCategory));
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 4329235d4704972..a5a23a19256712a 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -90,9 +90,10 @@ extern cl::opt<bolt::IdenticalCodeFolding::ICFLevel, false,
                llvm::bolt::DeprecatedICFNumericOptionParser>
     ICF;
 
-cl::opt<bool> AllowStripped("allow-stripped",
-                            cl::desc("allow processing of stripped binaries"),
-                            cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    AllowStripped("allow-stripped",
+                  cl::desc("allow processing of stripped binaries"), cl::Hidden,
+                  cl::cat(BoltCategory));
 
 static cl::opt<bool> ForceToDataRelocations(
     "force-data-relocations",
@@ -100,7 +101,7 @@ static cl::opt<bool> ForceToDataRelocations(
 
     cl::Hidden, cl::cat(BoltCategory));
 
-cl::opt<std::string>
+static cl::opt<std::string>
     BoltID("bolt-id",
            cl::desc("add any string to tag this execution in the "
                     "output binary via bolt info section"),
@@ -174,9 +175,10 @@ cl::opt<bool> PrintAll("print-all",
                        cl::desc("print functions after each stage"), cl::Hidden,
                        cl::cat(BoltCategory));
 
-cl::opt<bool> PrintProfile("print-profile",
-                           cl::desc("print functions after attaching profile"),
-                           cl::Hidden, cl::cat(BoltCategory));
+static cl::opt<bool>
+    PrintProfile("print-profile",
+                 cl::desc("print functions after attaching profile"),
+                 cl::Hidden, cl::cat(BoltCategory));
 
 cl::opt<bool> PrintCFG("print-cfg",
                        cl::desc("print functions after CFG construction"),
@@ -217,11 +219,10 @@ SkipFunctionNamesFile("skip-funcs-file",
   cl::Hidden,
   cl::cat(BoltCategory));
 
-cl::opt<bool>
-TrapOldCode("trap-old-code",
-  cl::desc("insert traps in old function bodies (relocation mode)"),
-  cl::Hidden,
-  cl::cat(BoltCategory));
+static cl::opt<bool> TrapOldCode(
+    "trap-old-code",
+    cl::desc("insert traps in old function bodies (relocation mode)"),
+    cl::Hidden, cl::cat(BoltCategory));
 
 static cl::opt<std::string> DWPPathName("dwp",
                                         cl::desc("Path and name to DWP file."),
diff --git a/bolt/tools/bat-dump/bat-dump.cpp b/bolt/tools/bat-dump/bat-dump.cpp
index 709eb076bca2da7..8a743cba175401f 100644
--- a/bolt/tools/bat-dump/bat-dump.cpp
+++ b/bolt/tools/bat-dump/bat-dump.cpp
@@ -39,7 +39,7 @@ using namespace bolt;
 
 namespace opts {
 
-cl::OptionCategory BatDumpCategory("BAT dump options");
+static cl::OptionCategory BatDumpCategory("BAT dump options");
 
 static cl::OptionCategory *BatDumpCategories[] = {&BatDumpCategory};
 
diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp
index efa06cd68cb997d..4ce699e501de0a1 100644
--- a/bolt/tools/driver/llvm-bolt.cpp
+++ b/bolt/tools/driver/llvm-bolt.cpp
@@ -63,7 +63,7 @@ BoltProfile("b",
   cl::aliasopt(InputDataFilename),
   cl::cat(BoltCategory));
 
-cl::opt<std::string>
+static cl::opt<std::string>
     LogFile("log-file",
             cl::desc("redirect journaling to a file instead of stdout/stderr"),
             cl::Hidden, cl::cat(BoltCategory));
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp
index 74a5f8ca2d47780..864aa674741997b 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -31,7 +31,7 @@ using namespace llvm::yaml::bolt;
 
 namespace opts {
 
-cl::OptionCategory MergeFdataCategory("merge-fdata options");
+static cl::OptionCategory MergeFdataCategory("merge-fdata options");
 
 enum SortType : char {
   ST_NONE,
diff --git a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
index 22d26db0c11bcf0..d5457aaf67ea1f3 100644
--- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
@@ -45,34 +45,35 @@ using namespace llvm;
 
 namespace {
 
-cl::OptionCategory ChangeNamespaceCategory("Change namespace.");
+static cl::OptionCategory ChangeNamespaceCategory("Change namespace.");
 
-cl::opt<std::string> OldNamespace("old_namespace", cl::Required,
-                                  cl::desc("Old namespace."),
-                                  cl::cat(ChangeNamespaceCategory));
+static cl::opt<std::string> OldNamespace("old_namespace", cl::Required,
+                                         cl::desc("Old namespace."),
+                                         cl::cat(ChangeNamespaceCategory));
 
-cl::opt<std::string> NewNamespace("new_namespace", cl::Required,
-                                  cl::desc("New namespace."),
-                                  cl::cat(ChangeNamespaceCategory));
+static cl::opt<std::string> NewNamespace("new_namespace", cl::...
[truncated]

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025

I understand this is mostly mechanical changes, but wondering if review wise it will help if its split up into 4-5 PRs. For example, bolt, clang, flag, llvm, mlir etc.

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should definitely be split up. Also some options are referenced in multiple places, i.e. Did you handle those properly?

// foo.h
extern cl::opt <...>

// foo.cpp
cl::opt <...>
use opt

//bar.cpp
use opt.

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025 via email

@chrisPyr
Copy link
Contributor Author

chrisPyr commented Feb 7, 2025

So what I need to do is like open 5 branches and make a PR for each?

As for the cases mentioned, when I tried compile all projects (compile with -DLLVM_ENABLE_PROJECTS=all), I did encounter such cases when compiling and I've fixed them all.
Now all projects can be successfully built, so I think it should be fine?

@jhuber6
Copy link
Contributor

jhuber6 commented Feb 7, 2025

So I should do like open 5 branches and make a PR for each?

As for the cases mentioned, when I tried compile all projects (compile with -DLLVM_ENABLE_PROJECTS=all), I did encounter such cases when compiling and I've fixed them all. Now all projects can be successfully built, so I think it should be fine?

Yes, one PR for each project please.

Also refer to the failing CI for what's broken, e.g.

/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-96x6s-1/llvm-project/github-pull-requests/flang/lib/Lower/OpenMP/Utils.cpp:30:28: error: static declaration of 'treatIndexAsSection' follows non-static declaration
static llvm::cl::opt<bool> treatIndexAsSection(
                           ^
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-96x6s-1/llvm-project/github-pull-requests/flang/lib/Lower/OpenMP/Utils.h:19:28: note: previous declaration is here
extern llvm::cl::opt<bool> treatIndexAsSection;
                           ^

@chrisPyr
Copy link
Contributor Author

chrisPyr commented Feb 7, 2025

OK, I'll do it.
Except for checking it on CI, is there any other method I can test locally? E.g. what options should I add when compiling to make sure if all the components can be compiled successfully

I've tried compile with all project enabled, I thought by that way all changes were already being tested.
However, the CI failed, so it seems what I thought was wrong.

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025 via email

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025

@arsenm did you intent to approve it without splitting? Is this trivial enough to not need splitting as long as CI checks pass?

@arsenm
Copy link
Contributor

arsenm commented Feb 7, 2025

I don't care about splitting or not; either way

@DavidSpickett
Copy link
Collaborator

As for the cases mentioned, when I tried compile all projects (compile with -DLLVM_ENABLE_PROJECTS=all), I did encounter such cases when compiling and I've fixed them all.
Now all projects can be successfully built, so I think it should be fine?

Just to explain why this only came up in CI, Flang is not part of all (see #112789).

According to:

set(LLVM_EXTRA_PROJECTS "flang")

Everything other than Flang will be enabled by all.

@DavidSpickett
Copy link
Collaborator

DavidSpickett commented Feb 7, 2025

You can check the CI logs for the exact command line it uses and replicate it locally.

Should be towards the start of the log, search for cmake (cmake, then space) to find the command.

@joker-eph
Copy link
Collaborator

I don't quite follow the motivation for this, can you expand on this in the description please? Right now this seems unnecessary for the changes I can see in MLIR for example.

@dwblaikie
Copy link
Collaborator

I don't quite follow the motivation for this, can you expand on this in the description please? Right now this seems unnecessary for the changes I can see in MLIR for example.

The linked bug seems to explain it, I think? It seems to be the usual "if something isn't/doesn't need to be declared in a header, then it should be file-local static, so as to not conflict with other local names in other files"?

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025

I don't quite follow the motivation for this, can you expand on this in the description please? Right now this seems unnecessary for the changes I can see in MLIR for example.

The linked bug seems to explain it, I think? It seems to be the usual "if something isn't/doesn't need to be declared in a header, then it should be file-local static, so as to not conflict with other local names in other files"?

Right, though I think @joker-eph comment is that for lot of the MLIR changes, these option variables are function local and they need not be changed to static. This issue is only applicable to file scoped variables.

@jurahul
Copy link
Contributor

jurahul commented Feb 7, 2025

Also, the commit description should be something like: "[NFC] Make file-local cl::opt global variables static" or something like that

@@ -20,7 +20,7 @@ using namespace mlir::lsp;

LogicalResult mlir::MlirLspServerMain(int argc, char **argv,
DialectRegistry &registry) {
llvm::cl::opt<JSONStreamStyle> inputStyle{
static llvm::cl::opt<JSONStreamStyle> inputStyle{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are function local variables and need not be changed to static.

@@ -119,24 +119,24 @@ int main(int argc, char **argv) {
// options as static variables.. some of which overlap with our options.
llvm::cl::ResetCommandLineParser();

llvm::cl::opt<std::string> inputFilename(
static llvm::cl::opt<std::string> inputFilename(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are function local variables and need not be changed to static.

@dwblaikie
Copy link
Collaborator

I don't quite follow the motivation for this, can you expand on this in the description please? Right now this seems unnecessary for the changes I can see in MLIR for example.

The linked bug seems to explain it, I think? It seems to be the usual "if something isn't/doesn't need to be declared in a header, then it should be file-local static, so as to not conflict with other local names in other files"?

Right, though I think @joker-eph comment is that for lot of the MLIR changes, these option variables are function local and they need not be changed to static. This issue is only applicable to file scoped variables.

ah, fair enough - yeah, not sure what the right thihng to do with the locals is. At least in some cases I glanced at, the categories were static local, so arguably the opts could be too - but because it's not clear which way, and doesn't have the same problems as globals - best to leave them as-is.

@vitalybuka
Copy link
Collaborator

All these changes are independent and quite straight forward.

I'd suggest to split in some way, so it's easier to review, land, and revert if we miss and break something.

Maybe by component.
also globals vs function local etc.

@chrisPyr
Copy link
Contributor Author

chrisPyr commented Feb 8, 2025 via email

@joker-eph
Copy link
Collaborator

joker-eph commented Feb 8, 2025

The linked bug seems to explain it, I think?

I don't actually see a description of what is the problem to solve really.

It seems to be the usual "if something isn't/doesn't need to be declared in a header, then it should be file-local static, so as to not conflict with other local names in other files"?

All of the files are main() file for standalone test utilities, they are not library files that anyone can reuse. So I'm not totally clear on what they would conflict with? Not that this change hurts of course, but there is a difference between "I'm fixing a linter issue" and "here is a bug that someone is hitting right now or may hit".

Right, though I think @joker-eph comment is that for lot of the MLIR changes, these option variables are function local and they need not be changed to static. This issue is only applicable to file scoped variables.

That too :)

@jurahul
Copy link
Contributor

jurahul commented Feb 8, 2025 via email

@joker-eph
Copy link
Collaborator

In any case, my understanding is that this is a common C++ practice, [...] It not solving any problem, its just code cleanup.

That's fine (thanks for cleaning up things by the way, always appreciated), I think it should just be documented as a cleanup.

I got thrown off by the description of the issue that says:

Most (if not all) of global variables for command line options need to be defined as static.

They don't actually need to, it's just a enforcing a linter/convention/good practice/....

@jurahul
Copy link
Contributor

jurahul commented Feb 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 backend:AMDGPU backend:ARM backend:Hexagon backend:WebAssembly backend:X86 BOLT clang Clang issues not falling into any other category clang-tools-extra clangd compiler-rt:sanitizer debuginfo flang:fir-hlfir flang Flang issues not falling into any other category lldb llvm:analysis Includes value tracking, cost tables and constant folding llvm:globalisel llvm:SelectionDAG SelectionDAGISel as well llvm:support llvm:transforms LTO Link time optimization (regular/full LTO or ThinLTO) mlgo mlir:core MLIR Core Infrastructure mlir objectyaml offload PGO Profile Guided Optimizations tablegen vectorizers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants