[WinEH] Update CoreCLR EH state numbering
authorJoseph Tremoulet <jotrem@microsoft.com>
Mon, 4 Jan 2016 16:16:01 +0000 (16:16 +0000)
committerJoseph Tremoulet <jotrem@microsoft.com>
Mon, 4 Jan 2016 16:16:01 +0000 (16:16 +0000)
commit7f410b17a792c624d2b939fa56285f8eb8cba184
treefb3195127e7619913b7243cd77e9d9f576381bfd
parent98732e397c55abc7a214dd2d4f09a08a24382f35
[WinEH] Update CoreCLR EH state numbering

Summary:
Fix the CLR state numbering to generate correct tables, and update the lit
test to verify them.

The CLR numbering assigns one state number to each catchpad and
cleanuppad.

It also computes two tree-like relations over states:
 1) Each state has a "HandlerParentState", which is the state of the next
    outer handler enclosing this state's handler (same as nearest ancestor
    per the ParentPad linkage on EH pads, but skipping over catchswitches).
 2) Each state has a "TryParentState", which:
    a) for a catchpad that's not the last handler on its catchswitch, is
       the state of the next catchpad on that catchswitch.
    b) for all other pads, is the state of the pad whose try region is the
       next outer try region enclosing this state's try region.  The "try
       regions are not present as such in the IR, but will be inferred
       based on the placement of invokes and pads which reach each other
       by exceptional exits.

Catchswitches do not get their own states, but each gets mapped to the
state of its first catchpad.

Table generation requires each state's "unwind dest" state to have a lower
state number than the given state.

Since HandlerParentState can be computed as a function of a pad's
ParentPad, and TryParentState can be computed as a function of its unwind
dest and the TryParentStates of its children, the CLR state numbering
algorithm first computes HandlerParentState in a top-down pass, then
computes TryParentState in a bottom-up pass.

Also reword some comments/names in the CLR EH table generation to make the
distinction between the different kinds of "parent" clear.

Reviewers: rnk, andrew.w.kaylor, majnemer

Subscribers: AndyAyers, llvm-commits

Differential Revision: http://reviews.llvm.org/D15325

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256760 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/WinEHFuncInfo.h
lib/CodeGen/AsmPrinter/WinException.cpp
lib/CodeGen/WinEHPrepare.cpp
test/CodeGen/X86/wineh-coreclr.ll