[llvm] [WebAssembly] Misc. fixes in CFGStackify (PR #107182)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 22:31:08 PDT 2024


================
@@ -1697,23 +1709,8 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
         break;
 
       default:
-        if (MI.isTerminator()) {
-          // Rewrite MBB operands to be depth immediates.
-          SmallVector<MachineOperand, 4> Ops(MI.operands());
-          while (MI.getNumOperands() > 0)
-            MI.removeOperand(MI.getNumOperands() - 1);
-          for (auto MO : Ops) {
-            if (MO.isMBB()) {
-              if (MI.getOpcode() == WebAssembly::DELEGATE)
-                MO = MachineOperand::CreateImm(
-                    getDelegateDepth(Stack, MO.getMBB()));
-              else
-                MO = MachineOperand::CreateImm(
-                    getBranchDepth(Stack, MO.getMBB()));
-            }
-            MI.addOperand(MF, MO);
-          }
-        }
+        if (MI.isTerminator())
+          RewriteOperands(MI);
----------------
aheejin wrote:

This is extracted to a lambda function, because this will be used in multiple places in a follow-up PR for the new EH.

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


More information about the llvm-commits mailing list