[llvm] [WebAssembly] Port WebAssemblyOptimizeReturnedPass (PR #209036)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 23:46:14 PDT 2026
================
@@ -70,12 +79,27 @@ void OptimizeReturned::visitCallBase(CallBase &CB) {
}
}
-bool OptimizeReturned::runOnFunction(Function &F) {
+bool WebAssemblyOptimizeReturnedImpl::runOnFunction(Function &F) {
LLVM_DEBUG(dbgs() << "********** Optimize returned Attributes **********\n"
"********** Function: "
<< F.getName() << '\n');
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
visit(F);
return true;
}
+
+bool WebAssemblyOptimizeReturnedLegacy::runOnFunction(Function &F) {
+ DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ WebAssemblyOptimizeReturnedImpl Impl(DT);
+ return Impl.runOnFunction(F);
+}
+
+PreservedAnalyses
+WebAssemblyOptimizeReturnedPass::run(Function &F,
+ FunctionAnalysisManager &FAM) {
+ DominatorTree *DT = &FAM.getResult<DominatorTreeAnalysis>(F);
+ WebAssemblyOptimizeReturnedImpl Impl(DT);
+ return Impl.runOnFunction(F)
+ ? PreservedAnalyses::none().preserveSet<CFGAnalyses>()
+ : PreservedAnalyses::all();
----------------
aheejin wrote:
https://github.com/llvm/llvm-project/blob/6a33b69d8bae737e5e1d60c7b7776a0b1f885bfa/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp#L41-L46
We seem to preserve `DominatorTree` too
https://github.com/llvm/llvm-project/pull/209036
More information about the llvm-commits
mailing list