This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Update catchrets with cloned successors
ClosedPublic

Authored by JosephTremoulet on Jan 1 2016, 5:36 AM.

Details

Summary

Add a pass to update catchrets when their successors get cloned; the
existing pass doesn't catch these because it walks the funclet whose
blocks are being cloned but the catchret is in a child funclet.

Also update the test for removing incoming PHI values; when the
predecessor is a catchret, the relevant color is the catchret's parentPad,
not its block's color.

Diff Detail

Event Timeline

JosephTremoulet retitled this revision from to [WinEH] Update catchrets with cloned successors.
JosephTremoulet updated this object.
JosephTremoulet added a subscriber: llvm-commits.
majnemer edited edge metadata.Jan 1 2016, 11:35 PM

I'm confused as to why this doesn't trip up our existing assertions. Preparation should have asserted because %join has two colors (none and %cleanpad). My guess is we make the verifyPreparedFunclets rerun coloring.

A-ha, we generate the following IR which upsets the verifier (when running with -disable-cleanups):

join:                                             ; preds = %pad.outer, %pad.inner
  %phi = phi i32 [ 1, %pad.inner ], [ 2, %pad.outer ]
  call void @llvm.foo(i32 %phi)
  unreachable

join.for.entry:                                   ; No predecessors!
  %phi.for.entry = phi i32 
  call void @llvm.foo(i32 %phi.for.entry)
  unreachable
lib/CodeGen/WinEHPrepare.cpp
700

Can we think of a better name than BlockInFunclet? In this case, we are checking to make sure that the catchret's target makes sense given it's parent funclet.

703

I'd write this as !IncomingColors.empty().

majnemer accepted this revision.Jan 2 2016, 1:33 AM
majnemer edited edge metadata.

I went ahead and wrote rL256687 which results in your new test case failing regardless of how winehprepare is operated.

Your changes LGTM with nits addressed.

This revision is now accepted and ready to land.Jan 2 2016, 1:33 AM
JosephTremoulet edited edge metadata.

Address feedback