Put implementation details into anonymous namespaces. NFCI.

This commit is contained in:
Benjamin Kramer 2021-11-07 15:18:30 +01:00
parent 8adb6d6de2
commit 9b8b16457c
14 changed files with 31 additions and 2 deletions

View File

@ -715,6 +715,7 @@ PreservedAnalyses LintPass::run(Function &F, FunctionAnalysisManager &AM) {
return PreservedAnalyses::all(); return PreservedAnalyses::all();
} }
namespace {
class LintLegacyPass : public FunctionPass { class LintLegacyPass : public FunctionPass {
public: public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
@ -733,6 +734,7 @@ public:
} }
void print(raw_ostream &O, const Module *M) const override {} void print(raw_ostream &O, const Module *M) const override {}
}; };
} // namespace
char LintLegacyPass::ID = 0; char LintLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(LintLegacyPass, "lint", "Statically lint-checks LLVM IR", INITIALIZE_PASS_BEGIN(LintLegacyPass, "lint", "Statically lint-checks LLVM IR",

View File

@ -52,6 +52,7 @@ static cl::opt<unsigned> InputDbgValueLimit(
"Maximum input DBG_VALUE insts supported by debug range extension"), "Maximum input DBG_VALUE insts supported by debug range extension"),
cl::init(50000), cl::Hidden); cl::init(50000), cl::Hidden);
namespace {
/// Generic LiveDebugValues pass. Calls through to VarLocBasedLDV or /// Generic LiveDebugValues pass. Calls through to VarLocBasedLDV or
/// InstrRefBasedLDV to perform location propagation, via the LDVImpl /// InstrRefBasedLDV to perform location propagation, via the LDVImpl
/// base class. /// base class.
@ -81,6 +82,7 @@ private:
TargetPassConfig *TPC; TargetPassConfig *TPC;
MachineDominatorTree MDT; MachineDominatorTree MDT;
}; };
} // namespace
char LiveDebugValues::ID = 0; char LiveDebugValues::ID = 0;

View File

