[llvm] [NFC][LLVM][NVPTX] Cleanup pass initialization for NVPTX (PR #134311)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 4 08:46:56 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-nvptx
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
- Move all pass initialization function calls to NVPTX target initialization and out of individual pass constructors.
- Move all pass initialization function declaration to NVPTX.h.
- https://github.com/llvm/llvm-project/issues/111767
---
Full diff: https://github.com/llvm/llvm-project/pull/134311.diff
19 Files Affected:
- (modified) llvm/lib/Target/NVPTX/NVPTX.h (+18)
- (modified) llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp (+1-3)
- (modified) llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h (-2)
- (modified) llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp (+1-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h (+1-1)
- (modified) llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp (-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXAtomicLower.cpp (+1-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp (-1)
- (modified) llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h (-3)
- (modified) llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp (+1-7)
- (modified) llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp (+1-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp (-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp (-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp (-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXPeephole.cpp (+1-7)
- (modified) llvm/lib/Target/NVPTX/NVPTXProxyRegErasure.cpp (+1-7)
- (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+1-21)
- (modified) llvm/lib/Target/NVPTX/NVVMIntrRange.cpp (+1-6)
- (modified) llvm/lib/Target/NVPTX/NVVMReflect.cpp (+1-7)
``````````diff
diff --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h
index 20a5bf46dc06b..ff983e52179af 100644
--- a/llvm/lib/Target/NVPTX/NVPTX.h
+++ b/llvm/lib/Target/NVPTX/NVPTX.h
@@ -55,6 +55,24 @@ MachineFunctionPass *createNVPTXPeephole();
MachineFunctionPass *createNVPTXProxyRegErasurePass();
MachineFunctionPass *createNVPTXForwardParamsPass();
+void initializeGenericToNVVMLegacyPassPass(PassRegistry &);
+void initializeNVPTXAllocaHoistingPass(PassRegistry &);
+void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry &);
+void initializeNVPTXAtomicLowerPass(PassRegistry &);
+void initializeNVPTXCtorDtorLoweringLegacyPass(PassRegistry &);
+void initializeNVPTXLowerAggrCopiesPass(PassRegistry &);
+void initializeNVPTXLowerAllocaPass(PassRegistry &);
+void initializeNVPTXLowerUnreachablePass(PassRegistry &);
+void initializeNVPTXCtorDtorLoweringLegacyPass(PassRegistry &);
+void initializeNVPTXLowerArgsLegacyPassPass(PassRegistry &);
+void initializeNVPTXProxyRegErasurePass(PassRegistry &);
+void initializeNVPTXForwardParamsPassPass(PassRegistry &);
+void initializeNVVMIntrRangePass(PassRegistry &);
+void initializeNVVMReflectPass(PassRegistry &);
+void initializeNVPTXAAWrapperPassPass(PassRegistry &);
+void initializeNVPTXExternalAAWrapperPass(PassRegistry &);
+void initializeNVPTXPeepholePass(PassRegistry &);
+
struct NVVMIntrRangePass : PassInfoMixin<NVVMIntrRangePass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp b/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp
index 1f770893828e2..b910ccab21bf3 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp
@@ -45,9 +45,7 @@ ImmutablePass *llvm::createNVPTXExternalAAWrapperPass() {
return new NVPTXExternalAAWrapper();
}
-NVPTXAAWrapperPass::NVPTXAAWrapperPass() : ImmutablePass(ID) {
- initializeNVPTXAAWrapperPassPass(*PassRegistry::getPassRegistry());
-}
+NVPTXAAWrapperPass::NVPTXAAWrapperPass() : ImmutablePass(ID) {}
void NVPTXAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
diff --git a/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h b/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h
index cfbf5dee3ec50..a82c3aaa72423 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h
+++ b/llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h
@@ -98,9 +98,7 @@ class NVPTXExternalAAWrapper : public ExternalAAWrapperPass {
};
ImmutablePass *createNVPTXAAWrapperPass();
-void initializeNVPTXAAWrapperPassPass(PassRegistry &);
ImmutablePass *createNVPTXExternalAAWrapperPass();
-void initializeNVPTXExternalAAWrapperPass(PassRegistry &);
} // end namespace llvm
diff --git a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp
index f676496453f9f..8a8e423a2eb71 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "NVPTXAllocaHoisting.h"
+#include "NVPTX.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
@@ -57,10 +58,6 @@ bool NVPTXAllocaHoisting::runOnFunction(Function &function) {
char NVPTXAllocaHoisting::ID = 0;
-namespace llvm {
-void initializeNVPTXAllocaHoistingPass(PassRegistry &);
-}
-
INITIALIZE_PASS(
NVPTXAllocaHoisting, "alloca-hoisting",
"Hoisting alloca instructions in non-entry blocks to the entry block",
diff --git a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h
index d7de8e3a2f46a..a75a83fbb061c 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h
+++ b/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h
@@ -16,7 +16,7 @@
namespace llvm {
class FunctionPass;
-extern FunctionPass *createAllocaHoisting();
+FunctionPass *createAllocaHoisting();
} // end namespace llvm
#endif
diff --git a/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp b/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
index 724ef7fe98322..15417a15f389b 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAssignValidGlobalNames.cpp
@@ -38,10 +38,6 @@ class NVPTXAssignValidGlobalNames : public ModulePass {
char NVPTXAssignValidGlobalNames::ID = 0;
-namespace llvm {
-void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry &);
-}
-
INITIALIZE_PASS(NVPTXAssignValidGlobalNames, "nvptx-assign-valid-global-names",
"Assign valid PTX names to globals", false, false)
diff --git a/llvm/lib/Target/NVPTX/NVPTXAtomicLower.cpp b/llvm/lib/Target/NVPTX/NVPTXAtomicLower.cpp
index 5a3b110cf278d..918daf6c04ecd 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAtomicLower.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAtomicLower.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "NVPTXAtomicLower.h"
+#include "NVPTX.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
@@ -55,10 +56,6 @@ bool NVPTXAtomicLower::runOnFunction(Function &F) {
char NVPTXAtomicLower::ID = 0;
-namespace llvm {
-void initializeNVPTXAtomicLowerPass(PassRegistry &);
-}
-
INITIALIZE_PASS(NVPTXAtomicLower, "nvptx-atomic-lower",
"Lower atomics of local memory to simple load/stores", false,
false)
diff --git a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp
index b10e0b14118a1..bb8cec05f4d84 100644
--- a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp
@@ -256,7 +256,6 @@ PreservedAnalyses NVPTXCtorDtorLoweringPass::run(Module &M,
}
char NVPTXCtorDtorLoweringLegacy::ID = 0;
-char &llvm::NVPTXCtorDtorLoweringLegacyPassID = NVPTXCtorDtorLoweringLegacy::ID;
INITIALIZE_PASS(NVPTXCtorDtorLoweringLegacy, DEBUG_TYPE,
"Lower ctors and dtors for NVPTX", false, false)
diff --git a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
index c03fe97f1a782..df58ddd3e78fc 100644
--- a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
+++ b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
@@ -15,9 +15,6 @@ namespace llvm {
class Module;
class PassRegistry;
-extern char &NVPTXCtorDtorLoweringLegacyPassID;
-extern void initializeNVPTXCtorDtorLoweringLegacyPass(PassRegistry &);
-
/// Lower llvm.global_ctors and llvm.global_dtors to special kernels.
class NVPTXCtorDtorLoweringPass
: public PassInfoMixin<NVPTXCtorDtorLoweringPass> {
diff --git a/llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp b/llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp
index 47d44b985363d..f5063a80b8a15 100644
--- a/llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp
@@ -136,16 +136,10 @@ static bool forwardDeviceParams(MachineFunction &MF) {
/// Pass (Manager) Boilerplate
/// ----------------------------------------------------------------------------
-namespace llvm {
-void initializeNVPTXForwardParamsPassPass(PassRegistry &);
-} // namespace llvm
-
namespace {
struct NVPTXForwardParamsPass : public MachineFunctionPass {
static char ID;
- NVPTXForwardParamsPass() : MachineFunctionPass(ID) {
- initializeNVPTXForwardParamsPassPass(*PassRegistry::getPassRegistry());
- }
+ NVPTXForwardParamsPass() : MachineFunctionPass(ID) {}
bool runOnMachineFunction(MachineFunction &MF) override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
index 0f0e7c2f8227e..ac6f4061b9f1f 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "NVPTXLowerAggrCopies.h"
+#include "NVPTX.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/IR/Constants.h"
@@ -137,10 +138,6 @@ bool NVPTXLowerAggrCopies::runOnFunction(Function &F) {
} // namespace
-namespace llvm {
-void initializeNVPTXLowerAggrCopiesPass(PassRegistry &);
-}
-
INITIALIZE_PASS(NVPTXLowerAggrCopies, "nvptx-lower-aggr-copies",
"Lower aggregate copies, and llvm.mem* intrinsics into loops",
false, false)
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
index 3b44a86013f04..88bc000f39bf7 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
@@ -33,10 +33,6 @@
using namespace llvm;
-namespace llvm {
-void initializeNVPTXLowerAllocaPass(PassRegistry &);
-}
-
namespace {
class NVPTXLowerAlloca : public FunctionPass {
bool runOnFunction(Function &F) override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
index 2637b9fab0d50..89da37d32b6d4 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
@@ -161,10 +161,6 @@
using namespace llvm;
-namespace llvm {
-void initializeNVPTXLowerArgsLegacyPassPass(PassRegistry &);
-}
-
namespace {
class NVPTXLowerArgsLegacyPass : public FunctionPass {
bool runOnFunction(Function &F) override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp
index a289d35f9b3f1..00a12bf818897 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp
@@ -78,10 +78,6 @@
using namespace llvm;
-namespace llvm {
-void initializeNVPTXLowerUnreachablePass(PassRegistry &);
-}
-
namespace {
class NVPTXLowerUnreachable : public FunctionPass {
StringRef getPassName() const override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXPeephole.cpp b/llvm/lib/Target/NVPTX/NVPTXPeephole.cpp
index f2f547da88c7c..e9b0aaeca4964 100644
--- a/llvm/lib/Target/NVPTX/NVPTXPeephole.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXPeephole.cpp
@@ -44,17 +44,11 @@ using namespace llvm;
#define DEBUG_TYPE "nvptx-peephole"
-namespace llvm {
-void initializeNVPTXPeepholePass(PassRegistry &);
-}
-
namespace {
struct NVPTXPeephole : public MachineFunctionPass {
public:
static char ID;
- NVPTXPeephole() : MachineFunctionPass(ID) {
- initializeNVPTXPeepholePass(*PassRegistry::getPassRegistry());
- }
+ NVPTXPeephole() : MachineFunctionPass(ID) {}
bool runOnMachineFunction(MachineFunction &MF) override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXProxyRegErasure.cpp b/llvm/lib/Target/NVPTX/NVPTXProxyRegErasure.cpp
index 8dfa2ebe80c3a..2253afa2806c3 100644
--- a/llvm/lib/Target/NVPTX/NVPTXProxyRegErasure.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXProxyRegErasure.cpp
@@ -24,17 +24,11 @@
using namespace llvm;
-namespace llvm {
-void initializeNVPTXProxyRegErasurePass(PassRegistry &);
-}
-
namespace {
struct NVPTXProxyRegErasure : public MachineFunctionPass {
static char ID;
- NVPTXProxyRegErasure() : MachineFunctionPass(ID) {
- initializeNVPTXProxyRegErasurePass(*PassRegistry::getPassRegistry());
- }
+ NVPTXProxyRegErasure() : MachineFunctionPass(ID) {}
bool runOnMachineFunction(MachineFunction &MF) override;
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index 5bb168704bad0..8a25256ea1e4a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -87,27 +87,6 @@ static cl::opt<bool> EarlyByValArgsCopy(
cl::desc("Create a copy of byval function arguments early."),
cl::init(false), cl::Hidden);
-namespace llvm {
-
-void initializeGenericToNVVMLegacyPassPass(PassRegistry &);
-void initializeNVPTXAllocaHoistingPass(PassRegistry &);
-void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry &);
-void initializeNVPTXAtomicLowerPass(PassRegistry &);
-void initializeNVPTXCtorDtorLoweringLegacyPass(PassRegistry &);
-void initializeNVPTXLowerAggrCopiesPass(PassRegistry &);
-void initializeNVPTXLowerAllocaPass(PassRegistry &);
-void initializeNVPTXLowerUnreachablePass(PassRegistry &);
-void initializeNVPTXCtorDtorLoweringLegacyPass(PassRegistry &);
-void initializeNVPTXLowerArgsLegacyPassPass(PassRegistry &);
-void initializeNVPTXProxyRegErasurePass(PassRegistry &);
-void initializeNVPTXForwardParamsPassPass(PassRegistry &);
-void initializeNVVMIntrRangePass(PassRegistry &);
-void initializeNVVMReflectPass(PassRegistry &);
-void initializeNVPTXAAWrapperPassPass(PassRegistry &);
-void initializeNVPTXExternalAAWrapperPass(PassRegistry &);
-
-} // end namespace llvm
-
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTarget() {
// Register the target.
RegisterTargetMachine<NVPTXTargetMachine32> X(getTheNVPTXTarget32());
@@ -132,6 +111,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTarget() {
initializeNVPTXDAGToDAGISelLegacyPass(PR);
initializeNVPTXAAWrapperPassPass(PR);
initializeNVPTXExternalAAWrapperPass(PR);
+ initializeNVPTXPeepholePass(PR);
}
static std::string computeDataLayout(bool is64Bit, bool UseShortPointers) {
diff --git a/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp b/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
index 8286e9661f202..91b8e470e055e 100644
--- a/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
+++ b/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
@@ -25,16 +25,11 @@ using namespace llvm;
#define DEBUG_TYPE "nvvm-intr-range"
-namespace llvm { void initializeNVVMIntrRangePass(PassRegistry &); }
-
namespace {
class NVVMIntrRange : public FunctionPass {
public:
static char ID;
- NVVMIntrRange() : FunctionPass(ID) {
-
- initializeNVVMIntrRangePass(*PassRegistry::getPassRegistry());
- }
+ NVVMIntrRange() : FunctionPass(ID) {}
bool runOnFunction(Function &) override;
};
diff --git a/llvm/lib/Target/NVPTX/NVVMReflect.cpp b/llvm/lib/Target/NVPTX/NVVMReflect.cpp
index 20b8bef1899b4..2809ec2303f99 100644
--- a/llvm/lib/Target/NVPTX/NVVMReflect.cpp
+++ b/llvm/lib/Target/NVPTX/NVVMReflect.cpp
@@ -47,19 +47,13 @@ using namespace llvm;
#define DEBUG_TYPE "nvptx-reflect"
-namespace llvm {
-void initializeNVVMReflectPass(PassRegistry &);
-}
-
namespace {
class NVVMReflect : public FunctionPass {
public:
static char ID;
unsigned int SmVersion;
NVVMReflect() : NVVMReflect(0) {}
- explicit NVVMReflect(unsigned int Sm) : FunctionPass(ID), SmVersion(Sm) {
- initializeNVVMReflectPass(*PassRegistry::getPassRegistry());
- }
+ explicit NVVMReflect(unsigned int Sm) : FunctionPass(ID), SmVersion(Sm) {}
bool runOnFunction(Function &) override;
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/134311
More information about the llvm-commits
mailing list