This is an archive of the discontinued LLVM Phabricator instance.

Don't crash on leaving nested __finally blocks through an EH edge.
ClosedPublic

Authored by thakis on Feb 26 2015, 1:55 PM.

Details

Reviewers
rnk
Summary

The finally emission block tries to be clever by removing unused continuation edges if there's an unconditional jump out of the finally block. With exception edges, the EH continuation edge isn't always unused though and we'd crash in a few places.

Just don't be clever. That makes the IR for __finally blocks a bit longer in some cases (hence small and behavior-preserving changes to existing tests), but it makes no difference in general and it fixes the last crash from PR22553.

Diff Detail

Event Timeline

thakis updated this revision to Diff 20794.Feb 26 2015, 1:55 PM
thakis retitled this revision from to Don't crash on leaving nested __finally blocks through an EH edge..
thakis updated this object.
thakis edited the test plan for this revision. (Show Details)
thakis added a reviewer: rnk.
thakis added a subscriber: Unknown Object (MLST).
rnk edited edge metadata.Feb 26 2015, 2:05 PM

I have one idea for how we can still be clever, but if it's too hard, then yeah let's be dumb.

lib/CodeGen/CGException.cpp
1936

Can we check !HaveInsertPoint() && FI.ContBB->hasZeroUses() instead and still be clever?

thakis added inline comments.Feb 26 2015, 2:10 PM
lib/CodeGen/CGException.cpp
1936

You mean use_empty()? I tried that (if (FI.ContBB.use_empty() && (!FI.ResumeBB || FI.ResumeBB.use_empty())) and that didn't immediately work. But then I though even if it did, he benefits of being clever seem not worth it over having more control flow, and I stopped trying immediately and sent this out as-is :-)

rnk accepted this revision.Feb 26 2015, 2:31 PM
rnk edited edge metadata.

lgtm

lib/CodeGen/CGException.cpp
1936

OK. SEH finally is super rare. In general, though, the best way to speed up -O0 codegen is to emit less code.

This revision is now accepted and ready to land.Feb 26 2015, 2:31 PM
thakis closed this revision.Feb 26 2015, 2:36 PM

r230697