This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Fix endpad coloring/numbering
ClosedPublic

Authored by JosephTremoulet on Oct 16 2015, 12:47 AM.

Details

Summary

When a cleanup's cleanupendpad or cleanupret targets a catchendpad, stop
trying to propagate the cleanup's parent's color to the catchendpad, since
what's needed is the cleanup's grandparent's color and the catchendpad
will get that color from the catchpad linkage already. We already had
this exclusion for invokes, but were missing it for
cleanupendpad/cleanupret.

Also add a missing line that tags cleanupendpads' states in the
EHPadStateMap, without with lowering invokes that target cleanupendpads
which unwind to other handlers (and so don't have the -1 state) will fail.

This fixes the reduced IR repro in PR25163.

Diff Detail

Event Timeline

JosephTremoulet retitled this revision from to [WinEH] Fix endpad coloring/numbering.
JosephTremoulet updated this object.
JosephTremoulet added a subscriber: llvm-commits.

Looks good to me.

I noticed this extra cloning while working on the multi-parent cloning, but it seemed like the extra cloned blocks were generally cleared away by the cleanup code (at least in the cases I was debugging).

andrew.w.kaylor accepted this revision.Oct 16 2015, 10:56 AM
andrew.w.kaylor edited edge metadata.
This revision is now accepted and ready to land.Oct 16 2015, 10:56 AM

I noticed this extra cloning while working on the multi-parent cloning, but it seemed like the extra cloned blocks were generally cleared away by the cleanup code (at least in the cases I was debugging).

Yeah, the trick to get an extra catchendpad to stick around (which PR25163 uncovered) is that a catch chained to the catchendpad needs to contain both an inner cleanup whose cleanupret/cleanupendpad unwinds to the catchendpad (so we give it the extra color) and an invoke, inside the catch but outside its cleanup, which also unwinds to the catchendpad (so that cloning will rewrite the invoke unwind dest to the cloned catchendpad).

rnk accepted this revision.Oct 16 2015, 11:09 AM
rnk edited edge metadata.

lgtm as well. However, it makes me feel like we overfit the C++ personality with the catchendpad design.