This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Fix cleanup state numbering
ClosedPublic

Authored by JosephTremoulet on Oct 1 2015, 8:37 PM.

Details

Summary
  • Recurse from cleanupendpads to their cleanuppads, to make sure the cleanuppad is visited if it has a cleanupendpad but no cleanupret.
  • Check for and avoid double-processing cleanuppads, to allow for them to have multiple cleanuprets (plus cleanupendpads).
  • Update Cxx state numbering to visit toplevel cleanupendpads and to recurse from cleanupendpads to their preds, to ensure we number any funclets in inlined cleanups. SEH state numbering already did this.

Diff Detail

Event Timeline

JosephTremoulet retitled this revision from to [WinEH] Fix cleanup state numbering.
JosephTremoulet updated this object.
JosephTremoulet added a reviewer: rnk.
JosephTremoulet added a subscriber: llvm-commits.

Just a few things I noticed when going over this code in the process of using it as a template for CLR state numbering. I wanted to make sure we'd handle these cases in a consistent way, and it would have taken longer to try to explain than to just send this patch.

rnk edited edge metadata.Oct 6 2015, 1:25 PM

I held off on doing this because Clang doesn't emit cleanupendpad for C++ destructors yet. This isn't usually problem because destructors are noexcept by default in C++11, so the cleanupendpad is unreachable *unless* someone explicitly declares a noexcept(false) destructor:

struct D {
  ~D() noexcept(false) { throw 42; }
};
int main() {
  D o;
  throw 42;
}

Let me deal with that and I'll get back to this.

JosephTremoulet edited edge metadata.

replace find(x) != end() with count(x) != 0

rnk accepted this revision.Oct 8 2015, 2:57 PM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Oct 8 2015, 2:57 PM
rnk added a comment.Oct 8 2015, 3:14 PM

I landed rL249748, which makes clang do the right thing with cleanupendpad and C++.