This is an archive of the discontinued LLVM Phabricator instance.

[WinEHPrepare] Replace unreasonable funclet terminators with unreachable
ClosedPublic

Authored by majnemer on Aug 17 2015, 1:54 AM.

Details

Summary

It is possible to be in a situation where more than one funclet token is
a valid SSA value. If we see a terminator which exits a funclet which
doesn't use the funclet's token, replace it with unreachable.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 32274.Aug 17 2015, 1:54 AM
majnemer retitled this revision from to [WinEHPrepare] Replace unreasonable funclet terminators with unreachable.
majnemer updated this object.
majnemer added a reviewer: JosephTremoulet.
majnemer added a subscriber: llvm-commits.
JosephTremoulet accepted this revision.Aug 17 2015, 6:59 AM
JosephTremoulet edited edge metadata.

LGTM with one nit.

lib/CodeGen/WinEHPrepare.cpp
3242–3243 ↗(On Diff #32274)

I think this is subtle enough to merit a comment (along the lines of "We can't demote a token but it's safe to skip these since cloning will remove mismatched uses").

This revision is now accepted and ready to land.Aug 17 2015, 6:59 AM
JosephTremoulet requested changes to this revision.Aug 17 2015, 7:03 AM
JosephTremoulet edited edge metadata.

Spoke too soon, sorry.

test/CodeGen/WinEH/wineh-demotion.ll
325 ↗(On Diff #32274)

Is this input valid? I don't think the def of %cp0 dominates the use here (path where first invoke returns normally, second invoke raises exception reaches here via cleanup2 without passing through the def at cleanup1).

This revision now requires changes to proceed.Aug 17 2015, 7:03 AM
JosephTremoulet accepted this revision.Aug 17 2015, 8:43 AM
JosephTremoulet edited edge metadata.
JosephTremoulet added inline comments.
test/CodeGen/WinEH/wineh-demotion.ll
325 ↗(On Diff #32274)

Oh, I misread it; that 2nd invoke is unreachable and cleanup2 is only reachable from this cleanupret, which is dominated by cleanup1. Sorry for the noise, objection rescinded.

This revision is now accepted and ready to land.Aug 17 2015, 8:43 AM
This revision was automatically updated to reflect the committed changes.