This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Don't inline an 'unwinds to caller' cleanupret into funclets which locally unwind
ClosedPublic

Authored by majnemer on Feb 22 2016, 11:24 PM.

Details

Summary

It is problematic if the inlinee has a cleanupret which unwinds to
caller and we inline it into a call site which doesn't unwind.

If the funclet unwinds anywhere other than to the caller,
then we will give the funclet two unwind destinations.
This will result in a verifier failure.

Seeing as how the caller wasn't an invoke (which would locally unwind)
and that the funclet cannot unwind to caller, we must conclude that an
'unwind to caller' cleanupret is dynamically unreachable.

This fixes PR26698.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 48782.Feb 22 2016, 11:24 PM
majnemer retitled this revision from to [WinEH] Don't inline an 'unwinds to caller' cleanupret into funclets which locally unwind.
majnemer updated this object.
majnemer added a subscriber: llvm-commits.

HandleInlinedEHPad builds up the FuncletUnwindMap looking at the pre-inlining callee IR. Sharing it with the new call to getUnwindDestToken might be benign, but I'm not sure. I think it would be safer to use a separate FuncletUnwindMap for the new call. Probably also safer to compute the unwind dest in the caller before the code on line 1759 has had a chance to give the caller EH pad new uses in the partially-rewritten inlinee which might confuse the computation.

majnemer updated this revision to Diff 48822.Feb 23 2016, 9:03 AM
majnemer edited edge metadata.
  • Address review feedback
JosephTremoulet accepted this revision.Feb 23 2016, 9:11 AM
JosephTremoulet edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 23 2016, 9:11 AM
This revision was automatically updated to reflect the committed changes.
rnk edited edge metadata.Feb 23 2016, 2:11 PM

belated lgtm

I thought we had some conversations about this situation or something like it.