[PATCH] D14454: [WinEH] Fix mutli-parent cloning

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 14:54:20 PST 2015


andrew.w.kaylor added a comment.

This still doesn't fix everything.  There's a problem with the block ordering of cloned catch end pads.

The code that I added to cloneCommonBlocks for catchendpad handling finds the catchpad that unwinds to the catchendpad and assigns the catchendpad the color of that catchpad's first parent.  I said in the comment that it didn't matter if the catchpad had multiple parents because we'd clone it later if it did.  That's not quite true.  When we clone the block later, we use its color to figure out whether to give the new catchend pad to the clone parent or the original funclet's parent.  So the color we gave it in cloneCommonBlocks determines which parent funclet gets the clone and that, in turn, determines whether or not the unwind edge is removed as implausible.

For instance, test15 in wineh-multi-parent-cloning.ll has this form (with a bunch of stuff omitted):

  define void @test15() personality i32 (...)* @__CxxFrameHandler3 {
  left:
  left.end:
    catchendpad unwind to caller
  right:
  right.end:
    catchendpad unwind label %left.end
  inner:
    catchpad []
  inner.end:
    catchendpad unwind label %left.end
  }

Here %left and %right are both parents of %inner.  When we see %inner.end in cloneCommonBlocks() we can set its color to either %left or %right.  FuncletParents maps to a vector, trying to normalize the order of traversal, but the order is actually based on the order of the BlockColors assigned to %inner by colorFunclets.

So we set the color of %inner.end to either %left or %right.  When we do the cloning, if we made it %left, it comes out like this:

  inner:
    catchpad []
  inner.from.right:
    catchpad []
  inner.end:
    catchendpad unwind label %left.end
  inner.end.from.right
    catchendpad unwind to caller

but if we made it %right, it comes out like this:

  inner:
    catchpad []
  inner.from.right:
    catchpad []
  inner.end:
    catchendpad unwind to caller
  inner.end.from.left
    catchendpad unwind label %left.end

Basically, I think I need to make the BlockColors value type a vector too.


Repository:
  rL LLVM

http://reviews.llvm.org/D14454





More information about the llvm-commits mailing list