@ -1117,6 +1117,7 @@ public:
} }
}; };
namespace {
/// Directory iterator implementation for \c RedirectingFileSystem's /// Directory iterator implementation for \c RedirectingFileSystem's
/// directory remap entries that maps the paths reported by the external /// directory remap entries that maps the paths reported by the external
/// file system's directory iterator back to the virtual directory's path. /// file system's directory iterator back to the virtual directory's path.
@ -1155,6 +1156,7 @@ public:
return EC; return EC;
} }
}; };
} // namespace
llvm::ErrorOr<std::string> llvm::ErrorOr<std::string>
RedirectingFileSystem::getCurrentWorkingDirectory() const { RedirectingFileSystem::getCurrentWorkingDirectory() const {

View File

@ -112,6 +112,7 @@ static bool isDSAddress(const Constant *C) {
return AS == AMDGPUAS::LOCAL_ADDRESS || AS == AMDGPUAS::REGION_ADDRESS; return AS == AMDGPUAS::LOCAL_ADDRESS || AS == AMDGPUAS::REGION_ADDRESS;
} }
namespace {
class AMDGPUInformationCache : public InformationCache { class AMDGPUInformationCache : public InformationCache {
public: public:
AMDGPUInformationCache(const Module &M, AnalysisGetter &AG, AMDGPUInformationCache(const Module &M, AnalysisGetter &AG,
@ -643,6 +644,7 @@ public:
TargetMachine *TM; TargetMachine *TM;
static char ID; static char ID;
}; };
} // namespace
char AMDGPUAttributor::ID = 0; char AMDGPUAttributor::ID = 0;

View File

@ -24,6 +24,7 @@ using namespace llvm;
MipsCallLowering::MipsCallLowering(const MipsTargetLowering &TLI) MipsCallLowering::MipsCallLowering(const MipsTargetLowering &TLI)
: CallLowering(&TLI) {} : CallLowering(&TLI) {}
namespace {
struct MipsOutgoingValueAssigner : public CallLowering::OutgoingValueAssigner { struct MipsOutgoingValueAssigner : public CallLowering::OutgoingValueAssigner {
/// This is the name of the function being called /// This is the name of the function being called
/// FIXME: Relying on this is unsound /// FIXME: Relying on this is unsound
@ -80,7 +81,6 @@ struct MipsIncomingValueAssigner : public CallLowering::IncomingValueAssigner {
} }
}; };
namespace {
class MipsIncomingValueHandler : public CallLowering::IncomingValueHandler { class MipsIncomingValueHandler : public CallLowering::IncomingValueHandler {
const MipsSubtarget &STI; const MipsSubtarget &STI;

View File

@ -630,6 +630,7 @@ bool X86LowerAMXIntrinsics::visit() {
return C; return C;
} }
namespace {
class X86LowerAMXIntrinsicsLegacyPass : public FunctionPass { class X86LowerAMXIntrinsicsLegacyPass : public FunctionPass {
public: public:
static char ID; static char ID;
@ -664,6 +665,7 @@ public:
AU.addRequired<TargetPassConfig>(); AU.addRequired<TargetPassConfig>();
} }
}; };
} // namespace
static const char PassName[] = "Lower AMX intrinsics"; static const char PassName[] = "Lower AMX intrinsics";
char X86LowerAMXIntrinsicsLegacyPass::ID = 0; char X86LowerAMXIntrinsicsLegacyPass::ID = 0;

View File

@ -483,6 +483,7 @@ static void clampReturnedValueStates(
S ^= *T; S ^= *T;
} }
namespace {
/// Helper class for generic deduction: return value -> returned position. /// Helper class for generic deduction: return value -> returned position.
template <typename AAType, typename BaseType, template <typename AAType, typename BaseType,
typename StateType = typename BaseType::StateType, typename StateType = typename BaseType::StateType,
@ -641,6 +642,7 @@ struct AACallSiteReturnedFromReturned : public BaseType {
return clampStateAndIndicateChange(S, AA.getState()); return clampStateAndIndicateChange(S, AA.getState());
} }
}; };
} // namespace
/// Helper function to accumulate uses. /// Helper function to accumulate uses.
template <class AAType, typename StateType = typename AAType::StateType> template <class AAType, typename StateType = typename AAType::StateType>
@ -1031,6 +1033,7 @@ private:
BooleanState BS; BooleanState BS;
}; };
namespace {
struct AAPointerInfoImpl struct AAPointerInfoImpl
: public StateWrapper<AA::PointerInfo::State, AAPointerInfo> { : public StateWrapper<AA::PointerInfo::State, AAPointerInfo> {
using BaseTy = StateWrapper<AA::PointerInfo::State, AAPointerInfo>; using BaseTy = StateWrapper<AA::PointerInfo::State, AAPointerInfo>;
@ -5074,6 +5077,7 @@ struct AANoCaptureCallSiteReturned final : AANoCaptureImpl {
STATS_DECLTRACK_CSRET_ATTR(nocapture) STATS_DECLTRACK_CSRET_ATTR(nocapture)
} }
}; };
} // namespace
/// ------------------ Value Simplify Attribute ---------------------------- /// ------------------ Value Simplify Attribute ----------------------------
@ -5094,6 +5098,7 @@ bool ValueSimplifyStateType::unionAssumed(Optional<Value *> Other) {
return true; return true;
} }
namespace {
struct AAValueSimplifyImpl : AAValueSimplify { struct AAValueSimplifyImpl : AAValueSimplify {
AAValueSimplifyImpl(const IRPosition &IRP, Attributor &A) AAValueSimplifyImpl(const IRPosition &IRP, Attributor &A)
: AAValueSimplify(IRP, A) {} : AAValueSimplify(IRP, A) {}
@ -7373,6 +7378,7 @@ void AAMemoryBehaviorFloating::analyzeUseIn(Attributor &A, const Use &U,
if (UserI->mayWriteToMemory()) if (UserI->mayWriteToMemory())
removeAssumedBits(NO_WRITES); removeAssumedBits(NO_WRITES);
} }
} // namespace
/// -------------------- Memory Locations Attributes --------------------------- /// -------------------- Memory Locations Attributes ---------------------------
/// Includes read-none, argmemonly, inaccessiblememonly, /// Includes read-none, argmemonly, inaccessiblememonly,

View File

@ -229,6 +229,7 @@ static void removeSSACopy(Module &M) {
removeSSACopy(F); removeSSACopy(F);
} }
namespace {
class FunctionSpecializer { class FunctionSpecializer {
/// The IPSCCP Solver. /// The IPSCCP Solver.
@ -737,6 +738,7 @@ private:
} }
} }
}; };
} // namespace
bool llvm::runFunctionSpecialization( bool llvm::runFunctionSpecialization(
Module &M, const DataLayout &DL, Module &M, const DataLayout &DL,

View File

@ -2206,6 +2206,7 @@ bool IROutliner::run(Module &M) {
} }
// Pass Manager Boilerplate // Pass Manager Boilerplate
namespace {
class IROutlinerLegacyPass : public ModulePass { class IROutlinerLegacyPass : public ModulePass {
public: public:
static char ID; static char ID;
@ -2221,6 +2222,7 @@ public:
bool runOnModule(Module &M) override; bool runOnModule(Module &M) override;
}; };
} // namespace
bool IROutlinerLegacyPass::runOnModule(Module &M) { bool IROutlinerLegacyPass::runOnModule(Module &M) {
if (skipModule(M)) if (skipModule(M))

View File

@ -135,6 +135,7 @@ PreservedAnalyses FunctionSpecializationPass::run(Module &M,
return PA; return PA;
} }
namespace {
struct FunctionSpecializationLegacyPass : public ModulePass { struct FunctionSpecializationLegacyPass : public ModulePass {
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
FunctionSpecializationLegacyPass() : ModulePass(ID) {} FunctionSpecializationLegacyPass() : ModulePass(ID) {}
@ -175,6 +176,7 @@ struct FunctionSpecializationLegacyPass : public ModulePass {
return runFunctionSpecialization(M, DL, GetTLI, GetTTI, GetAC, GetAnalysis); return runFunctionSpecialization(M, DL, GetTLI, GetTTI, GetAC, GetAnalysis);
} }
}; };
} // namespace
char FunctionSpecializationLegacyPass::ID = 0; char FunctionSpecializationLegacyPass::ID = 0;

View File

@ -1763,6 +1763,7 @@ bool LoopInterchangeTransform::adjustLoopLinks() {
return Changed; return Changed;
} }
namespace {
/// Main LoopInterchange Pass. /// Main LoopInterchange Pass.
struct LoopInterchangeLegacyPass : public LoopPass { struct LoopInterchangeLegacyPass : public LoopPass {
static char ID; static char ID;
@ -1791,6 +1792,7 @@ struct LoopInterchangeLegacyPass : public LoopPass {
return LoopInterchange(SE, LI, DI, DT, ORE).run(L); return LoopInterchange(SE, LI, DI, DT, ORE).run(L);
} }
}; };
} // namespace
char LoopInterchangeLegacyPass::ID = 0; char LoopInterchangeLegacyPass::ID = 0;

