[llvm] d8aba75 - Internalize some cl::opt global variables or move them under namespace llvm

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 7 11:15:56 PDT 2021


Author: Fangrui Song
Date: 2021-05-07T11:15:43-07:00
New Revision: d8aba75a768033c326613d85e8789703cb4565d2

URL: https://github.com/llvm/llvm-project/commit/d8aba75a768033c326613d85e8789703cb4565d2
DIFF: https://github.com/llvm/llvm-project/commit/d8aba75a768033c326613d85e8789703cb4565d2.diff

LOG: Internalize some cl::opt global variables or move them under namespace llvm

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
    llvm/include/llvm/Transforms/Utils/SizeOpts.h
    llvm/lib/Analysis/AliasAnalysis.cpp
    llvm/lib/Analysis/BlockFrequencyInfo.cpp
    llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
    llvm/lib/Analysis/CallGraphSCCPass.cpp
    llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
    llvm/lib/CodeGen/MachineBlockPlacement.cpp
    llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
    llvm/lib/LTO/SummaryBasedOptimizations.cpp
    llvm/lib/MC/MCAsmInfo.cpp
    llvm/lib/MC/MCAsmInfoXCOFF.cpp
    llvm/lib/Passes/PassBuilder.cpp
    llvm/lib/Transforms/IPO/BlockExtractor.cpp
    llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
    llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
    llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
    llvm/lib/Transforms/Utils/SizeOpts.cpp
    llvm/tools/opt/NewPMDriver.cpp
    llvm/tools/opt/opt.cpp
    llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
    polly/lib/Analysis/ScopDetectionDiagnostic.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index c227875311177..4e5cd952b353a 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -48,9 +48,8 @@
 
 #define DEBUG_TYPE "block-freq"
 
-extern llvm::cl::opt<bool> CheckBFIUnknownBlockQueries;
-
 namespace llvm {
+extern llvm::cl::opt<bool> CheckBFIUnknownBlockQueries;
 
 class BranchProbabilityInfo;
 class Function;

diff  --git a/llvm/include/llvm/Transforms/Utils/SizeOpts.h b/llvm/include/llvm/Transforms/Utils/SizeOpts.h
index 3c1173b747d33..11bf5501598fd 100644
--- a/llvm/include/llvm/Transforms/Utils/SizeOpts.h
+++ b/llvm/include/llvm/Transforms/Utils/SizeOpts.h
@@ -17,17 +17,16 @@
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Support/CommandLine.h"
 
-extern llvm::cl::opt<bool> EnablePGSO;
-extern llvm::cl::opt<bool> PGSOLargeWorkingSetSizeOnly;
-extern llvm::cl::opt<bool> PGSOColdCodeOnly;
-extern llvm::cl::opt<bool> PGSOColdCodeOnlyForInstrPGO;
-extern llvm::cl::opt<bool> PGSOColdCodeOnlyForSamplePGO;
-extern llvm::cl::opt<bool> PGSOColdCodeOnlyForPartialSamplePGO;
-extern llvm::cl::opt<bool> ForcePGSO;
-extern llvm::cl::opt<int> PgsoCutoffInstrProf;
-extern llvm::cl::opt<int> PgsoCutoffSampleProf;
-
 namespace llvm {
+extern cl::opt<bool> EnablePGSO;
+extern cl::opt<bool> PGSOLargeWorkingSetSizeOnly;
+extern cl::opt<bool> PGSOColdCodeOnly;
+extern cl::opt<bool> PGSOColdCodeOnlyForInstrPGO;
+extern cl::opt<bool> PGSOColdCodeOnlyForSamplePGO;
+extern cl::opt<bool> PGSOColdCodeOnlyForPartialSamplePGO;
+extern cl::opt<bool> ForcePGSO;
+extern cl::opt<int> PgsoCutoffInstrProf;
+extern cl::opt<int> PgsoCutoffSampleProf;
 
 class BasicBlock;
 class BlockFrequencyInfo;

diff  --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 910103bcfbe02..89a451ba259f0 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -63,9 +63,11 @@ STATISTIC(NumNoAlias,   "Number of NoAlias results");
 STATISTIC(NumMayAlias,  "Number of MayAlias results");
 STATISTIC(NumMustAlias, "Number of MustAlias results");
 
+namespace llvm {
 /// Allow disabling BasicAA from the AA results. This is particularly useful
 /// when testing to isolate a single AA implementation.
 cl::opt<bool> DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false));
+} // namespace llvm
 
 #ifndef NDEBUG
 /// Print a trace of alias analysis queries and their results.

