[PATCH] D59342: [WebAssembly] Method order change in LateEHPrepare (NFC)

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 18:52:37 PDT 2019


aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, jdoerfert, sunfish, jgravelle-google, sbc100.
Herald added a project: LLVM.

Currently the order of `addCatches` and `replaceFuncletReturns` does not
matter, but the following CL needs to have this order changed. Merging
the order change and the semantics change within a CL complicates the
diff, so submitting the order change first.


Repository:
  rL LLVM

https://reviews.llvm.org/D59342

Files:
  lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp


Index: lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+++ lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
@@ -31,8 +31,8 @@
 
   bool runOnMachineFunction(MachineFunction &MF) override;
   bool removeUnnecessaryUnreachables(MachineFunction &MF);
-  bool replaceFuncletReturns(MachineFunction &MF);
   bool addCatches(MachineFunction &MF);
+  bool replaceFuncletReturns(MachineFunction &MF);
   bool addExceptionExtraction(MachineFunction &MF);
   bool restoreStackPointer(MachineFunction &MF);
 
@@ -111,8 +111,8 @@
   Changed |= removeUnnecessaryUnreachables(MF);
   if (!MF.getFunction().hasPersonalityFn())
     return Changed;
-  Changed |= replaceFuncletReturns(MF);
   Changed |= addCatches(MF);
+  Changed |= replaceFuncletReturns(MF);
   Changed |= addExceptionExtraction(MF);
   Changed |= restoreStackPointer(MF);
   return Changed;
@@ -144,6 +144,26 @@
   return Changed;
 }
 
+// Add catch instruction to beginning of catchpads and cleanuppads.
+bool WebAssemblyLateEHPrepare::addCatches(MachineFunction &MF) {
+  bool Changed = false;
+  const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
+  MachineRegisterInfo &MRI = MF.getRegInfo();
+  for (auto &MBB : MF) {
+    if (MBB.isEHPad()) {
+      Changed = true;
+      auto InsertPos = MBB.begin();
+      if (InsertPos->isEHLabel()) // EH pad starts with an EH label
+        ++InsertPos;
+      unsigned DstReg =
+          MRI.createVirtualRegister(&WebAssembly::EXCEPT_REFRegClass);
+      BuildMI(MBB, InsertPos, MBB.begin()->getDebugLoc(),
+              TII.get(WebAssembly::CATCH), DstReg);
+    }
+  }
+  return Changed;
+}
+
 bool WebAssemblyLateEHPrepare::replaceFuncletReturns(MachineFunction &MF) {
   bool Changed = false;
   const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
@@ -177,26 +197,6 @@
   return Changed;
 }
 
-// Add catch instruction to beginning of catchpads and cleanuppads.
-bool WebAssemblyLateEHPrepare::addCatches(MachineFunction &MF) {
-  bool Changed = false;
-  const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
-  MachineRegisterInfo &MRI = MF.getRegInfo();
-  for (auto &MBB : MF) {
-    if (MBB.isEHPad()) {
-      Changed = true;
-      auto InsertPos = MBB.begin();
-      if (InsertPos->isEHLabel()) // EH pad starts with an EH label
-        ++InsertPos;
-      unsigned DstReg =
-          MRI.createVirtualRegister(&WebAssembly::EXCEPT_REFRegClass);
-      BuildMI(MBB, InsertPos, MBB.begin()->getDebugLoc(),
-              TII.get(WebAssembly::CATCH), DstReg);
-    }
-  }
-  return Changed;
-}
-
 // Wasm uses 'br_on_exn' instruction to check the tag of an exception. It takes
 // except_ref type object returned by 'catch', and branches to the destination
 // if it matches a given tag. We currently use __cpp_exception symbol to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59342.190556.patch
Type: text/x-patch
Size: 2947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190314/4c082038/attachment.bin>


More information about the llvm-commits mailing list