[PATCH] D46500: [WebAssembly] CFG sort support for exception handling

Derek Schuff via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 9 09:10:14 PDT 2018


dschuff accepted this revision.
dschuff added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/Target/WebAssembly/WebAssemblyCFGSort.cpp:200
                   const MachineBasicBlock *B) const {
+    // We give a higher priority to an EH pad
+    if (A->isEHPad() && !B->isEHPad())
----------------
aheejin wrote:
> dschuff wrote:
> > Even when comparing backwards? I don't quite understand why this shouldn't just be the inverse of forward comparison.
> For some reason I don't fully understand, for `Ready` list later BBs are selected first. But my intention here is no matter whether the list is `Preferred` (which uses `CompareBlockNumbers`) or `Ready` (which uses `CompareBlockNumbersBackwards`), whenever we have an EH pad ready, we want to pick it first.
> 
> So `CompareBlockNumbersBackwards` doesn't mean its results will be used in the reverse direction. Regardless of the comparison function, a BB indicated by the function as having higher priority is placed before when sorting.
OK. This whole bit with the comparison functions still seems a little awkward to me though. At the very least there should be a comment here saying something about the usage or why it's not just the inverse of the above (especially since the name seems to imply that it is). Or maybe it just needs a better name?

Perhaps @sunfish knows why the queues sort in the opposite directions.

Or, stepping back, more, would it make more sense to just have separate queue (alongside Preferred and Ready) for EH pads? Preferred and Ready are basically 2 different priority classes, and we are now adding a third, but we are handling its prioritization differently from the other 2.


================
Comment at: lib/Target/WebAssembly/WebAssemblyCFGSort.cpp:85
+    const auto *WE = WEI.getExceptionFor(MBB);
+    if (!ML && !WE)
+      return nullptr;
----------------
We could also assert that ML and WE aren't both set.


Repository:
  rL LLVM

https://reviews.llvm.org/D46500





More information about the llvm-commits mailing list