[llvm] [CodeGen] Port WasmEHPrepare to new pass manager (PR #74435)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 16:37:45 PST 2023


================
@@ -113,19 +116,41 @@ class WasmEHPrepare : public FunctionPass {
   bool prepareEHPads(Function &F);
   void prepareEHPad(BasicBlock *BB, bool NeedPersonality, unsigned Index = 0);
 
+public:
+  WasmEHPrepareImpl() = default;
+  WasmEHPrepareImpl(Type *LPadContextTy_) : LPadContextTy(LPadContextTy_) {}
+  bool runOnFunction(Function &F);
+};
+
+class WasmEHPrepare : public FunctionPass {
+  WasmEHPrepareImpl P;
+
 public:
   static char ID; // Pass identification, replacement for typeid
 
   WasmEHPrepare() : FunctionPass(ID) {}
   bool doInitialization(Module &M) override;
-  bool runOnFunction(Function &F) override;
+  bool runOnFunction(Function &F) override { return P.runOnFunction(F); }
 
   StringRef getPassName() const override {
     return "WebAssembly Exception handling preparation";
   }
 };
+
 } // end anonymous namespace
 
+PreservedAnalyses WasmEHPreparePass::run(Function &F,
+                                         FunctionAnalysisManager &) {
+  auto &Context = F.getContext();
----------------
paperchalice wrote:

There is no `doInitialization/doFinalization` concept in new pass manager. I add the same code here to ensure the same behavior for new and legacy pass.

https://github.com/llvm/llvm-project/pull/74435


More information about the llvm-commits mailing list