This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Split blocks at calls to llvm.eh.begincatch.
ClosedPublic

Authored by andrew.w.kaylor on Apr 27 2015, 4:57 PM.

Details

Summary

This patch introduces code to split basic blocks before calls to llvm.eh.begincatch (and any adjacent operands) in order to allow catch handlers and cleanup code to be more easily distinguished during later processing.

The patch also replaces all calls to BasicBlock::splitBasicBlock() with a call to llvm::SplitBlock() because the latter is able to preserve the DominatorTree whereas the former does not. This causes a change in block names, because llvm::SplitBlock() doesn't provide a parameter to name the split block. Obviously we could rename the block after SplitBlock returns, but that didn't seem necessary to me.

Diff Detail

Repository
rL LLVM

Event Timeline

andrew.w.kaylor retitled this revision from to [WinEH] Split blocks at calls to llvm.eh.begincatch..
andrew.w.kaylor updated this object.
andrew.w.kaylor edited the test plan for this revision. (Show Details)
andrew.w.kaylor added reviewers: rnk, majnemer.
andrew.w.kaylor set the repository for this revision to rL LLVM.
andrew.w.kaylor added a subscriber: Unknown Object (MLST).
rnk accepted this revision.Apr 28 2015, 1:34 PM
rnk edited edge metadata.

lgtm

Yeah, I was worrying about DominatorTree preservation when I added those splitBasicBlock calls. Nothing seemed to break, so I went with it, which is always dangerous. :)

lib/CodeGen/WinEHPrepare.cpp
409–411 ↗(On Diff #24516)

Hm, I guess this funny business is needed to allow bitcasts and extractvalue? I guess it prevents us from demoting too much stuff.

418 ↗(On Diff #24516)

You should check I != nullptr in this condition because Op0 and Op1 could be null if the catch parameter is null. Null is not an instruction, so the dyn_cast will fail, and we might call getPrevNode() on null.

This revision is now accepted and ready to land.Apr 28 2015, 1:34 PM
This revision was automatically updated to reflect the committed changes.