[llvm] r237014 - [WinEH] Update exception numbering to give handlers their own base state.
Andrew Kaylor
andrew.kaylor at intel.com
Mon May 11 12:41:19 PDT 2015
Author: akaylor
Date: Mon May 11 14:41:19 2015
New Revision: 237014
URL: http://llvm.org/viewvc/llvm-project?rev=237014&view=rev
Log:
[WinEH] Update exception numbering to give handlers their own base state.
Differential Revision: http://reviews.llvm.org/D9512
Added:
llvm/trunk/test/CodeGen/WinEH/cppeh-state-calc-1.ll
Modified:
llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll
llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll
llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll
Modified: llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h Mon May 11 14:41:19 2015
@@ -136,6 +136,7 @@ struct WinEHFuncInfo {
DenseMap<const Function *, int> CatchHandlerParentFrameObjIdx;
DenseMap<const Function *, int> CatchHandlerParentFrameObjOffset;
DenseMap<const Function *, int> CatchHandlerMaxState;
+ DenseMap<const Function *, int> HandlerBaseState;
SmallVector<WinEHUnwindMapEntry, 4> UnwindMap;
SmallVector<WinEHTryBlockMapEntry, 4> TryBlockMap;
SmallVector<std::pair<MCSymbol *, int>, 4> IPToStateList;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Mon May 11 14:41:19 2015
@@ -299,6 +299,17 @@ void Win64Exception::emitCXXFrameHandler
// The parent function and the catch handlers contribute to the 'ip2state'
// table.
+
+ // Include ip2state entries for the beginning of the main function and
+ // for catch handler functions.
+ if (F == ParentF) {
+ FuncInfo.IPToStateList.push_back(std::make_pair(LastLabel, -1));
+ LastEHState = -1;
+ } else if (FuncInfo.HandlerBaseState.count(F)) {
+ FuncInfo.IPToStateList.push_back(std::make_pair(LastLabel,
+ FuncInfo.HandlerBaseState[F]));
+ LastEHState = FuncInfo.HandlerBaseState[F];
+ }
for (const auto &MBB : *MF) {
for (const auto &MI : MBB) {
if (!MI.isEHLabel()) {
@@ -323,7 +334,8 @@ void Win64Exception::emitCXXFrameHandler
assert(BeginLabel == LandingPad->BeginLabels[P.RangeIndex] &&
"Inconsistent landing pad map!");
- if (SawPotentiallyThrowing) {
+ // FIXME: Should this be using FuncInfo.HandlerBaseState?
+ if (SawPotentiallyThrowing && LastEHState != -1) {
FuncInfo.IPToStateList.push_back(std::make_pair(LastLabel, -1));
SawPotentiallyThrowing = false;
LastEHState = -1;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Mon May 11 14:41:19 2015
@@ -82,16 +82,18 @@ static ISD::NodeType getPreferredExtendF
namespace {
struct WinEHNumbering {
- WinEHNumbering(WinEHFuncInfo &FuncInfo) : FuncInfo(FuncInfo), NextState(0) {}
+ WinEHNumbering(WinEHFuncInfo &FuncInfo) : FuncInfo(FuncInfo),
+ CurrentBaseState(-1), NextState(0) {}
WinEHFuncInfo &FuncInfo;
+ int CurrentBaseState;
int NextState;
SmallVector<ActionHandler *, 4> HandlerStack;
SmallPtrSet<const Function *, 4> VisitedHandlers;
int currentEHNumber() const {
- return HandlerStack.empty() ? -1 : HandlerStack.back()->getEHState();
+ return HandlerStack.empty() ? CurrentBaseState : HandlerStack.back()->getEHState();
}
void createUnwindMapEntry(int ToState, ActionHandler *AH);
@@ -401,17 +403,33 @@ static void print_name(const Value *V) {
void WinEHNumbering::processCallSite(ArrayRef<ActionHandler *> Actions,
ImmutableCallSite CS) {
+ DEBUG(dbgs() << "processCallSite (EH state = " << currentEHNumber()
+ << ") for: ");
+ print_name(CS ? CS.getCalledValue() : nullptr);
+ DEBUG(dbgs() << '\n');
+
+ DEBUG(dbgs() << "HandlerStack: \n");
+ for (int I = 0, E = HandlerStack.size(); I < E; ++I) {
+ DEBUG(dbgs() << " ");
+ print_name(HandlerStack[I]->getHandlerBlockOrFunc());
+ DEBUG(dbgs() << '\n');
+ }
+ DEBUG(dbgs() << "Actions: \n");
+ for (int I = 0, E = Actions.size(); I < E; ++I) {
+ DEBUG(dbgs() << " ");
+ print_name(Actions[I]->getHandlerBlockOrFunc());
+ DEBUG(dbgs() << '\n');
+ }
int FirstMismatch = 0;
for (int E = std::min(HandlerStack.size(), Actions.size()); FirstMismatch < E;
++FirstMismatch) {
if (HandlerStack[FirstMismatch]->getHandlerBlockOrFunc() !=
Actions[FirstMismatch]->getHandlerBlockOrFunc())
break;
+ // Delete any actions that are already represented on the handler stack.
delete Actions[FirstMismatch];
}
- bool EnteringScope = (int)Actions.size() > FirstMismatch;
-
// Don't recurse while we are looping over the handler stack. Instead, defer
// the numbering of the catch handlers until we are done popping.
SmallVector<CatchHandler *, 4> PoppedCatches;
@@ -425,46 +443,75 @@ void WinEHNumbering::processCallSite(Arr
HandlerStack.pop_back();
}
- // We need to create a new state number if we are exiting a try scope and we
- // will not push any more actions.
int TryHigh = NextState - 1;
- if (!EnteringScope && !PoppedCatches.empty()) {
- createUnwindMapEntry(currentEHNumber(), nullptr);
- ++NextState;
- }
-
int LastTryLowIdx = 0;
for (int I = 0, E = PoppedCatches.size(); I != E; ++I) {
CatchHandler *CH = PoppedCatches[I];
+ DEBUG(dbgs() << "Popped handler with state " << CH->getEHState() << "\n");
if (I + 1 == E || CH->getEHState() != PoppedCatches[I + 1]->getEHState()) {
int TryLow = CH->getEHState();
auto Handlers =
makeArrayRef(&PoppedCatches[LastTryLowIdx], I - LastTryLowIdx + 1);
+ DEBUG(dbgs() << "createTryBlockMapEntry(" << TryLow << ", " << TryHigh);
+ for (int J = 0; J < Handlers.size(); ++J) {
+ DEBUG(dbgs() << ", ");
+ print_name(Handlers[J]->getHandlerBlockOrFunc());
+ }
+ DEBUG(dbgs() << ")\n");
createTryBlockMapEntry(TryLow, TryHigh, Handlers);
LastTryLowIdx = I + 1;
}
}
for (CatchHandler *CH : PoppedCatches) {
- if (auto *F = dyn_cast<Function>(CH->getHandlerBlockOrFunc()))
+ if (auto *F = dyn_cast<Function>(CH->getHandlerBlockOrFunc())) {
+ DEBUG(dbgs() << "Assigning base state " << NextState << " to ");
+ print_name(F);
+ DEBUG(dbgs() << '\n');
+ FuncInfo.HandlerBaseState[F] = NextState;
+ DEBUG(dbgs() << "createUnwindMapEntry(" << currentEHNumber()
+ << ", null)\n");
+ createUnwindMapEntry(currentEHNumber(), nullptr);
+ ++NextState;
calculateStateNumbers(*F);
+ }
delete CH;
}
+ // The handler functions may have pushed actions onto the handler stack
+ // that we expected to push here. Compare the handler stack to our
+ // actions again to check for that possibility.
+ if (HandlerStack.size() > FirstMismatch) {
+ for (int E = std::min(HandlerStack.size(), Actions.size());
+ FirstMismatch < E; ++FirstMismatch) {
+ if (HandlerStack[FirstMismatch]->getHandlerBlockOrFunc() !=
+ Actions[FirstMismatch]->getHandlerBlockOrFunc())
+ break;
+ delete Actions[FirstMismatch];
+ }
+ }
+
+ DEBUG(dbgs() << "Pushing actions for CallSite: ");
+ print_name(CS ? CS.getCalledValue() : nullptr);
+ DEBUG(dbgs() << '\n');
+
bool LastActionWasCatch = false;
for (size_t I = FirstMismatch; I != Actions.size(); ++I) {
// We can reuse eh states when pushing two catches for the same invoke.
bool CurrActionIsCatch = isa<CatchHandler>(Actions[I]);
// FIXME: Reenable this optimization!
if (CurrActionIsCatch && LastActionWasCatch && false) {
+ DEBUG(dbgs() << "setEHState for handler to " << currentEHNumber()
+ << "\n");
Actions[I]->setEHState(currentEHNumber());
} else {
+ DEBUG(dbgs() << "createUnwindMapEntry(" << currentEHNumber() << ", ");
+ print_name(Actions[I]->getHandlerBlockOrFunc());
+ DEBUG(dbgs() << ")\n");
createUnwindMapEntry(currentEHNumber(), Actions[I]);
+ DEBUG(dbgs() << "setEHState for handler to " << NextState << "\n");
Actions[I]->setEHState(NextState);
NextState++;
- DEBUG(dbgs() << "Creating unwind map entry for: (");
- print_name(Actions[I]->getHandlerBlockOrFunc());
- DEBUG(dbgs() << ", " << currentEHNumber() << ")\n");
}
HandlerStack.push_back(Actions[I]);
LastActionWasCatch = CurrActionIsCatch;
@@ -480,6 +527,11 @@ void WinEHNumbering::calculateStateNumbe
if (!I.second)
return; // We've already visited this handler, don't renumber it.
+ int OldBaseState = CurrentBaseState;
+ if (FuncInfo.HandlerBaseState.count(&F)) {
+ CurrentBaseState = FuncInfo.HandlerBaseState[&F];
+ }
+
DEBUG(dbgs() << "Calculating state numbers for: " << F.getName() << '\n');
SmallVector<ActionHandler *, 4> ActionList;
for (const BasicBlock &BB : F) {
@@ -498,12 +550,19 @@ void WinEHNumbering::calculateStateNumbe
continue;
assert(ActionsCall->getIntrinsicID() == Intrinsic::eh_actions);
parseEHActions(ActionsCall, ActionList);
+ if (ActionList.empty())
+ continue;
processCallSite(ActionList, II);
ActionList.clear();
FuncInfo.LandingPadStateMap[LPI] = currentEHNumber();
+ DEBUG(dbgs() << "Assigning state " << currentEHNumber()
+ << " to landing pad at " << LPI->getParent()->getName()
+ << '\n');
}
FuncInfo.CatchHandlerMaxState[&F] = NextState - 1;
+
+ CurrentBaseState = OldBaseState;
}
/// clear - Clear out all the function-specific state. This returns this
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll Mon May 11 14:41:19 2015
@@ -120,7 +120,7 @@ stub:
; CHECK-NEXT: .long ($stateUnwindMap$main)@IMGREL
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ($tryMap$main)@IMGREL
-; CHECK-NEXT: .long 1
+; CHECK-NEXT: .long 3
; CHECK-NEXT: .long ($ip2state$main)@IMGREL
; CHECK-NEXT: .long 40
; CHECK-NEXT: .long 0
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll Mon May 11 14:41:19 2015
@@ -127,7 +127,7 @@ try.cont8:
; CHECK-NEXT: .long ("$stateUnwindMap$?f@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long ("$tryMap$?f@@YAXXZ")@IMGREL
-; CHECK-NEXT: .long 3
+; CHECK-NEXT: .long 6
; CHECK-NEXT: .long ("$ip2state$?f@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 32
; CHECK-NEXT: .long 0
@@ -165,8 +165,14 @@ try.cont8:
; CHECK-NEXT: .long "?f@@YAXXZ.catch1"@IMGREL
; CHECK-NEXT: .long ".L?f@@YAXXZ.catch1$parent_frame_offset"
; CHECK-NEXT:"$ip2state$?f@@YAXXZ":
+; CHECK-NEXT: .long .Lfunc_begin0 at IMGREL
+; CHECK-NEXT: .long 2
; CHECK-NEXT: .long .Ltmp0 at IMGREL
; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long .Lfunc_begin1 at IMGREL
+; CHECK-NEXT: .long 3
+; CHECK-NEXT: .long .Lfunc_begin2 at IMGREL
+; CHECK-NEXT: .long -1
; CHECK-NEXT: .long .Ltmp13 at IMGREL
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long .Ltmp16 at IMGREL
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll?rev=237014&r1=237013&r2=237014&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-cleanups.ll Mon May 11 14:41:19 2015
@@ -36,7 +36,7 @@ $_TI1H = comdat any
; CHECK-NEXT: .long ("$stateUnwindMap$?test1@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 0
-; CHECK-NEXT: .long 1
+; CHECK-NEXT: .long 2
; CHECK-NEXT: .long ("$ip2state$?test1@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 32
; CHECK-NEXT: .long 0
@@ -45,6 +45,8 @@ $_TI1H = comdat any
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long "?test1@@YAXXZ.cleanup"@IMGREL
; CHECK-NEXT:"$ip2state$?test1@@YAXXZ":
+; CHECK-NEXT: .long .Lfunc_begin0 at IMGREL
+; CHECK-NEXT: .long -1
; CHECK-NEXT: .long .Ltmp0 at IMGREL
; CHECK-NEXT: .long 0
Added: llvm/trunk/test/CodeGen/WinEH/cppeh-state-calc-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-state-calc-1.ll?rev=237014&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/cppeh-state-calc-1.ll (added)
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-state-calc-1.ll Mon May 11 14:41:19 2015
@@ -0,0 +1,289 @@
+; RUN: llc < %s | FileCheck %s
+
+; This test was generated from the following code.
+;
+; void test() {
+; try {
+; try {
+; try {
+; two();
+; throw 2;
+; } catch (int x) {
+; catch_two();
+; }
+; a();
+; throw 'a';
+; } catch (char c) {
+; catch_a();
+; }
+; one();
+; throw 1;
+; } catch(int x) {
+; catch_one();
+; } catch(...) {
+; catch_all();
+; }
+; }
+;
+; The function calls before the throws were declared as 'noexcept' and are
+; just here to make blocks easier to identify in the IR.
+
+; ModuleID = '<stdin>'
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
+%eh.CatchHandlerType = type { i32, i8* }
+%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
+%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
+%eh.ThrowInfo = type { i32, i32, i32, i32 }
+
+$"\01??_R0H at 8" = comdat any
+
+$"\01??_R0D at 8" = comdat any
+
+$"_CT??_R0H at 84" = comdat any
+
+$_CTA1H = comdat any
+
+$_TI1H = comdat any
+
+$"_CT??_R0D at 81" = comdat any
+
+$_CTA1D = comdat any
+
+$_TI1D = comdat any
+
+@"\01??_7type_info@@6B@" = external constant i8*
+@"\01??_R0H at 8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
+ at llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H at 8" to i8*) }, section "llvm.metadata"
+@"\01??_R0D at 8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".D\00" }, comdat
+ at llvm.eh.handlertype.D.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0D at 8" to i8*) }, section "llvm.metadata"
+ at __ImageBase = external constant i8
+@"_CT??_R0H at 84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0H at 8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat
+ at _CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0H at 84" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
+ at _TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @_CTA1H to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
+@"_CT??_R0D at 81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0D at 8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 1, i32 0 }, section ".xdata", comdat
+ at _CTA1D = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0D at 81" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
+ at _TI1D = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @_CTA1D to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
+
+; Function Attrs: nounwind uwtable
+define void @"\01?test@@YAXXZ"() #0 {
+entry:
+ %tmp = alloca i32, align 4
+ %x = alloca i32, align 4
+ %tmp2 = alloca i8, align 1
+ %c = alloca i8, align 1
+ %tmp11 = alloca i32, align 4
+ %x21 = alloca i32, align 4
+ call void @"\01?two@@YAXXZ"() #3
+ store i32 2, i32* %tmp
+ %0 = bitcast i32* %tmp to i8*
+ call void (...) @llvm.frameescape(i32* %x, i8* %c, i32* %x21)
+ invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* @_TI1H) #5
+ to label %unreachable unwind label %lpad
+
+lpad: ; preds = %entry
+ %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
+ catch %eh.CatchHandlerType* @llvm.eh.handlertype.D.0
+ catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
+ catch i8* null
+ %recover = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 0, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch1", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
+ indirectbr i8* %recover, [label %try.cont, label %try.cont10, label %try.cont22]
+
+try.cont: ; preds = %lpad
+ call void @"\01?a@@YAXXZ"() #3
+ store i8 97, i8* %tmp2
+ invoke void @_CxxThrowException(i8* %tmp2, %eh.ThrowInfo* @_TI1D) #5
+ to label %unreachable unwind label %lpad3
+
+lpad3: ; preds = %try.cont
+ %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ catch %eh.CatchHandlerType* @llvm.eh.handlertype.D.0
+ catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
+ catch i8* null
+ %recover1 = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*), i32 1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch1", i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
+ indirectbr i8* %recover1, [label %try.cont10, label %try.cont22]
+
+try.cont10: ; preds = %lpad3, %lpad
+ call void @"\01?one@@YAXXZ"() #3
+ store i32 1, i32* %tmp11
+ %3 = bitcast i32* %tmp11 to i8*
+ invoke void @_CxxThrowException(i8* %3, %eh.ThrowInfo* @_TI1H) #5
+ to label %unreachable unwind label %lpad12
+
+lpad12: ; preds = %try.cont10
+ %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
+ catch i8* null
+ %recover2 = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch2", i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch3")
+ indirectbr i8* %recover2, [label %try.cont22]
+
+try.cont22: ; preds = %lpad12, %lpad3, %lpad
+ ret void
+
+unreachable: ; preds = %try.cont10, %try.cont, %entry
+ unreachable
+}
+
+; Function Attrs: nounwind
+declare void @"\01?two@@YAXXZ"() #1
+
+declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
+
+declare i32 @__CxxFrameHandler3(...)
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.eh.typeid.for(i8*) #2
+
+; Function Attrs: nounwind
+declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3
+
+; Function Attrs: nounwind
+declare void @"\01?catch_two@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare void @llvm.eh.endcatch() #3
+
+; Function Attrs: nounwind
+declare void @"\01?a@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare void @"\01?catch_a@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare void @"\01?one@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare void @"\01?catch_all@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare void @"\01?catch_one@@YAXXZ"() #1
+
+; Function Attrs: nounwind
+declare i8* @llvm.eh.actions(...) #3
+
+define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) #4 {
+entry:
+ %x.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
+ %x = bitcast i8* %x.i8 to i32*
+ %2 = bitcast i32* %x to i8*
+ call void @"\01?catch_two@@YAXXZ"() #3
+ invoke void @llvm.donothing()
+ to label %entry.split unwind label %stub
+
+entry.split: ; preds = %entry
+ ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont)
+
+stub: ; preds = %entry
+ %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ cleanup
+ %recover = call i8* (...) @llvm.eh.actions()
+ unreachable
+}
+
+; Function Attrs: nounwind readnone
+declare void @llvm.donothing() #2
+
+define internal i8* @"\01?test@@YAXXZ.catch1"(i8*, i8*) #4 {
+entry:
+ call void @"\01?catch_a@@YAXXZ"() #3
+ invoke void @llvm.donothing()
+ to label %entry.split unwind label %stub
+
+entry.split: ; preds = %entry
+ ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont10)
+
+stub: ; preds = %entry
+ %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ cleanup
+ %recover = call i8* (...) @llvm.eh.actions()
+ unreachable
+}
+
+define internal i8* @"\01?test@@YAXXZ.catch2"(i8*, i8*) #4 {
+entry:
+ %x21.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
+ %x21 = bitcast i8* %x21.i8 to i32*
+ %2 = bitcast i32* %x21 to i8*
+ call void @"\01?catch_one@@YAXXZ"() #3
+ invoke void @llvm.donothing()
+ to label %entry.split unwind label %stub
+
+entry.split: ; preds = %entry
+ ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont22)
+
+stub: ; preds = %entry
+ %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ cleanup
+ %recover = call i8* (...) @llvm.eh.actions()
+ unreachable
+}
+
+define internal i8* @"\01?test@@YAXXZ.catch3"(i8*, i8*) #4 {
+entry:
+ call void @"\01?catch_all@@YAXXZ"() #3
+ invoke void @llvm.donothing()
+ to label %entry.split unwind label %stub
+
+entry.split: ; preds = %entry
+ ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont22)
+
+stub: ; preds = %entry
+ %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
+ cleanup
+ %recover = call i8* (...) @llvm.eh.actions()
+ unreachable
+}
+
+; Function Attrs: nounwind
+declare void @llvm.frameescape(...) #3
+
+; Function Attrs: nounwind readnone
+declare i8* @llvm.framerecover(i8*, i8*, i32) #2
+
+attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "wineh-parent"="?test@@YAXXZ" }
+attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { nounwind readnone }
+attributes #3 = { nounwind }
+attributes #4 = { "wineh-parent"="?test@@YAXXZ" }
+attributes #5 = { noreturn }
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"PIC Level", i32 2}
+!1 = !{!"clang version 3.7.0 (trunk 236059)"}
+
+; CHECK-LABEL: "$cppxdata$?test@@YAXXZ":
+; CHECK-NEXT: .long 429065506
+; CHECK-NEXT: .long
+; CHECK-NEXT: .long ("$stateUnwindMap$?test@@YAXXZ")@IMGREL
+; CHECK-NEXT: .long
+; CHECK-NEXT: .long ("$tryMap$?test@@YAXXZ")@IMGREL
+; CHECK-NEXT: .long
+; CHECK-NEXT: .long ("$ip2state$?test@@YAXXZ")@IMGREL
+; CHECK-NEXT: .long 40
+; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 1
+; CHECK: "$stateUnwindMap$?test@@YAXXZ":
+; CHECK: "$tryMap$?test@@YAXXZ":
+; CHECK: "$handlerMap$0$?test@@YAXXZ":
+; CHECK: "$ip2state$?test@@YAXXZ":
+; CHECK-NEXT: .long .Lfunc_begin0 at IMGREL
+; CHECK-NEXT: .long -1
+; CHECK-NEXT: .long .Ltmp0 at IMGREL
+; CHECK-NEXT: .long 3
+; CHECK-NEXT: .long .Ltmp3 at IMGREL
+; CHECK-NEXT: .long 2
+; CHECK-NEXT: .long .Ltmp6 at IMGREL
+; CHECK-NEXT: .long 1
+; CHECK-NEXT: .long .Lfunc_begin1 at IMGREL
+; CHECK-NEXT: .long 4
+; CHECK-NEXT: .long .Lfunc_begin2 at IMGREL
+; CHECK-NEXT: .long 5
+; CHECK-NEXT: .long .Lfunc_begin3 at IMGREL
+; CHECK-NEXT: .long 6
+; CHECK-NEXT: .long .Lfunc_begin4 at IMGREL
+; CHECK-NEXT: .long 7
More information about the llvm-commits
mailing list