[llvm] [NVPTX] Add NewPM boilerplate to NVPTXAllocaHoisting (PR #215325)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 16:58:20 PDT 2026
================
@@ -56,11 +36,42 @@ bool NVPTXAllocaHoisting::runOnFunction(Function &function) {
return functionModified;
}
-char NVPTXAllocaHoisting::ID = 0;
+namespace {
+// Hoisting the alloca instructions in the non-entry blocks to the entry
+// block.
+class NVPTXAllocaHoistingLegacyPass : public FunctionPass {
+public:
+ static char ID; // Pass ID
+ NVPTXAllocaHoistingLegacyPass() : FunctionPass(ID) {}
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.addPreserved<StackProtector>();
+ }
+
+ StringRef getPassName() const override {
+ return "NVPTX specific alloca hoisting";
+ }
+
+ bool runOnFunction(Function &function) override {
+ return hoistAllocas(function);
+ }
+};
+} // namespace
+
+char NVPTXAllocaHoistingLegacyPass::ID = 0;
INITIALIZE_PASS(
- NVPTXAllocaHoisting, "alloca-hoisting",
+ NVPTXAllocaHoistingLegacyPass, "alloca-hoisting",
"Hoisting alloca instructions in non-entry blocks to the entry block",
false, false)
-FunctionPass *llvm::createAllocaHoisting() { return new NVPTXAllocaHoisting; }
+FunctionPass *llvm::createNVPTXAllocaHoistingLegacyPass() {
+ return new NVPTXAllocaHoistingLegacyPass;
+}
+
+PreservedAnalyses NVPTXAllocaHoistingPass::run(Function &F,
+ FunctionAnalysisManager &FAM) {
+ if (!hoistAllocas(F))
+ return PreservedAnalyses::all();
+ return PreservedAnalyses::none().preserveSet<CFGAnalyses>();
----------------
boomanaiden154 wrote:
Should we be marking `StackProtector` as preserved here too?
The LegacyPM doesn't mark the CFG as preserved, but it probably should for consistency.
https://github.com/llvm/llvm-project/pull/215325
More information about the llvm-commits
mailing list