This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Use operand bundles to describe call sites
ClosedPublic

Authored by majnemer on Dec 14 2015, 7:11 PM.

Details

Summary

SimplifyCFG allows tail merging with code which terminates in
unreachable which, in turn, makes it possible for an invoke to end up in
a funclet which it was not originally part of.

Using operand bundles on invokes allows us to determine whether or not
an invoke was part of a funclet in the source program.

Furthermore, it allows us to unambiguously answer questions about the
legality of inlining into call sites which the personality may have
trouble with.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 42814.Dec 14 2015, 7:11 PM
majnemer retitled this revision from to [WinEH] Use operand bundles to describe call sites.
majnemer updated this object.
majnemer added a subscriber: llvm-commits.
rnk accepted this revision.Dec 14 2015, 8:18 PM
rnk edited edge metadata.

lgtm, but let's wait for more feedback.

I personally like the name "funclet" for the operand bundle. It always has to be a FuncletPadInst value, so it really always is a "funclet".

This revision is now accepted and ready to land.Dec 14 2015, 8:18 PM
sanjoy edited edge metadata.Dec 14 2015, 8:58 PM

Operand bundles bits lgtm with some minor comments. Doesn't have to be this patch, but please add a small blurb to the langref about the "funclet" operand bundle.

lib/CodeGen/WinEHPrepare.cpp
795 ↗(On Diff #42814)

Minor: will this look cleaner with an auto?

lib/Transforms/Utils/InlineFunction.cpp
1446 ↗(On Diff #42814)

Why do you need to declare Inputs separately? Why not just OpBundles.emplace_back("funclet", CallSiteEHPad);?

1449 ↗(On Diff #42814)

Minor: braces unnecessary. This may even be clearer as a ternary operator.

lib/CodeGen/WinEHPrepare.cpp
804–809 ↗(On Diff #42814)

I think you should do this part for CallInst uses too.

lib/IR/Verifier.cpp
2397–2398 ↗(On Diff #42814)

Want to check that it has token type? Or specifically that it is a FuncletPadInst?

lib/Transforms/Utils/InlineFunction.cpp
1419 ↗(On Diff #42814)

s/funclets/funclets and callsites/?

1434–1438 ↗(On Diff #42814)

If you agree with my feedback in WinEHPrepare about making mis-annotated calls equally UB to mis-annotated invokes (and it seems to me they should agree), then this part will need to agree. It might make sense to have nounwind intrinsics be a special case (and the only one) in both places. Or neither.

1454 ↗(On Diff #42814)

The Create overloads you call a few lines above pass the old instruction's name as the name argument for the new instruction. Does takeName do something different than (but still compatible with) that?

Also, supposing one of these calls/invokes has debug info (line number etc) attached, is what's here sufficient to propagate it to the new one?

majnemer updated this revision to Diff 42885.Dec 15 2015, 11:46 AM
majnemer edited edge metadata.
  • Address review comments
JosephTremoulet accepted this revision.Dec 15 2015, 12:09 PM
JosephTremoulet edited edge metadata.

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.