diff  --git a/llvm/lib/Analysis/BlockFrequencyInfo.cpp b/llvm/lib/Analysis/BlockFrequencyInfo.cpp
index b9b1fded9de34..b464071a33e6e 100644
--- a/llvm/lib/Analysis/BlockFrequencyInfo.cpp
+++ b/llvm/lib/Analysis/BlockFrequencyInfo.cpp
@@ -47,6 +47,7 @@ static cl::opt<GVDAGType> ViewBlockFreqPropagationDAG(
                clEnumValN(GVDT_Count, "count", "display a graph using the real "
                                                "profile count if available.")));
 
+namespace llvm {
 cl::opt<std::string>
     ViewBlockFreqFuncName("view-bfi-func-name", cl::Hidden,
                           cl::desc("The option to specify "
@@ -86,6 +87,7 @@ cl::opt<std::string> PrintBlockFreqFuncName(
     "print-bfi-func-name", cl::Hidden,
     cl::desc("The option to specify the name of the function "
              "whose block frequency info is printed."));
+} // namespace llvm
 
 namespace llvm {
 

diff  --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
index e4fda2472b3ac..15503c5117e58 100644
--- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
+++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
@@ -40,11 +40,13 @@ using namespace llvm::bfi_detail;
 
 #define DEBUG_TYPE "block-freq"
 
+namespace llvm {
 cl::opt<bool> CheckBFIUnknownBlockQueries(
     "check-bfi-unknown-block-queries",
     cl::init(false), cl::Hidden,
     cl::desc("Check if block frequency is queried for an unknown block "
              "for debugging missed BFI updates"));
+}
 
 ScaledNumber<uint64_t> BlockMass::toScaled() const {
   if (isFull())

diff  --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index 9e5049593a919..f2e5eab72bf28 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -43,8 +43,10 @@ using namespace llvm;
 
 #define DEBUG_TYPE "cgscc-passmgr"
 
+namespace llvm {
 cl::opt<unsigned> MaxDevirtIterations("max-devirt-iterations", cl::ReallyHidden,
                                       cl::init(4));
+}
 
 STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");
 

diff  --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
index 54e0a14e05557..0368583fa2354 100644
--- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -29,6 +29,7 @@ using namespace llvm;
 
 #define DEBUG_TYPE "machine-block-freq"
 
+namespace llvm {
 static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG(
     "view-machine-block-freq-propagation-dags", cl::Hidden,
     cl::desc("Pop up a window to show a dag displaying how machine block "
@@ -75,6 +76,7 @@ static cl::opt<bool> PrintMachineBlockFreq(
 // Command line option to specify the name of the function for block frequency
 // dump. Defined in Analysis/BlockFrequencyInfo.cpp.
 extern cl::opt<std::string> PrintBlockFreqFuncName;
+} // namespace llvm
 
 static GVDAGType getGVDT() {
   if (ViewBlockLayoutWithBFI != GVDT_None)

diff  --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 2e7584876b54b..f61142d202eb6 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -193,6 +193,7 @@ static cl::opt<unsigned> TriangleChainCount(
     cl::init(2),
     cl::Hidden);
 
+namespace llvm {
 extern cl::opt<unsigned> StaticLikelyProb;
 extern cl::opt<unsigned> ProfileLikelyProb;
 
@@ -204,6 +205,7 @@ extern cl::opt<GVDAGType> ViewBlockLayoutWithBFI;
 // Command line option to specify the name of the function for CFG dump
 // Defined in Analysis/BlockFrequencyInfo.cpp:  -view-bfi-func-name=
 extern cl::opt<std::string> ViewBlockFreqFuncName;
+} // namespace llvm
 
 namespace {
 

diff  --git a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
index f1d68c79a2122..85924bec94a71 100644
--- a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
@@ -25,6 +25,7 @@ INITIALIZE_PASS_BEGIN(MachineBranchProbabilityInfo, "machine-branch-prob",
 INITIALIZE_PASS_END(MachineBranchProbabilityInfo, "machine-branch-prob",
                     "Machine Branch Probability Analysis", false, true)
 
+namespace llvm {
 cl::opt<unsigned>
     StaticLikelyProb("static-likely-prob",
                      cl::desc("branch probability threshold in percentage"
@@ -36,6 +37,7 @@ cl::opt<unsigned> ProfileLikelyProb(
     cl::desc("branch probability threshold in percentage to be considered"
              " very likely when profile is available"),
     cl::init(51), cl::Hidden);
+} // namespace llvm
 
 char MachineBranchProbabilityInfo::ID = 0;
 

diff  --git a/llvm/lib/LTO/SummaryBasedOptimizations.cpp b/llvm/lib/LTO/SummaryBasedOptimizations.cpp
index d4dbefb231e8d..9e9d5c84d50df 100644
--- a/llvm/lib/LTO/SummaryBasedOptimizations.cpp
+++ b/llvm/lib/LTO/SummaryBasedOptimizations.cpp
@@ -23,7 +23,9 @@ static cl::opt<bool> ThinLTOSynthesizeEntryCounts(
     "thinlto-synthesize-entry-counts", cl::init(false), cl::Hidden,
     cl::desc("Synthesize entry counts based on the summary"));
 
+namespace llvm {
 extern cl::opt<int> InitialSyntheticCount;
+}
 
 static void initializeCounts(ModuleSummaryIndex &Index) {
   auto Root = Index.calculateCallGraphRoot();

diff  --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index 620d3e7cffc30..7484bd1827cdb 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -20,7 +20,9 @@
 
 using namespace llvm;
 
+namespace {
 enum DefaultOnOff { Default, Enable, Disable };
+}
 static cl::opt<DefaultOnOff> DwarfExtendedLoc(
     "dwarf-extended-loc", cl::Hidden,
     cl::desc("Disable emission of the extended flags in .loc directives."),
@@ -28,11 +30,13 @@ static cl::opt<DefaultOnOff> DwarfExtendedLoc(
                clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")),
     cl::init(Default));
 
+namespace llvm {
 cl::opt<cl::boolOrDefault> UseLEB128Directives(
     "use-leb128-directives", cl::Hidden,
     cl::desc(
         "Disable the usage of LEB128 directives, and generate .byte instead."),
     cl::init(cl::BOU_UNSET));
+}
 
 MCAsmInfo::MCAsmInfo() {
   SeparatorString = ";";

diff  --git a/llvm/lib/MC/MCAsmInfoXCOFF.cpp b/llvm/lib/MC/MCAsmInfoXCOFF.cpp
index 7ee0eef6aecee..603f894dacd2c 100644
--- a/llvm/lib/MC/MCAsmInfoXCOFF.cpp
+++ b/llvm/lib/MC/MCAsmInfoXCOFF.cpp
@@ -12,7 +12,9 @@
 
 using namespace llvm;
 
+namespace llvm {
 extern cl::opt<cl::boolOrDefault> UseLEB128Directives;
+}
 
 void MCAsmInfoXCOFF::anchor() {}
 

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 3e2973937ed7d..f811c26609bc1 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -240,8 +240,6 @@
 
 using namespace llvm;
 
-extern cl::opt<unsigned> MaxDevirtIterations;
-
 static cl::opt<InliningAdvisorMode> UseInlineAdvisor(
     "enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden,
     cl::desc("Enable ML policy for inliner. Currently trained for -Oz only"),
@@ -296,8 +294,9 @@ PipelineTuningOptions::PipelineTuningOptions() {
   CallGraphProfile = true;
   MergeFunctions = false;
 }
-extern cl::opt<bool> ExtraVectorizerPasses;
 
+namespace llvm {
+extern cl::opt<unsigned> MaxDevirtIterations;
 extern cl::opt<bool> EnableConstraintElimination;
 extern cl::opt<bool> EnableGVNHoist;
 extern cl::opt<bool> EnableGVNSink;
@@ -310,6 +309,7 @@ extern cl::opt<bool> EnableUnrollAndJam;
 extern cl::opt<bool> EnableLoopFlatten;
 extern cl::opt<bool> RunNewGVN;
 extern cl::opt<bool> RunPartialInlining;
+extern cl::opt<bool> ExtraVectorizerPasses;
 
 extern cl::opt<bool> FlattenedProfileUsed;
 
@@ -320,6 +320,7 @@ extern cl::opt<bool> EnableMatrix;
 
 extern cl::opt<bool> DisablePreInliner;
 extern cl::opt<int> PreInlineThreshold;
+} // namespace llvm
 
 const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
     /*SpeedLevel*/ 0,

diff  --git a/llvm/lib/Transforms/IPO/BlockExtractor.cpp b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
index c6e222a096eb1..7c178f9a98345 100644
--- a/llvm/lib/Transforms/IPO/BlockExtractor.cpp
+++ b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
@@ -36,9 +36,10 @@ static cl::opt<std::string> BlockExtractorFile(
     "extract-blocks-file", cl::value_desc("filename"),
     cl::desc("A file containing list of basic blocks to extract"), cl::Hidden);
 
-cl::opt<bool> BlockExtractorEraseFuncs("extract-blocks-erase-funcs",
-                                       cl::desc("Erase the existing functions"),
-                                       cl::Hidden);
+static cl::opt<bool>
+    BlockExtractorEraseFuncs("extract-blocks-erase-funcs",
+                             cl::desc("Erase the existing functions"),
+                             cl::Hidden);
 namespace {
 class BlockExtractor {
 public:

diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 1de8cfa774457..0b9d869aa1554 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -51,6 +51,7 @@
 
 using namespace llvm;
 
+namespace llvm {
 cl::opt<bool> RunPartialInlining("enable-partial-inlining", cl::init(false),
                                  cl::Hidden, cl::ZeroOrMore,
                                  cl::desc("Run Partial inlinining pass"));
@@ -178,6 +179,7 @@ cl::opt<AttributorRunOption> AttributorRun(
                           "disable attributor runs")));
 
 extern cl::opt<bool> EnableKnowledgeRetention;
+} // namespace llvm
 
 PassManagerBuilder::PassManagerBuilder() {
     OptLevel = 2;

diff  --git a/llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp b/llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
index 1b1e91cafa651..95393d9476e0a 100644
--- a/llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
+++ b/llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
@@ -44,11 +44,12 @@ using ProfileCount = Function::ProfileCount;
 
 #define DEBUG_TYPE "synthetic-counts-propagation"
 
-/// Initial synthetic count assigned to functions.
+namespace llvm {
 cl::opt<int>
     InitialSyntheticCount("initial-synthetic-count", cl::Hidden, cl::init(10),
                           cl::ZeroOrMore,
-                          cl::desc("Initial value of synthetic entry count."));
+                          cl::desc("Initial value of synthetic entry count"));
+} // namespace llvm
 
 /// Initial synthetic count assigned to inline functions.
 static cl::opt<int> InlineSyntheticCount(

diff  --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index ee79bb2a310d5..349cd5f50c7f6 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -145,20 +145,20 @@ static cl::opt<bool>
 /// This is needed to support legacy tests that don't contain
 /// !vcall_visibility metadata (the mere presense of type tests
 /// previously implied hidden visibility).
-cl::opt<bool>
+static cl::opt<bool>
     WholeProgramVisibility("whole-program-visibility", cl::init(false),
                            cl::Hidden, cl::ZeroOrMore,
                            cl::desc("Enable whole program visibility"));
 
 /// Provide a way to force disable whole program for debugging or workarounds,
 /// when enabled via the linker.
-cl::opt<bool> DisableWholeProgramVisibility(
+static cl::opt<bool> DisableWholeProgramVisibility(
     "disable-whole-program-visibility", cl::init(false), cl::Hidden,
     cl::ZeroOrMore,
     cl::desc("Disable whole program visibility (overrides enabling options)"));
 
 /// Provide way to prevent certain function from being devirtualized
-cl::list<std::string>
+static cl::list<std::string>
     SkipFunctionNames("wholeprogramdevirt-skip",
                       cl::desc("Prevent function(s) from being devirtualized"),
                       cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated);
@@ -166,7 +166,7 @@ cl::list<std::string>
 /// Mechanism to add runtime checking of devirtualization decisions, trapping on
 /// any that are not correct. Useful for debugging undefined behavior leading to
 /// failures with WPD.
-cl::opt<bool>
+static cl::opt<bool>
     CheckDevirt("wholeprogramdevirt-check", cl::init(false), cl::Hidden,
                 cl::ZeroOrMore,
                 cl::desc("Add code to trap on incorrect devirtualizations"));

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index bd4fd84441d89..c8f8a75dc6de0 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -90,9 +90,11 @@ static cl::opt<unsigned> GuardWideningWindow(
     cl::desc("How wide an instruction window to bypass looking for "
              "another guard"));
 
+namespace llvm {
 /// enable preservation of attributes in assume like:
 /// call void @llvm.assume(i1 true) [ "nonnull"(i32* %PTR) ]
 extern cl::opt<bool> EnableKnowledgeRetention;
+} // namespace llvm
 
 /// Return the specified type promoted as it would be to pass though a va_arg
 /// area.

diff  --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 0534830f0f336..3d9261eb99ba4 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -280,6 +280,7 @@ static cl::opt<unsigned> PGOVerifyBFICutoff(
     cl::desc("Set the threshold for pgo-verify-bfi -- skip the counts whose "
              "profile count value is below."));
 
+namespace llvm {
 // Command line option to turn on CFG dot dump after profile annotation.
 // Defined in Analysis/BlockFrequencyInfo.cpp:  -pgo-view-counts
 extern cl::opt<PGOViewCountsType> PGOViewCounts;
@@ -287,6 +288,7 @@ extern cl::opt<PGOViewCountsType> PGOViewCounts;
 // Command line option to specify the name of the function for CFG dump
 // Defined in Analysis/BlockFrequencyInfo.cpp:  -view-bfi-func-name=
 extern cl::opt<std::string> ViewBlockFreqFuncName;
+} // namespace llvm
 
 static cl::opt<bool>
     PGOOldCFGHashing("pgo-instr-old-cfg-hashing", cl::init(false), cl::Hidden,

diff  --git a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
index 2804c3c523da3..f8c66035c65bf 100644
--- a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
+++ b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
@@ -25,6 +25,7 @@
 
 using namespace llvm;
 
+namespace llvm {
 cl::opt<bool> ShouldPreserveAllAttributes(
     "assume-preserve-all", cl::init(false), cl::Hidden,
     cl::desc("enable preservation of all attrbitues. even those that are "
@@ -34,6 +35,7 @@ cl::opt<bool> EnableKnowledgeRetention(
     "enable-knowledge-retention", cl::init(false), cl::Hidden,
     cl::desc(
         "enable preservation of attributes throughout code transformation"));
+} // namespace llvm
 
 #define DEBUG_TYPE "assume-builder"
 

diff  --git a/llvm/lib/Transforms/Utils/SizeOpts.cpp b/llvm/lib/Transforms/Utils/SizeOpts.cpp
index beeb60698f045..08a29ea16ba11 100644
--- a/llvm/lib/Transforms/Utils/SizeOpts.cpp
+++ b/llvm/lib/Transforms/Utils/SizeOpts.cpp
@@ -14,45 +14,45 @@
 
 using namespace llvm;
 
-cl::opt<bool> EnablePGSO(
+cl::opt<bool> llvm::EnablePGSO(
     "pgso", cl::Hidden, cl::init(true),
     cl::desc("Enable the profile guided size optimizations. "));
 
-cl::opt<bool> PGSOLargeWorkingSetSizeOnly(
+cl::opt<bool> llvm::PGSOLargeWorkingSetSizeOnly(
     "pgso-lwss-only", cl::Hidden, cl::init(true),
     cl::desc("Apply the profile guided size optimizations only "
              "if the working set size is large (except for cold code.)"));
 
-cl::opt<bool> PGSOColdCodeOnly(
+cl::opt<bool> llvm::PGSOColdCodeOnly(
     "pgso-cold-code-only", cl::Hidden, cl::init(false),
     cl::desc("Apply the profile guided size optimizations only "
              "to cold code."));
 
-cl::opt<bool> PGSOColdCodeOnlyForInstrPGO(
+cl::opt<bool> llvm::PGSOColdCodeOnlyForInstrPGO(
     "pgso-cold-code-only-for-instr-pgo", cl::Hidden, cl::init(false),
     cl::desc("Apply the profile guided size optimizations only "
              "to cold code under instrumentation PGO."));
 
-cl::opt<bool> PGSOColdCodeOnlyForSamplePGO(
+cl::opt<bool> llvm::PGSOColdCodeOnlyForSamplePGO(
     "pgso-cold-code-only-for-sample-pgo", cl::Hidden, cl::init(false),
     cl::desc("Apply the profile guided size optimizations only "
              "to cold code under sample PGO."));
 
-cl::opt<bool> PGSOColdCodeOnlyForPartialSamplePGO(
+cl::opt<bool> llvm::PGSOColdCodeOnlyForPartialSamplePGO(
     "pgso-cold-code-only-for-partial-sample-pgo", cl::Hidden, cl::init(false),
     cl::desc("Apply the profile guided size optimizations only "
              "to cold code under partial-profile sample PGO."));
 
-cl::opt<bool> ForcePGSO(
+cl::opt<bool> llvm::ForcePGSO(
     "force-pgso", cl::Hidden, cl::init(false),
     cl::desc("Force the (profiled-guided) size optimizations. "));
 
-cl::opt<int> PgsoCutoffInstrProf(
+cl::opt<int> llvm::PgsoCutoffInstrProf(
     "pgso-cutoff-instr-prof", cl::Hidden, cl::init(950000), cl::ZeroOrMore,
     cl::desc("The profile guided size optimization profile summary cutoff "
              "for instrumentation profile."));
 
-cl::opt<int> PgsoCutoffSampleProf(
+cl::opt<int> llvm::PgsoCutoffSampleProf(
     "pgso-cutoff-sample-prof", cl::Hidden, cl::init(990000), cl::ZeroOrMore,
     cl::desc("The profile guided size optimization profile summary cutoff "
              "for sample profile."));

diff  --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index b41b61c3580a4..02a19d0fd500e 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -121,11 +121,13 @@ static cl::opt<std::string> OptimizerLastEPPipeline(
 // Individual pipeline tuning options.
 extern cl::opt<bool> DisableLoopUnrolling;
 
+namespace llvm {
 extern cl::opt<PGOKind> PGOKindFlag;
 extern cl::opt<std::string> ProfileFile;
 extern cl::opt<CSPGOKind> CSPGOKindFlag;
 extern cl::opt<std::string> CSProfileGenFile;
 extern cl::opt<bool> DisableBasicAA;
+} // namespace llvm
 
 static cl::opt<std::string>
     ProfileRemappingFile("profile-remapping-file",

diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 8e32c25a99550..254fd6abe66df 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -313,6 +313,7 @@ static cl::opt<std::string> RemarksFormat(
     cl::desc("The format used for serializing remarks (default: YAML)"),
     cl::value_desc("format"), cl::init("yaml"));
 
+namespace llvm {
 cl::opt<PGOKind>
     PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
                 cl::desc("The kind of profile guided optimization"),
@@ -341,6 +342,7 @@ cl::opt<std::string> CSProfileGenFile(
     "cs-profilegen-file",
     cl::desc("Path to the instrumented context sensitive profile."),
     cl::Hidden);
+} // namespace llvm
 
 static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
   // Add the pass to the pass manager...

diff  --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
index c33e20671bebc..28ebb8cda01bb 100644
--- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -20,8 +20,10 @@
 
 using namespace llvm;
 
+namespace llvm {
 extern cl::opt<bool> ShouldPreserveAllAttributes;
 extern cl::opt<bool> EnableKnowledgeRetention;
+} // namespace llvm
 
 static void RunTest(
     StringRef Head, StringRef Tail,

diff  --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
index d4e70d3dce4a6..a32428583c863 100644
--- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
+++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
@@ -47,7 +47,7 @@ using namespace llvm;
 #define SCOP_STAT(NAME, DESC)                                                  \
   { "polly-detect", "NAME", "Number of rejected regions: " DESC }
 
-Statistic RejectStatistics[] = {
+static Statistic RejectStatistics[] = {
     SCOP_STAT(CFG, ""),
     SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
     SCOP_STAT(UnreachableInExit, "Unreachable in exit block"),


        


More information about the llvm-commits mailing list