Skip to content

Commit 11a4b2d

Browse files
authored
Cleanup the LLVM exported symbols namespace (#161240)
There's a pattern throughout LLVM of cl::opts being exported. That in itself is probably a bit unfortunate, but what's especially bad about it is that a lot of those symbols are in the global namespace. Move them into the llvm namespace. While doing this, I noticed some other variables in the global namespace and moved them as well.
1 parent bdd98a0 commit 11a4b2d

39 files changed

+118
-38
lines changed

llvm/include/llvm/Target/TargetMachine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#include <string>
3030
#include <utility>
3131

32-
LLVM_ABI extern llvm::cl::opt<bool> NoKernelInfoEndLTO;
33-
3432
namespace llvm {
3533

34+
LLVM_ABI extern llvm::cl::opt<bool> NoKernelInfoEndLTO;
35+
3636
class AAManager;
3737
using ModulePassManager = PassManager<Module>;
3838

llvm/lib/Analysis/CtxProfAnalysis.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#define DEBUG_TYPE "ctx_prof"
3131

3232
using namespace llvm;
33+
34+
namespace llvm {
35+
3336
cl::opt<std::string>
3437
UseCtxProfile("use-ctx-profile", cl::init(""), cl::Hidden,
3538
cl::desc("Use the specified contextual profile file"));
@@ -50,7 +53,6 @@ static cl::opt<bool> ForceIsInSpecializedModule(
5053

5154
const char *AssignGUIDPass::GUIDMetadataName = "guid";
5255

53-
namespace llvm {
5456
class ProfileAnnotatorImpl final {
5557
friend class ProfileAnnotator;
5658
class BBInfo;

llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ using namespace llvm;
2222

2323
#define DEBUG_TYPE "pgo-icall-prom-analysis"
2424

25+
namespace llvm {
26+
2527
// The percent threshold for the direct-call target (this call site vs the
2628
// remaining call count) for it to be considered as the promotion target.
2729
static cl::opt<unsigned> ICPRemainingPercentThreshold(
@@ -54,6 +56,8 @@ cl::opt<unsigned> MaxNumVTableAnnotations(
5456
"icp-max-num-vtables", cl::init(6), cl::Hidden,
5557
cl::desc("Max number of vtables annotated for a vtable load instruction."));
5658

59+
} // end namespace llvm
60+
5761
bool ICallPromotionAnalysis::isPromotionProfitable(uint64_t Count,
5862
uint64_t TotalCount,
5963
uint64_t RemainingCount) {

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ using namespace llvm::memprof;
2222

2323
#define DEBUG_TYPE "memory-profile-info"
2424

25+
namespace llvm {
26+
2527
cl::opt<bool> MemProfReportHintedSizes(
2628
"memprof-report-hinted-sizes", cl::init(false), cl::Hidden,
2729
cl::desc("Report total allocation sizes of hinted allocations"));
@@ -52,6 +54,8 @@ cl::opt<unsigned> MinPercentMaxColdSize(
5254
"memprof-min-percent-max-cold-size", cl::init(100), cl::Hidden,
5355
cl::desc("Min percent of max cold bytes for critical cold context"));
5456

57+
} // end namespace llvm
58+
5559
bool llvm::memprof::metadataIncludesAllContextSizeInfo() {
5660
return MemProfReportHintedSizes || MinClonedColdBytePercent < 100;
5761
}

llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ using namespace llvm::memprof;
6767
namespace llvm {
6868
FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold =
6969
FunctionSummary::FSHT_None;
70-
} // namespace llvm
7170

7271
static cl::opt<FunctionSummary::ForceSummaryHotnessType, true> FSEC(
7372
"force-summary-edges-cold", cl::Hidden, cl::location(ForceSummaryEdgesCold),
@@ -91,6 +90,7 @@ LLVM_ABI extern cl::opt<bool> ScalePartialSampleProfileWorkingSetSize;
9190
extern cl::opt<unsigned> MaxNumVTableAnnotations;
9291

9392
extern cl::opt<bool> MemProfReportHintedSizes;
93+
} // namespace llvm
9494

9595
// Walk through the operands of a given User via worklist iteration and populate
9696
// the set of GlobalValue references encountered. Invoked either on an

llvm/lib/Analysis/ProfileSummaryInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <optional>
2525
using namespace llvm;
2626

27+
namespace llvm {
28+
2729
static cl::opt<bool> PartialProfile(
2830
"partial-profile", cl::Hidden, cl::init(false),
2931
cl::desc("Specify the current profile is used as a partial profile."));
@@ -44,6 +46,8 @@ static cl::opt<double> PartialSampleProfileWorkingSetSizeScaleFactor(
4446
"and the factor to scale the working set size to use the same "
4547
"shared thresholds as PGO."));
4648

49+
} // end namespace llvm
50+
4751
// The profile summary metadata may be attached either by the frontend or by
4852
// any backend passes (IR level instrumentation, for example). This method
4953
// checks if the Summary is null and if so checks if the summary metadata is now

llvm/lib/CGData/CodeGenData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ static cl::opt<bool>
3131
static cl::opt<std::string>
3232
CodeGenDataUsePath("codegen-data-use-path", cl::init(""), cl::Hidden,
3333
cl::desc("File path to where .cgdata file is read"));
34+
35+
namespace llvm {
3436
cl::opt<bool> CodeGenDataThinLTOTwoRounds(
3537
"codegen-data-thinlto-two-rounds", cl::init(false), cl::Hidden,
3638
cl::desc("Enable two-round ThinLTO code generation. The first round "
3739
"emits codegen data, while the second round uses the emitted "
3840
"codegen data for further optimizations."));
41+
} // end namespace llvm
3942

4043
static std::string getCGDataErrString(cgdata_error Err,
4144
const std::string &ErrMsg = "") {

llvm/lib/CGData/CodeGenDataReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ static cl::opt<bool> IndexedCodeGenDataReadFunctionMapNames(
2626
"disabled to save memory and time for final consumption of the "
2727
"indexed CodeGenData in production."));
2828

29+
namespace llvm {
30+
2931
cl::opt<bool> IndexedCodeGenDataLazyLoading(
3032
"indexed-codegen-data-lazy-loading", cl::init(false), cl::Hidden,
3133
cl::desc(
3234
"Lazily load indexed CodeGenData. Enable to save memory and time "
3335
"for final consumption of the indexed CodeGenData in production."));
3436

35-
namespace llvm {
36-
3737
static Expected<std::unique_ptr<MemoryBuffer>>
3838
setupMemoryBuffer(const Twine &Filename, vfs::FileSystem &FS) {
3939
auto BufferOrErr = Filename.str() == "-" ? MemoryBuffer::getSTDIN()

llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cl::opt<bool> llvm::DisableGISelLegalityCheck(
3434
cl::desc("Don't verify that MIR is fully legal between GlobalISel passes"),
3535
cl::Hidden);
3636

37-
cl::opt<bool> VerboseVerifyLegalizerInfo(
37+
static cl::opt<bool> VerboseVerifyLegalizerInfo(
3838
"verbose-gisel-verify-legalizer-info",
3939
cl::desc("Print more information to dbgs about GlobalISel legalizer rules "
4040
"being verified"),

llvm/lib/CodeGen/MachineRegionInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "llvm/ADT/Statistic.h"
1111
#include "llvm/Analysis/RegionInfoImpl.h"
1212
#include "llvm/CodeGen/MachinePostDominators.h"
13+
#include "llvm/CodeGen/Passes.h"
1314
#include "llvm/Config/llvm-config.h"
1415
#include "llvm/InitializePasses.h"
1516
#include "llvm/Pass.h"
@@ -127,7 +128,7 @@ LLVM_DUMP_METHOD void MachineRegionInfoPass::dump() const {
127128
#endif
128129

129130
char MachineRegionInfoPass::ID = 0;
130-
char &MachineRegionInfoPassID = MachineRegionInfoPass::ID;
131+
char &llvm::MachineRegionInfoPassID = MachineRegionInfoPass::ID;
131132

132133
INITIALIZE_PASS_BEGIN(MachineRegionInfoPass, DEBUG_TYPE,
133134
"Detect single entry single exit regions", true, true)

0 commit comments

Comments
 (0)