This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Handle the case of nested landing pads that return to a block in the parent function.
ClosedPublic

Authored by andrew.w.kaylor on May 11 2015, 3:16 PM.

Details

Summary

This adds support for preserving the correct control flow representation in the case where a nested landing pad returns to a block in the parent function. This can happen, for instance, in a case where the landing pad in question originally enclosed the handler in which it is nested in the user's source code but can only be reached from the enclosed landing pad. The following code is an example:

void test1() {
  try {
    try {
      throw 1;
    } catch(...) { throw; }
  } catch (...) { }
}

In such a case, we must represent the block to which the "nested" landing pad returns as a possible target of the landing pad in which it is enclosed in order to prevent the target block from being eliminated as dead code.

This patch only handles to case described at the WinEHPrepare level. There are still problem executing a program which includes the case above, but I can reproduce the same failures without the scenario that this patch is meant to address.

Diff Detail

Repository
rL LLVM

Event Timeline

andrew.w.kaylor retitled this revision from to [WinEH] Handle the case of nested landing pads that return to a block in the parent function..
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.May 11 2015, 3:51 PM
rnk edited edge metadata.

LGTM

lib/CodeGen/WinEHPrepare.cpp
894 ↗(On Diff #25517)

wrap

This revision is now accepted and ready to land.May 11 2015, 3:51 PM
This revision was automatically updated to reflect the committed changes.