mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 07:30:31 +00:00
[WinEH] Fixes for a few cppeh failures.
Differential Review: http://reviews.llvm.org/D9065 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235239 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ee5f9c6278
commit
166679ef06
@ -196,6 +196,9 @@ public:
|
||||
virtual CloningAction handleResume(ValueToValueMapTy &VMap,
|
||||
const ResumeInst *Resume,
|
||||
BasicBlock *NewBB) = 0;
|
||||
virtual CloningAction handleCompare(ValueToValueMapTy &VMap,
|
||||
const CmpInst *Compare,
|
||||
BasicBlock *NewBB) = 0;
|
||||
virtual CloningAction handleLandingPad(ValueToValueMapTy &VMap,
|
||||
const LandingPadInst *LPad,
|
||||
BasicBlock *NewBB) = 0;
|
||||
@ -231,6 +234,8 @@ public:
|
||||
BasicBlock *NewBB) override;
|
||||
CloningAction handleResume(ValueToValueMapTy &VMap, const ResumeInst *Resume,
|
||||
BasicBlock *NewBB) override;
|
||||
CloningAction handleCompare(ValueToValueMapTy &VMap,
|
||||
const CmpInst *Compare, BasicBlock *NewBB) override;
|
||||
CloningAction handleLandingPad(ValueToValueMapTy &VMap,
|
||||
const LandingPadInst *LPad,
|
||||
BasicBlock *NewBB) override;
|
||||
@ -267,6 +272,8 @@ public:
|
||||
BasicBlock *NewBB) override;
|
||||
CloningAction handleResume(ValueToValueMapTy &VMap, const ResumeInst *Resume,
|
||||
BasicBlock *NewBB) override;
|
||||
CloningAction handleCompare(ValueToValueMapTy &VMap,
|
||||
const CmpInst *Compare, BasicBlock *NewBB) override;
|
||||
CloningAction handleLandingPad(ValueToValueMapTy &VMap,
|
||||
const LandingPadInst *LPad,
|
||||
BasicBlock *NewBB) override;
|
||||
@ -1053,6 +1060,9 @@ CloningDirector::CloningAction WinEHCloningDirectorBase::handleInstruction(
|
||||
if (auto *Resume = dyn_cast<ResumeInst>(Inst))
|
||||
return handleResume(VMap, Resume, NewBB);
|
||||
|
||||
if (auto *Cmp = dyn_cast<CmpInst>(Inst))
|
||||
return handleCompare(VMap, Cmp, NewBB);
|
||||
|
||||
if (match(Inst, m_Intrinsic<Intrinsic::eh_begincatch>()))
|
||||
return handleBeginCatch(VMap, Inst, NewBB);
|
||||
if (match(Inst, m_Intrinsic<Intrinsic::eh_endcatch>()))
|
||||
@ -1173,6 +1183,30 @@ WinEHCatchDirector::handleResume(ValueToValueMapTy &VMap,
|
||||
return CloningDirector::StopCloningBB;
|
||||
}
|
||||
|
||||
CloningDirector::CloningAction
|
||||
WinEHCatchDirector::handleCompare(ValueToValueMapTy &VMap,
|
||||
const CmpInst *Compare, BasicBlock *NewBB) {
|
||||
const IntrinsicInst *IntrinCall = nullptr;
|
||||
if (match(Compare->getOperand(0), m_Intrinsic<Intrinsic::eh_typeid_for>())) {
|
||||
IntrinCall = dyn_cast<IntrinsicInst>(Compare->getOperand(0));
|
||||
} else if (match(Compare->getOperand(1), m_Intrinsic<Intrinsic::eh_typeid_for>())) {
|
||||
IntrinCall = dyn_cast<IntrinsicInst>(Compare->getOperand(1));
|
||||
}
|
||||
if (IntrinCall) {
|
||||
Value *Selector = IntrinCall->getArgOperand(0)->stripPointerCasts();
|
||||
// This causes a replacement that will collapse the landing pad CFG based
|
||||
// on the filter function we intend to match.
|
||||
if (Selector == CurrentSelector->stripPointerCasts()) {
|
||||
VMap[Compare] = ConstantInt::get(SelectorIDType, 1);
|
||||
}
|
||||
else {
|
||||
VMap[Compare] = ConstantInt::get(SelectorIDType, 0);
|
||||
}
|
||||
return CloningDirector::SkipInstruction;
|
||||
}
|
||||
return CloningDirector::CloneInstruction;
|
||||
}
|
||||
|
||||
CloningDirector::CloningAction WinEHCleanupDirector::handleLandingPad(
|
||||
ValueToValueMapTy &VMap, const LandingPadInst *LPad, BasicBlock *NewBB) {
|
||||
// The MS runtime will terminate the process if an exception occurs in a
|
||||
@ -1189,11 +1223,11 @@ CloningDirector::CloningAction WinEHCleanupDirector::handleLandingPad(
|
||||
|
||||
CloningDirector::CloningAction WinEHCleanupDirector::handleBeginCatch(
|
||||
ValueToValueMapTy &VMap, const Instruction *Inst, BasicBlock *NewBB) {
|
||||
// Catch blocks within cleanup handlers will always be unreachable.
|
||||
// We'll insert an unreachable instruction now, but it will be pruned
|
||||
// before the cloning process is complete.
|
||||
BasicBlock::InstListType &InstList = NewBB->getInstList();
|
||||
InstList.push_back(new UnreachableInst(NewBB->getContext()));
|
||||
// Cleanup code may flow into catch blocks or the catch block may be part
|
||||
// of a branch that will be optimized away. We'll insert a return
|
||||
// instruction now, but it may be pruned before the cloning process is
|
||||
// complete.
|
||||
ReturnInst::Create(NewBB->getContext(), nullptr, NewBB);
|
||||
return CloningDirector::StopCloningBB;
|
||||
}
|
||||
|
||||
@ -1259,6 +1293,19 @@ CloningDirector::CloningAction WinEHCleanupDirector::handleResume(
|
||||
return CloningDirector::StopCloningBB;
|
||||
}
|
||||
|
||||
CloningDirector::CloningAction
|
||||
WinEHCleanupDirector::handleCompare(ValueToValueMapTy &VMap,
|
||||
const CmpInst *Compare, BasicBlock *NewBB) {
|
||||
const IntrinsicInst *IntrinCall = nullptr;
|
||||
if (match(Compare->getOperand(0), m_Intrinsic<Intrinsic::eh_typeid_for>()) ||
|
||||
match(Compare->getOperand(1), m_Intrinsic<Intrinsic::eh_typeid_for>())) {
|
||||
VMap[Compare] = ConstantInt::get(SelectorIDType, 1);
|
||||
return CloningDirector::SkipInstruction;
|
||||
}
|
||||
return CloningDirector::CloneInstruction;
|
||||
|
||||
}
|
||||
|
||||
WinEHFrameVariableMaterializer::WinEHFrameVariableMaterializer(
|
||||
Function *OutlinedFn, FrameVarInfoMap &FrameVarInfo)
|
||||
: FrameVarInfo(FrameVarInfo), Builder(OutlinedFn->getContext()) {
|
||||
@ -1355,10 +1402,21 @@ void WinEHPrepare::mapLandingPadBlocks(LandingPadInst *LPad,
|
||||
|
||||
// See if the clause we're looking for is a catch-all.
|
||||
// If so, the catch begins immediately.
|
||||
if (isa<ConstantPointerNull>(LPad->getClause(HandlersFound))) {
|
||||
Constant *ExpectedSelector = LPad->getClause(HandlersFound)->stripPointerCasts();
|
||||
if (isa<ConstantPointerNull>(ExpectedSelector)) {
|
||||
// The catch all must occur last.
|
||||
assert(HandlersFound == NumClauses - 1);
|
||||
|
||||
// There can be additional selector dispatches in the call chain that we
|
||||
// need to ignore.
|
||||
BasicBlock *CatchBlock = nullptr;
|
||||
Constant *Selector;
|
||||
while (BB && isSelectorDispatch(BB, CatchBlock, Selector, NextBB)) {
|
||||
DEBUG(dbgs() << " Found extra catch dispatch in block "
|
||||
<< CatchBlock->getName() << "\n");
|
||||
BB = NextBB;
|
||||
}
|
||||
|
||||
// For C++ EH, check if there is any interesting cleanup code before we
|
||||
// begin the catch. This is important because cleanups cannot rethrow
|
||||
// exceptions but code called from catches can. For SEH, it isn't
|
||||
@ -1368,8 +1426,10 @@ void WinEHPrepare::mapLandingPadBlocks(LandingPadInst *LPad,
|
||||
findCleanupHandlers(Actions, BB, BB);
|
||||
|
||||
// Add the catch handler to the action list.
|
||||
CatchHandler *Action =
|
||||
new CatchHandler(BB, LPad->getClause(HandlersFound), nullptr);
|
||||
// Since this is a catch-all handler, the selector won't actually appear
|
||||
// in the code anywhere. ExpectedSelector here is the constant null ptr
|
||||
// that we got from the landing pad instruction.
|
||||
CatchHandler *Action = new CatchHandler(BB, ExpectedSelector, nullptr);
|
||||
CatchHandlerMap[BB] = Action;
|
||||
Actions.insertCatchHandler(Action);
|
||||
DEBUG(dbgs() << " Catch all handler at block " << BB->getName() << "\n");
|
||||
@ -1385,12 +1445,21 @@ void WinEHPrepare::mapLandingPadBlocks(LandingPadInst *LPad,
|
||||
findCleanupHandlers(Actions, BB, CatchAction->getStartBlock());
|
||||
|
||||
assert(CatchAction);
|
||||
++HandlersFound;
|
||||
|
||||
// Add the catch handler to the action list.
|
||||
Actions.insertCatchHandler(CatchAction);
|
||||
DEBUG(dbgs() << " Found catch dispatch in block "
|
||||
<< CatchAction->getStartBlock()->getName() << "\n");
|
||||
// When the source program contains multiple nested try blocks the catch
|
||||
// handlers can get strung together in such a way that we can encounter
|
||||
// a dispatch for a selector that we've already had a handler for.
|
||||
if (CatchAction->getSelector()->stripPointerCasts() == ExpectedSelector) {
|
||||
++HandlersFound;
|
||||
|
||||
// Add the catch handler to the action list.
|
||||
DEBUG(dbgs() << " Found catch dispatch in block "
|
||||
<< CatchAction->getStartBlock()->getName() << "\n");
|
||||
Actions.insertCatchHandler(CatchAction);
|
||||
} else {
|
||||
DEBUG(dbgs() << " Found extra catch dispatch in block "
|
||||
<< CatchAction->getStartBlock()->getName() << "\n");
|
||||
}
|
||||
|
||||
// Move on to the block after the catch handler.
|
||||
BB = NextBB;
|
||||
|
143
test/CodeGen/WinEH/cppeh-catch-and-throw.ll
Normal file
143
test/CodeGen/WinEH/cppeh-catch-and-throw.ll
Normal file
@ -0,0 +1,143 @@
|
||||
; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
|
||||
|
||||
; This test is based on the following code:
|
||||
;
|
||||
; class Obj {
|
||||
; public:
|
||||
; ~Obj();
|
||||
; };
|
||||
;
|
||||
; void test(void)
|
||||
; {
|
||||
; try {
|
||||
; Obj o;
|
||||
; throw 1;
|
||||
; } catch (...) {
|
||||
; throw;
|
||||
; }
|
||||
; }
|
||||
|
||||
; ModuleID = 'cppeh-catch-and-throw.cpp'
|
||||
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.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
|
||||
%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
|
||||
%eh.ThrowInfo = type { i32, i32, i32, i32 }
|
||||
%class.Obj = type { i8 }
|
||||
|
||||
$"\01??_R0H@8" = comdat any
|
||||
|
||||
$"_CT??_R0H@84" = comdat any
|
||||
|
||||
$_CTA1H = comdat any
|
||||
|
||||
$_TI1H = comdat any
|
||||
|
||||
@"\01??_7type_info@@6B@" = external constant i8*
|
||||
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
|
||||
@__ImageBase = external constant i8
|
||||
@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat
|
||||
@_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@84" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
|
||||
@_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
|
||||
|
||||
; This is just a minimal check to verify that main was handled by WinEHPrepare.
|
||||
; CHECK: define void @"\01?test@@YAXXZ"()
|
||||
; CHECK: entry:
|
||||
; CHECK: call void (...) @llvm.frameescape
|
||||
; CHECK: invoke void @_CxxThrowException
|
||||
; CHECK: }
|
||||
|
||||
; Function Attrs: uwtable
|
||||
define void @"\01?test@@YAXXZ"() #0 {
|
||||
entry:
|
||||
%o = alloca %class.Obj, align 1
|
||||
%tmp = alloca i32, align 4
|
||||
%exn.slot = alloca i8*
|
||||
%ehselector.slot = alloca i32
|
||||
store i32 1, i32* %tmp
|
||||
%0 = bitcast i32* %tmp to i8*
|
||||
invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* @_TI1H) #3
|
||||
to label %unreachable unwind label %lpad
|
||||
|
||||
lpad: ; preds = %entry
|
||||
%1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch i8* null
|
||||
%2 = extractvalue { i8*, i32 } %1, 0
|
||||
store i8* %2, i8** %exn.slot
|
||||
%3 = extractvalue { i8*, i32 } %1, 1
|
||||
store i32 %3, i32* %ehselector.slot
|
||||
call void @"\01??1Obj@@QEAA@XZ"(%class.Obj* %o) #2
|
||||
br label %catch
|
||||
|
||||
catch: ; preds = %lpad
|
||||
%exn = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn, i8* null) #2
|
||||
invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #3
|
||||
to label %unreachable unwind label %lpad1
|
||||
|
||||
lpad1: ; preds = %catch
|
||||
%4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%5 = extractvalue { i8*, i32 } %4, 0
|
||||
store i8* %5, i8** %exn.slot
|
||||
%6 = extractvalue { i8*, i32 } %4, 1
|
||||
store i32 %6, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
try.cont: ; No predecessors!
|
||||
ret void
|
||||
|
||||
eh.resume: ; preds = %lpad1
|
||||
%exn2 = load i8*, i8** %exn.slot
|
||||
%sel = load i32, i32* %ehselector.slot
|
||||
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn2, 0
|
||||
%lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1
|
||||
resume { i8*, i32 } %lpad.val3
|
||||
|
||||
unreachable: ; preds = %catch, %entry
|
||||
unreachable
|
||||
}
|
||||
|
||||
; Verify that we inserted a stub invoke into the outlined cleanup handler.
|
||||
;
|
||||
; CHECK-LABEL: define internal void @"\01?test@@YAXXZ.cleanup"(i8*, i8*)
|
||||
; CHECK: entry:
|
||||
; CHECK: call i8* @llvm.framerecover
|
||||
; CHECK: call void @"\01??1Obj@@QEAA@XZ"
|
||||
; CHECK: invoke void @llvm.donothing()
|
||||
; CHECK: to label %[[SPLIT_LABEL:.+]] unwind label %[[LPAD_LABEL:.+]]
|
||||
;
|
||||
; CHECK: [[SPLIT_LABEL]]
|
||||
;
|
||||
; CHECK: [[LPAD_LABEL]]
|
||||
; CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
; CHECK: cleanup
|
||||
; CHECK: unreachable
|
||||
; CHECK: }
|
||||
|
||||
declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
|
||||
|
||||
declare i32 @__CxxFrameHandler3(...)
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @"\01??1Obj@@QEAA@XZ"(%class.Obj*) #1
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #2
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @llvm.eh.endcatch() #2
|
||||
|
||||
attributes #0 = { 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" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
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" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
attributes #2 = { nounwind }
|
||||
attributes #3 = { noreturn }
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
!llvm.ident = !{!1}
|
||||
|
||||
!0 = !{i32 1, !"PIC Level", i32 2}
|
||||
!1 = !{!"clang version 3.7.0 (trunk 235214) (llvm/trunk 235213)"}
|
394
test/CodeGen/WinEH/cppeh-similar-catch-blocks.ll
Normal file
394
test/CodeGen/WinEH/cppeh-similar-catch-blocks.ll
Normal file
@ -0,0 +1,394 @@
|
||||
; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
|
||||
|
||||
; This test is based on the following code:
|
||||
;
|
||||
; int main(void) {
|
||||
; try {
|
||||
; try {
|
||||
; throw 'a';
|
||||
; } catch (char c) {
|
||||
; printf("%c\n", c);
|
||||
; }
|
||||
; throw 1;
|
||||
; } catch(int x) {
|
||||
; printf("%d\n", x);
|
||||
; } catch(...) {
|
||||
; printf("...\n");
|
||||
; }
|
||||
; try {
|
||||
; try {
|
||||
; throw 'b';
|
||||
; } catch (char c) {
|
||||
; printf("%c\n", c);
|
||||
; }
|
||||
; throw 2;
|
||||
; } catch(int x) {
|
||||
; printf("%d\n", x);
|
||||
; } catch (char c) {
|
||||
; printf("%c\n", c);
|
||||
; } catch(...) {
|
||||
; printf("...\n");
|
||||
; }
|
||||
; return 0;
|
||||
; }
|
||||
|
||||
; This test is just checking for failures in processing the IR.
|
||||
; Extensive handler matching is not required.
|
||||
|
||||
; ModuleID = 'cppeh-similar-catch-blocks.cpp'
|
||||
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@8" = comdat any
|
||||
|
||||
$"\01??_R0D@8" = comdat any
|
||||
|
||||
$"_CT??_R0D@81" = comdat any
|
||||
|
||||
$_CTA1D = comdat any
|
||||
|
||||
$_TI1D = comdat any
|
||||
|
||||
$"\01??_C@_03PJCJOCBM@?$CFc?6?$AA@" = comdat any
|
||||
|
||||
$"_CT??_R0H@84" = comdat any
|
||||
|
||||
$_CTA1H = comdat any
|
||||
|
||||
$_TI1H = comdat any
|
||||
|
||||
$"\01??_C@_04MPPNMCOK@?4?4?4?6?$AA@" = comdat any
|
||||
|
||||
$"\01??_C@_03PMGGPEJJ@?$CFd?6?$AA@" = comdat any
|
||||
|
||||
@"\01??_7type_info@@6B@" = external constant i8*
|
||||
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
|
||||
@llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) }, section "llvm.metadata"
|
||||
@"\01??_R0D@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".D\00" }, comdat
|
||||
@llvm.eh.handlertype.D.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0D@8" to i8*) }, section "llvm.metadata"
|
||||
@__ImageBase = external constant i8
|
||||
@"_CT??_R0D@81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0D@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 1, i32 0 }, section ".xdata", comdat
|
||||
@_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@81" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
|
||||
@_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
|
||||
@"\01??_C@_03PJCJOCBM@?$CFc?6?$AA@" = linkonce_odr unnamed_addr constant [4 x i8] c"%c\0A\00", comdat, align 1
|
||||
@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat
|
||||
@_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@84" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
|
||||
@_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
|
||||
@"\01??_C@_04MPPNMCOK@?4?4?4?6?$AA@" = linkonce_odr unnamed_addr constant [5 x i8] c"...\0A\00", comdat, align 1
|
||||
@"\01??_C@_03PMGGPEJJ@?$CFd?6?$AA@" = linkonce_odr unnamed_addr constant [4 x i8] c"%d\0A\00", comdat, align 1
|
||||
|
||||
; This is just a minimal check to verify that main was handled by WinEHPrepare.
|
||||
; CHECK: define i32 @main()
|
||||
; CHECK: entry:
|
||||
; CHECK: call void (...) @llvm.frameescape(i8* [[C_PTR:\%.+]], i32* [[X_PTR:\%.+]], i8* [[C2_PTR:\%.+]], i32* [[X2_PTR:\%.+]], i8* [[C3_PTR:\%.+]])
|
||||
; CHECK: invoke void @_CxxThrowException
|
||||
; CHECK: }
|
||||
|
||||
; Function Attrs: uwtable
|
||||
define i32 @main() #0 {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%tmp = alloca i8, align 1
|
||||
%exn.slot = alloca i8*
|
||||
%ehselector.slot = alloca i32
|
||||
%c = alloca i8, align 1
|
||||
%tmp3 = alloca i32, align 4
|
||||
%x = alloca i32, align 4
|
||||
%tmp20 = alloca i8, align 1
|
||||
%c28 = alloca i8, align 1
|
||||
%tmp34 = alloca i32, align 4
|
||||
%c48 = alloca i8, align 1
|
||||
%x56 = alloca i32, align 4
|
||||
store i32 0, i32* %retval
|
||||
store i8 97, i8* %tmp
|
||||
invoke void @_CxxThrowException(i8* %tmp, %eh.ThrowInfo* @_TI1D) #4
|
||||
to label %unreachable unwind label %lpad
|
||||
|
||||
lpad: ; preds = %entry
|
||||
%0 = 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
|
||||
%1 = extractvalue { i8*, i32 } %0, 0
|
||||
store i8* %1, i8** %exn.slot
|
||||
%2 = extractvalue { i8*, i32 } %0, 1
|
||||
store i32 %2, i32* %ehselector.slot
|
||||
br label %catch.dispatch
|
||||
|
||||
catch.dispatch: ; preds = %lpad
|
||||
%sel = load i32, i32* %ehselector.slot
|
||||
%3 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)) #2
|
||||
%matches = icmp eq i32 %sel, %3
|
||||
br i1 %matches, label %catch, label %catch.dispatch5
|
||||
|
||||
catch: ; preds = %catch.dispatch
|
||||
%exn = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn, i8* %c) #2
|
||||
%4 = load i8, i8* %c, align 1
|
||||
%conv = sext i8 %4 to i32
|
||||
%call = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01??_C@_03PJCJOCBM@?$CFc?6?$AA@", i32 0, i32 0), i32 %conv)
|
||||
to label %invoke.cont unwind label %lpad2
|
||||
|
||||
invoke.cont: ; preds = %catch
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont
|
||||
|
||||
try.cont: ; preds = %invoke.cont
|
||||
store i32 1, i32* %tmp3
|
||||
%5 = bitcast i32* %tmp3 to i8*
|
||||
invoke void @_CxxThrowException(i8* %5, %eh.ThrowInfo* @_TI1H) #4
|
||||
to label %unreachable unwind label %lpad4
|
||||
|
||||
lpad2: ; preds = %catch
|
||||
%6 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
|
||||
catch i8* null
|
||||
%7 = extractvalue { i8*, i32 } %6, 0
|
||||
store i8* %7, i8** %exn.slot
|
||||
%8 = extractvalue { i8*, i32 } %6, 1
|
||||
store i32 %8, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %catch.dispatch5
|
||||
|
||||
lpad4: ; preds = %try.cont
|
||||
%9 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
|
||||
catch i8* null
|
||||
%10 = extractvalue { i8*, i32 } %9, 0
|
||||
store i8* %10, i8** %exn.slot
|
||||
%11 = extractvalue { i8*, i32 } %9, 1
|
||||
store i32 %11, i32* %ehselector.slot
|
||||
br label %catch.dispatch5
|
||||
|
||||
catch.dispatch5: ; preds = %lpad4, %lpad2, %catch.dispatch
|
||||
%sel6 = load i32, i32* %ehselector.slot
|
||||
%12 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)) #2
|
||||
%matches7 = icmp eq i32 %sel6, %12
|
||||
br i1 %matches7, label %catch13, label %catch8
|
||||
|
||||
catch13: ; preds = %catch.dispatch5
|
||||
%exn14 = load i8*, i8** %exn.slot
|
||||
%13 = bitcast i32* %x to i8*
|
||||
call void @llvm.eh.begincatch(i8* %exn14, i8* %13) #2
|
||||
%14 = load i32, i32* %x, align 4
|
||||
%call18 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01??_C@_03PMGGPEJJ@?$CFd?6?$AA@", i32 0, i32 0), i32 %14)
|
||||
to label %invoke.cont17 unwind label %lpad16
|
||||
|
||||
invoke.cont17: ; preds = %catch13
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont19
|
||||
|
||||
try.cont19: ; preds = %invoke.cont17, %invoke.cont11
|
||||
store i8 98, i8* %tmp20
|
||||
invoke void @_CxxThrowException(i8* %tmp20, %eh.ThrowInfo* @_TI1D) #4
|
||||
to label %unreachable unwind label %lpad21
|
||||
|
||||
catch8: ; preds = %catch.dispatch5
|
||||
%exn9 = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn9, i8* null) #2
|
||||
%call12 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @"\01??_C@_04MPPNMCOK@?4?4?4?6?$AA@", i32 0, i32 0))
|
||||
to label %invoke.cont11 unwind label %lpad10
|
||||
|
||||
invoke.cont11: ; preds = %catch8
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont19
|
||||
|
||||
lpad10: ; preds = %catch8
|
||||
%15 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%16 = extractvalue { i8*, i32 } %15, 0
|
||||
store i8* %16, i8** %exn.slot
|
||||
%17 = extractvalue { i8*, i32 } %15, 1
|
||||
store i32 %17, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
lpad16: ; preds = %catch13
|
||||
%18 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%19 = extractvalue { i8*, i32 } %18, 0
|
||||
store i8* %19, i8** %exn.slot
|
||||
%20 = extractvalue { i8*, i32 } %18, 1
|
||||
store i32 %20, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
lpad21: ; preds = %try.cont19
|
||||
%21 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
|
||||
catch i8* null
|
||||
%22 = extractvalue { i8*, i32 } %21, 0
|
||||
store i8* %22, i8** %exn.slot
|
||||
%23 = extractvalue { i8*, i32 } %21, 1
|
||||
store i32 %23, i32* %ehselector.slot
|
||||
br label %catch.dispatch22
|
||||
|
||||
catch.dispatch22: ; preds = %lpad21
|
||||
%sel23 = load i32, i32* %ehselector.slot
|
||||
%24 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)) #2
|
||||
%matches24 = icmp eq i32 %sel23, %24
|
||||
br i1 %matches24, label %catch25, label %catch.dispatch36
|
||||
|
||||
catch25: ; preds = %catch.dispatch22
|
||||
%exn26 = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn26, i8* %c28) #2
|
||||
%25 = load i8, i8* %c28, align 1
|
||||
%conv29 = sext i8 %25 to i32
|
||||
%call32 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01??_C@_03PJCJOCBM@?$CFc?6?$AA@", i32 0, i32 0), i32 %conv29)
|
||||
to label %invoke.cont31 unwind label %lpad30
|
||||
|
||||
invoke.cont31: ; preds = %catch25
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont33
|
||||
|
||||
try.cont33: ; preds = %invoke.cont31
|
||||
store i32 2, i32* %tmp34
|
||||
%26 = bitcast i32* %tmp34 to i8*
|
||||
invoke void @_CxxThrowException(i8* %26, %eh.ThrowInfo* @_TI1H) #4
|
||||
to label %unreachable unwind label %lpad35
|
||||
|
||||
lpad30: ; preds = %catch25
|
||||
%27 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)
|
||||
catch i8* null
|
||||
%28 = extractvalue { i8*, i32 } %27, 0
|
||||
store i8* %28, i8** %exn.slot
|
||||
%29 = extractvalue { i8*, i32 } %27, 1
|
||||
store i32 %29, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %catch.dispatch36
|
||||
|
||||
lpad35: ; preds = %try.cont33
|
||||
%30 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
|
||||
catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)
|
||||
catch i8* null
|
||||
%31 = extractvalue { i8*, i32 } %30, 0
|
||||
store i8* %31, i8** %exn.slot
|
||||
%32 = extractvalue { i8*, i32 } %30, 1
|
||||
store i32 %32, i32* %ehselector.slot
|
||||
br label %catch.dispatch36
|
||||
|
||||
catch.dispatch36: ; preds = %lpad35, %lpad30, %catch.dispatch22
|
||||
%sel37 = load i32, i32* %ehselector.slot
|
||||
%33 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)) #2
|
||||
%matches38 = icmp eq i32 %sel37, %33
|
||||
br i1 %matches38, label %catch53, label %catch.fallthrough
|
||||
|
||||
catch53: ; preds = %catch.dispatch36
|
||||
%exn54 = load i8*, i8** %exn.slot
|
||||
%34 = bitcast i32* %x56 to i8*
|
||||
call void @llvm.eh.begincatch(i8* %exn54, i8* %34) #2
|
||||
%35 = load i32, i32* %x56, align 4
|
||||
%call59 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01??_C@_03PMGGPEJJ@?$CFd?6?$AA@", i32 0, i32 0), i32 %35)
|
||||
to label %invoke.cont58 unwind label %lpad57
|
||||
|
||||
invoke.cont58: ; preds = %catch53
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont60
|
||||
|
||||
try.cont60: ; preds = %invoke.cont58, %invoke.cont51, %invoke.cont43
|
||||
ret i32 0
|
||||
|
||||
catch.fallthrough: ; preds = %catch.dispatch36
|
||||
%36 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.D.0 to i8*)) #2
|
||||
%matches39 = icmp eq i32 %sel37, %36
|
||||
br i1 %matches39, label %catch45, label %catch40
|
||||
|
||||
catch45: ; preds = %catch.fallthrough
|
||||
%exn46 = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn46, i8* %c48) #2
|
||||
%37 = load i8, i8* %c48, align 1
|
||||
%conv49 = sext i8 %37 to i32
|
||||
%call52 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01??_C@_03PJCJOCBM@?$CFc?6?$AA@", i32 0, i32 0), i32 %conv49)
|
||||
to label %invoke.cont51 unwind label %lpad50
|
||||
|
||||
invoke.cont51: ; preds = %catch45
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont60
|
||||
|
||||
catch40: ; preds = %catch.fallthrough
|
||||
%exn41 = load i8*, i8** %exn.slot
|
||||
call void @llvm.eh.begincatch(i8* %exn41, i8* null) #2
|
||||
%call44 = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @"\01??_C@_04MPPNMCOK@?4?4?4?6?$AA@", i32 0, i32 0))
|
||||
to label %invoke.cont43 unwind label %lpad42
|
||||
|
||||
invoke.cont43: ; preds = %catch40
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %try.cont60
|
||||
|
||||
lpad42: ; preds = %catch40
|
||||
%38 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%39 = extractvalue { i8*, i32 } %38, 0
|
||||
store i8* %39, i8** %exn.slot
|
||||
%40 = extractvalue { i8*, i32 } %38, 1
|
||||
store i32 %40, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
lpad50: ; preds = %catch45
|
||||
%41 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%42 = extractvalue { i8*, i32 } %41, 0
|
||||
store i8* %42, i8** %exn.slot
|
||||
%43 = extractvalue { i8*, i32 } %41, 1
|
||||
store i32 %43, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
lpad57: ; preds = %catch53
|
||||
%44 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
|
||||
cleanup
|
||||
%45 = extractvalue { i8*, i32 } %44, 0
|
||||
store i8* %45, i8** %exn.slot
|
||||
%46 = extractvalue { i8*, i32 } %44, 1
|
||||
store i32 %46, i32* %ehselector.slot
|
||||
call void @llvm.eh.endcatch() #2
|
||||
br label %eh.resume
|
||||
|
||||
eh.resume: ; preds = %lpad57, %lpad50, %lpad42, %lpad16, %lpad10
|
||||
%exn61 = load i8*, i8** %exn.slot
|
||||
%sel62 = load i32, i32* %ehselector.slot
|
||||
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn61, 0
|
||||
%lpad.val63 = insertvalue { i8*, i32 } %lpad.val, i32 %sel62, 1
|
||||
resume { i8*, i32 } %lpad.val63
|
||||
|
||||
unreachable: ; preds = %try.cont33, %try.cont19, %try.cont, %entry
|
||||
unreachable
|
||||
}
|
||||
|
||||
declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
|
||||
|
||||
declare i32 @__CxxFrameHandler3(...)
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i32 @llvm.eh.typeid.for(i8*) #1
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #2
|
||||
|
||||
declare i32 @printf(i8*, ...) #3
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @llvm.eh.endcatch() #2
|
||||
|
||||
attributes #0 = { 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" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
attributes #1 = { nounwind readnone }
|
||||
attributes #2 = { nounwind }
|
||||
attributes #3 = { "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
attributes #4 = { noreturn }
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
!llvm.ident = !{!1}
|
||||
|
||||
!0 = !{i32 1, !"PIC Level", i32 2}
|
||||
!1 = !{!"clang version 3.7.0 (trunk 235214) (llvm/trunk 235213)"}
|
Loading…
Reference in New Issue
Block a user