View File

@ -5868,6 +5868,7 @@ void LoopStrengthReduce::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<MemorySSAWrapperPass>(); AU.addPreserved<MemorySSAWrapperPass>();
} }
namespace {
struct SCEVDbgValueBuilder { struct SCEVDbgValueBuilder {
SCEVDbgValueBuilder() = default; SCEVDbgValueBuilder() = default;
SCEVDbgValueBuilder(const SCEVDbgValueBuilder &Base) { SCEVDbgValueBuilder(const SCEVDbgValueBuilder &Base) {
@ -6115,6 +6116,7 @@ struct DVIRecoveryRec {
Metadata *LocationOp; Metadata *LocationOp;
const llvm::SCEV *SCEV; const llvm::SCEV *SCEV;
}; };
} // namespace
static void RewriteDVIUsingIterCount(DVIRecoveryRec CachedDVI, static void RewriteDVIUsingIterCount(DVIRecoveryRec CachedDVI,
const SCEVDbgValueBuilder &IterationCount, const SCEVDbgValueBuilder &IterationCount,

View File

@ -828,6 +828,7 @@ static void PropagateCallSiteMetadata(CallBase &CB, Function::iterator FStart,
} }
} }
namespace {
/// Utility for cloning !noalias and !alias.scope metadata. When a code region /// Utility for cloning !noalias and !alias.scope metadata. When a code region
/// using scoped alias metadata is inlined, the aliasing relationships may not /// using scoped alias metadata is inlined, the aliasing relationships may not
/// hold between the two version. It is necessary to create a deep clone of the /// hold between the two version. It is necessary to create a deep clone of the
@ -849,6 +850,7 @@ public:
/// metadata. /// metadata.
void remap(Function::iterator FStart, Function::iterator FEnd); void remap(Function::iterator FStart, Function::iterator FEnd);
}; };
} // namespace
ScopedAliasMetadataDeepCloner::ScopedAliasMetadataDeepCloner( ScopedAliasMetadataDeepCloner::ScopedAliasMetadataDeepCloner(
const Function *F) { const Function *F) {

View File

@ -942,6 +942,7 @@ bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
} // namespace llvm } // namespace llvm
namespace {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Widen Induction Variables - Extend the width of an IV to cover its // Widen Induction Variables - Extend the width of an IV to cover its
// widest uses. // widest uses.
@ -1072,7 +1073,7 @@ protected:
private: private:
SmallVector<NarrowIVDefUse, 8> NarrowIVUsers; SmallVector<NarrowIVDefUse, 8> NarrowIVUsers;
}; };
} // namespace
/// Determine the insertion point for this user. By default, insert immediately /// Determine the insertion point for this user. By default, insert immediately
/// before the user. SCEVExpander or LICM will hoist loop invariants out of the /// before the user. SCEVExpander or LICM will hoist loop invariants out of the