Re-land r235154-r235156 under the existing -sehprepare flag

Keep the old SEH fan-in lowering on by default for now, since projects
rely on it.  This will make it easy to test this change with a simple
flag flip.

llvm-svn: 235399
This commit is contained in:
Reid Kleckner 2015-04-21 18:23:57 +00:00
parent d0a2ae054f
commit d2a1a51996
13 changed files with 420 additions and 48 deletions

View File

@ -221,6 +221,8 @@ public:
int getArgumentFrameIndex(const Argument *A);
private:
void addSEHHandlersForLPads();
/// LiveOutRegInfo - Information about live out vregs.
IndexedMap<LiveOutInfo, VirtReg2IndexFunctor> LiveOutRegInfo;
};

View File

@ -51,6 +51,7 @@ namespace llvm {
// Forward declarations.
class Constant;
class GlobalVariable;
class BlockAddress;
class MDNode;
class MMIAddrLabelMap;
class MachineBasicBlock;
@ -60,6 +61,14 @@ class PointerType;
class StructType;
struct WinEHFuncInfo;
struct SEHHandler {
// Filter or finally function. Null indicates a catch-all.
const Function *FilterOrFinally;
// Address of block to recover at. Null for a finally handler.
const BlockAddress *RecoverBA;
};
//===----------------------------------------------------------------------===//
/// LandingPadInfo - This structure is used to retain landing pad info for
/// the current function.
@ -69,6 +78,7 @@ struct LandingPadInfo {
SmallVector<MCSymbol *, 1> BeginLabels; // Labels prior to invoke.
SmallVector<MCSymbol *, 1> EndLabels; // Labels after invoke.
SmallVector<MCSymbol *, 1> ClauseLabels; // Labels for each clause.
SmallVector<SEHHandler, 1> SEHHandlers; // SEH handlers active at this lpad.
MCSymbol *LandingPadLabel; // Label at beginning of landing pad.
const Function *Personality; // Personality function.
std::vector<int> TypeIds; // List of type ids (filters negative).
@ -356,6 +366,12 @@ public:
/// each clause gets its own basic block.
MCSymbol *addClauseForLandingPad(MachineBasicBlock *LandingPad);
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter,
const BlockAddress *RecoverLabel);
void addSEHCleanupHandler(MachineBasicBlock *LandingPad,
const Function *Cleanup);
/// getTypeIDFor - Return the type id for the specified typeinfo. This is
/// function wide.
unsigned getTypeIDFor(const GlobalValue *TI);

View File

@ -260,7 +260,10 @@ private:
SDNode *MorphNode(SDNode *Node, unsigned TargetOpc, SDVTList VTs,
ArrayRef<SDValue> Ops, unsigned EmitNodeInfo);
void PrepareEHLandingPad();
/// Prepares the landing pad to take incoming values or do other EH
/// personality specific tasks. Returns true if the block should be
/// instruction selected, false if no code should be emitted for it.
bool PrepareEHLandingPad();
/// \brief Perform instruction selection on all basic blocks in the function.
void SelectAllBasicBlocks(const Function &Fn);

View File

@ -212,9 +212,14 @@ void Win64Exception::emitCSpecificHandlerTable() {
if (isCatchEHSelector(Selector))
++NumEntries;
}
NumEntries += CSE.LPad->SEHHandlers.size();
}
Asm->OutStreamer.EmitIntValue(NumEntries, 4);
// If there are no actions, we don't need to iterate again.
if (NumEntries == 0)
return;
// Emit the four-label records for each call site entry. The table has to be
// sorted in layout order, and the call sites should already be sorted.
for (const CallSiteEntry &CSE : CallSites) {
@ -240,6 +245,31 @@ void Win64Exception::emitCSpecificHandlerTable() {
End = createImageRel32(EHFuncEndSym);
}
// Emit an entry for each action.
for (SEHHandler Handler : LPad->SEHHandlers) {
Asm->OutStreamer.EmitValue(Begin, 4);
Asm->OutStreamer.EmitValue(End, 4);
// Emit the filter or finally function pointer, if present. Otherwise,
// emit '1' to indicate a catch-all.
const Function *F = Handler.FilterOrFinally;
if (F)
Asm->OutStreamer.EmitValue(createImageRel32(Asm->getSymbol(F)), 4);
else
Asm->OutStreamer.EmitIntValue(1, 4);
// Emit the recovery address, if present. Otherwise, this must be a
// finally.
const BlockAddress *BA = Handler.RecoverBA;
if (BA)
Asm->OutStreamer.EmitValue(
createImageRel32(Asm->GetBlockAddressSymbol(BA)), 4);
else
Asm->OutStreamer.EmitIntValue(0, 4);
}
if (!LPad->SEHHandlers.empty())
continue;
// These aren't really type info globals, they are actually pointers to
// filter functions ordered by selector. The zero selector is used for
// cleanups, so slot zero corresponds to selector 1.

View File

@ -469,6 +469,25 @@ MachineModuleInfo::addClauseForLandingPad(MachineBasicBlock *LandingPad) {
return ClauseLabel;
}
void MachineModuleInfo::addSEHCatchHandler(MachineBasicBlock *LandingPad,
const Function *Filter,
const BlockAddress *RecoverBA) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
SEHHandler Handler;
Handler.FilterOrFinally = Filter;
Handler.RecoverBA = RecoverBA;
LP.SEHHandlers.push_back(Handler);
}
void MachineModuleInfo::addSEHCleanupHandler(MachineBasicBlock *LandingPad,
const Function *Cleanup) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
SEHHandler Handler;
Handler.FilterOrFinally = Cleanup;
Handler.RecoverBA = nullptr;
LP.SEHHandlers.push_back(Handler);
}
/// TidyLandingPads - Remap landing pad labels and remove any deleted landing
/// pads.
void MachineModuleInfo::TidyLandingPads(DenseMap<MCSymbol*, uintptr_t> *LPMap) {

View File

@ -270,12 +270,21 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
}
// Mark landing pad blocks.
for (BB = Fn->begin(); BB != EB; ++BB)
const LandingPadInst *LP = nullptr;
for (BB = Fn->begin(); BB != EB; ++BB) {
if (const auto *Invoke = dyn_cast<InvokeInst>(BB->getTerminator()))
MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad();
if (BB->isLandingPad())
LP = BB->getLandingPadInst();
}
// Calculate EH numbers for WinEH.
if (fn.hasFnAttribute("wineh-parent")) {
// Calculate EH numbers for MSVC C++ EH and save SEH handlers if necessary.
EHPersonality Personality = EHPersonality::Unknown;
if (LP)
Personality = classifyEHPersonality(LP->getPersonalityFn());
if (Personality == EHPersonality::MSVC_Win64SEH) {
addSEHHandlersForLPads();
} else if (Personality == EHPersonality::MSVC_CXX) {
const Function *WinEHParentFn = MMI.getWinEHParent(&fn);
WinEHFuncInfo &FI = MMI.getWinEHFuncInfo(WinEHParentFn);
if (FI.LandingPadStateMap.empty()) {
@ -287,6 +296,47 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
}
}
void FunctionLoweringInfo::addSEHHandlersForLPads() {
MachineModuleInfo &MMI = MF->getMMI();
// Iterate over all landing pads with llvm.eh.actions calls.
for (const BasicBlock &BB : *Fn) {
const LandingPadInst *LP = BB.getLandingPadInst();
if (!LP)
continue;
const IntrinsicInst *ActionsCall =
dyn_cast<IntrinsicInst>(LP->getNextNode());
if (!ActionsCall ||
ActionsCall->getIntrinsicID() != Intrinsic::eh_actions)
continue;
// Parse the llvm.eh.actions call we found.
MachineBasicBlock *LPadMBB = MBBMap[LP->getParent()];
SmallVector<ActionHandler *, 4> Actions;
parseEHActions(ActionsCall, Actions);
// Iterate EH actions from most to least precedence, which means
// iterating in reverse.
for (auto I = Actions.rbegin(), E = Actions.rend(); I != E; ++I) {
ActionHandler *Action = *I;
if (auto *CH = dyn_cast<CatchHandler>(Action)) {
const auto *Filter =
dyn_cast<Function>(CH->getSelector()->stripPointerCasts());
assert((Filter || CH->getSelector()->isNullValue()) &&
"expected function or catch-all");
const auto *RecoverBA =
cast<BlockAddress>(CH->getHandlerBlockOrFunc());
MMI.addSEHCatchHandler(LPadMBB, Filter, RecoverBA);
} else {
assert(isa<CleanupHandler>(Action));
const auto *Fini = cast<Function>(Action->getHandlerBlockOrFunc());
MMI.addSEHCleanupHandler(LPadMBB, Fini);
}
}
DeleteContainerPointers(Actions);
}
}
void WinEHNumbering::createUnwindMapEntry(int ToState, ActionHandler *AH) {
WinEHUnwindMapEntry UME;
UME.ToState = ToState;

View File

@ -911,7 +911,7 @@ void SelectionDAGISel::DoInstructionSelection() {
/// PrepareEHLandingPad - Emit an EH_LABEL, set up live-in registers, and
/// do other setup for EH landing-pad blocks.
void SelectionDAGISel::PrepareEHLandingPad() {
bool SelectionDAGISel::PrepareEHLandingPad() {
MachineBasicBlock *MBB = FuncInfo->MBB;
const TargetRegisterClass *PtrRC = TLI->getRegClassFor(TLI->getPointerTy());
@ -937,12 +937,12 @@ void SelectionDAGISel::PrepareEHLandingPad() {
if (isMSVCEHPersonality(Personality)) {
SmallVector<MachineBasicBlock *, 4> ClauseBBs;
const IntrinsicInst *Actions =
const IntrinsicInst *ActionsCall =
dyn_cast<IntrinsicInst>(LLVMBB->getFirstInsertionPt());
// Get all invoke BBs that unwind to this landingpad.
SmallVector<MachineBasicBlock *, 4> InvokeBBs(MBB->pred_begin(),
MBB->pred_end());
if (Actions && Actions->getIntrinsicID() == Intrinsic::eh_actions) {
if (ActionsCall && ActionsCall->getIntrinsicID() == Intrinsic::eh_actions) {
// If this is a call to llvm.eh.actions followed by indirectbr, then we've
// run WinEHPrepare, and we should remove this block from the machine CFG.
// Mark the targets of the indirectbr as landingpads instead.
@ -951,11 +951,15 @@ void SelectionDAGISel::PrepareEHLandingPad() {
// Add the edge from the invoke to the clause.
for (MachineBasicBlock *InvokeBB : InvokeBBs)
InvokeBB->addSuccessor(ClauseBB);
// Mark the clause as a landing pad or MI passes will delete it.
ClauseBB->setIsLandingPad();
}
} else {
// Otherwise, we haven't done the preparation, and we need to invent some
// clause basic blocks that branch into the landingpad.
// FIXME: Remove this code once SEH preparation works.
ActionsCall = nullptr;
// Make virtual registers and a series of labels that fill in values for
// the clauses.
@ -1017,7 +1021,10 @@ void SelectionDAGISel::PrepareEHLandingPad() {
WinEHFuncInfo &FI = MF->getMMI().getWinEHFuncInfo(MF->getFunction());
MF->getMMI().addWinEHState(MBB, FI.LandingPadStateMap[LPadInst]);
}
return;
// Select instructions for the landingpad if there was no llvm.eh.actions
// call.
return ActionsCall == nullptr;
}
// Mark exception register as live in.
@ -1027,6 +1034,8 @@ void SelectionDAGISel::PrepareEHLandingPad() {
// Mark exception selector register as live in.
if (unsigned Reg = TLI->getExceptionSelectorRegister())
FuncInfo->ExceptionSelectorVirtReg = MBB->addLiveIn(Reg, PtrRC);
return true;
}
/// isFoldedOrDeadInstruction - Return true if the specified instruction is
@ -1197,7 +1206,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
FuncInfo->ExceptionPointerVirtReg = 0;
FuncInfo->ExceptionSelectorVirtReg = 0;
if (LLVMBB->isLandingPad())
PrepareEHLandingPad();
if (!PrepareEHLandingPad())
continue;
// Before doing SelectionDAG ISel, see if FastISel has been requested.
if (FastIS) {

View File

@ -0,0 +1,83 @@
; RUN: llc -sehprepare < %s | FileCheck %s
; Test case based on this code:
; extern "C" unsigned long _exception_code();
; extern "C" int filt(unsigned long);
; extern "C" void g();
; extern "C" void do_except() {
; __try {
; g();
; } __except(filt(_exception_code())) {
; }
; }
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
; Function Attrs: uwtable
define void @do_except() #0 {
entry:
call void (...) @llvm.frameescape()
invoke void @g() #5
to label %__try.cont unwind label %lpad1
lpad1: ; preds = %entry
%ehvals = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
catch i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@do_except@@" to i8*)
%recover = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@do_except@@" to i8*), i32 -1, i8* blockaddress(@do_except, %__try.cont))
indirectbr i8* %recover, [label %__try.cont]
__try.cont: ; preds = %lpad1, %entry
ret void
}
; CHECK-LABEL: do_except:
; CHECK: .seh_handler __C_specific_handler
; CHECK-NOT: jmpq *
; CHECK: .seh_handlerdata
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long .Ltmp{{.*}}
; CHECK-NEXT: .long .Ltmp{{.*}}
; CHECK-NEXT: .long "?filt$0@0@do_except@@"@IMGREL
; CHECK-NEXT: .long .Ltmp{{.*}}@IMGREL
; Function Attrs: noinline nounwind
define internal i32 @"\01?filt$0@0@do_except@@"(i8* nocapture readonly %exception_pointers, i8* nocapture readnone %frame_pointer) #1 {
entry:
%0 = bitcast i8* %exception_pointers to i32**
%1 = load i32*, i32** %0, align 8
%2 = load i32, i32* %1, align 4
%call = tail call i32 @filt(i32 %2) #4
ret i32 %call
}
declare i32 @filt(i32) #2
declare void @g() #2
declare i32 @__C_specific_handler(...)
; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #3
; Function Attrs: nounwind
declare i8* @llvm.eh.actions(...) #4
; Function Attrs: nounwind
declare void @llvm.frameescape(...) #4
; Function Attrs: nounwind readnone
declare i8* @llvm.framerecover(i8*, i8*, i32) #3
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" "wineh-parent"="do_except" }
attributes #1 = { noinline 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 = { "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 #3 = { nounwind readnone }
attributes #4 = { nounwind }
attributes #5 = { noinline }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"PIC Level", i32 2}
!1 = !{!"clang version 3.7.0 "}

View File

@ -1,3 +1,4 @@
; RUN: llc -sehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
@str = internal unnamed_addr constant [10 x i8] c"recovered\00", align 1

View File

@ -0,0 +1,167 @@
; RUN: llc -sehprepare < %s | FileCheck %s
; Test case based on this source:
; int puts(const char*);
; __declspec(noinline) void crash() {
; *(volatile int*)0 = 42;
; }
; int filt();
; void use_both() {
; __try {
; __try {
; crash();
; } __finally {
; puts("__finally");
; }
; } __except (filt()) {
; puts("__except");
; }
; }
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
$"\01??_C@_09KJEHOMHG@__finally?$AA@" = comdat any
$"\01??_C@_08MLCMLGHM@__except?$AA@" = comdat any
@"\01??_C@_09KJEHOMHG@__finally?$AA@" = linkonce_odr unnamed_addr constant [10 x i8] c"__finally\00", comdat, align 1
@"\01??_C@_08MLCMLGHM@__except?$AA@" = linkonce_odr unnamed_addr constant [9 x i8] c"__except\00", comdat, align 1
declare void @crash()
declare i32 @filt()
; Function Attrs: nounwind uwtable
define void @use_both() #1 {
entry:
%exn.slot = alloca i8*
%ehselector.slot = alloca i32
invoke void @crash() #5
to label %invoke.cont unwind label %lpad
invoke.cont: ; preds = %entry
%0 = call i8* @llvm.frameaddress(i32 0)
invoke void @"\01?fin$0@0@use_both@@"(i1 zeroext false, i8* %0) #5
to label %invoke.cont2 unwind label %lpad1
invoke.cont2: ; preds = %invoke.cont
br label %__try.cont
lpad: ; preds = %entry
%1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
cleanup
catch i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@use_both@@" to i8*)
%2 = extractvalue { i8*, i32 } %1, 0
store i8* %2, i8** %exn.slot
%3 = extractvalue { i8*, i32 } %1, 1
store i32 %3, i32* %ehselector.slot
%4 = call i8* @llvm.frameaddress(i32 0)
invoke void @"\01?fin$0@0@use_both@@"(i1 zeroext true, i8* %4) #5
to label %invoke.cont3 unwind label %lpad1
lpad1: ; preds = %lpad, %invoke.cont
%5 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
catch i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@use_both@@" to i8*)
%6 = extractvalue { i8*, i32 } %5, 0
store i8* %6, i8** %exn.slot
%7 = extractvalue { i8*, i32 } %5, 1
store i32 %7, i32* %ehselector.slot
br label %catch.dispatch
invoke.cont3: ; preds = %lpad
br label %catch.dispatch
catch.dispatch: ; preds = %invoke.cont3, %lpad1
%sel = load i32, i32* %ehselector.slot
%8 = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@use_both@@" to i8*)) #6
%matches = icmp eq i32 %sel, %8
br i1 %matches, label %__except, label %eh.resume
__except: ; preds = %catch.dispatch
%call = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @"\01??_C@_08MLCMLGHM@__except?$AA@", i32 0, i32 0))
br label %__try.cont
__try.cont: ; preds = %__except, %invoke.cont2
ret void
eh.resume: ; preds = %catch.dispatch
%exn = load i8*, i8** %exn.slot
%sel4 = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn, 0
%lpad.val5 = insertvalue { i8*, i32 } %lpad.val, i32 %sel4, 1
resume { i8*, i32 } %lpad.val5
}
; CHECK-LABEL: use_both:
; CHECK: .Ltmp0
; CHECK: callq crash
; CHECK: .Ltmp1
; CHECK: .Ltmp3
; CHECK: callq "?fin$0@0@use_both@@"
; CHECK: .Ltmp4
; CHECK: retq
;
; CHECK: .seh_handlerdata
; CHECK-NEXT: .long 3
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long .Ltmp1@IMGREL+1
; CHECK-NEXT: .long "?fin$0@0@use_both@@"@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long .Ltmp1@IMGREL+1
; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL
; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
; CHECK-NEXT: .long .Ltmp3@IMGREL
; CHECK-NEXT: .long .Ltmp4@IMGREL+1
; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL
; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
; Function Attrs: noinline nounwind
define internal i32 @"\01?filt$0@0@use_both@@"(i8* %exception_pointers, i8* %frame_pointer) #2 {
entry:
%frame_pointer.addr = alloca i8*, align 8
%exception_pointers.addr = alloca i8*, align 8
%exn.slot = alloca i8*
store i8* %frame_pointer, i8** %frame_pointer.addr, align 8
store i8* %exception_pointers, i8** %exception_pointers.addr, align 8
%0 = load i8*, i8** %exception_pointers.addr
%1 = bitcast i8* %0 to { i32*, i8* }*
%2 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %1, i32 0, i32 0
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = zext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %exn.slot
%call = call i32 @filt()
ret i32 %call
}
define internal void @"\01?fin$0@0@use_both@@"(i1 zeroext %abnormal_termination, i8* %frame_pointer) #3 {
entry:
%frame_pointer.addr = alloca i8*, align 8
%abnormal_termination.addr = alloca i8, align 1
store i8* %frame_pointer, i8** %frame_pointer.addr, align 8
%frombool = zext i1 %abnormal_termination to i8
store i8 %frombool, i8* %abnormal_termination.addr, align 1
%call = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @"\01??_C@_09KJEHOMHG@__finally?$AA@", i32 0, i32 0))
ret void
}
declare i32 @puts(i8*) #3
declare i32 @__C_specific_handler(...)
; Function Attrs: nounwind readnone
declare i8* @llvm.frameaddress(i32) #4
; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #4
attributes #0 = { noinline 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" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { 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" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { noinline 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 #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 = { nounwind readnone }
attributes #5 = { noinline }
attributes #6 = { nounwind }

View File

@ -1,4 +1,4 @@
; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
; RUN: llc -sehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s
@str_recovered = internal unnamed_addr constant [10 x i8] c"recovered\00", align 1
@ -32,12 +32,18 @@ terminate.lpad: ; preds = %lpad
unreachable
}
; CHECK: main:
; FIXME: No handlers yet!
; CHECK-LABEL: main:
; CHECK: .seh_handlerdata
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long .Ltmp1@IMGREL
; CHECK-NEXT: .long main.cleanup@IMGREL
; CHECK-NEXT: .long 0
; CHECK-LABEL: main.cleanup:
; CHECK: callq puts
; CHECK: retq
declare i32 @__C_specific_handler(...)
declare i32 @puts(i8*)

View File

@ -1,4 +1,4 @@
; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
; RUN: llc -sehprepare -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
; This test case is also intended to be run manually as a complete functional
; test. It should link, print something, and exit zero rather than crashing.
@ -71,46 +71,34 @@ __try.cont:
; CHECK: leaq [[rloc:.*\(%rsp\)]], %rcx
; CHECK: callq try_body
; CHECK-NEXT: .Ltmp1
; CHECK: .LBB0_7:
; CHECK: [[cont_bb:\.LBB0_[0-9]+]]:
; CHECK: movl [[rloc]], %eax
; CHECK: retq
; Landing pad code
; CHECK: .Ltmp3:
; CHECK: movl $1, %[[sel:[a-z]+]]
; CHECK: .Ltmp4
; CHECK: movl $2, %[[sel]]
; CHECK: .L{{.*}}:
; CHECK: cmpl $1, %[[sel]]
; CHECK: [[handler0:\.Ltmp[0-9]+]]: # Block address taken
; CHECK: # %handler0
; CHECK: callq puts
; CHECK: movl $-1, [[rloc]]
; CHECK: jmp .LBB0_7
; CHECK: cmpl $2, %[[sel]]
; CHECK: jmp [[cont_bb]]
; CHECK: [[handler1:\.Ltmp[0-9]+]]: # Block address taken
; CHECK: # %handler1
; CHECK: callq puts
; CHECK: movl $-2, [[rloc]]
; CHECK: jmp .LBB0_7
; FIXME: EH preparation should eliminate the 'resume' instr and we should not do
; the previous 'cmp;jeq'.
; CHECK-NOT: _Unwind_Resume
; CHECK: ud2
; CHECK: jmp [[cont_bb]]
; CHECK: .seh_handlerdata
; CHECK: .long 2
; CHECK: .long .Ltmp0@IMGREL
; CHECK: .long .Ltmp1@IMGREL+1
; CHECK: .long safe_div_filt0@IMGREL
; CHECK: .long .Ltmp3@IMGREL
; CHECK: .long .Ltmp0@IMGREL
; CHECK: .long .Ltmp1@IMGREL+1
; CHECK: .long safe_div_filt1@IMGREL
; CHECK: .long .Ltmp4@IMGREL
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long .Ltmp1@IMGREL+1
; CHECK-NEXT: .long safe_div_filt0@IMGREL
; CHECK-NEXT: .long [[handler0]]@IMGREL
; CHECK-NEXT: .long .Ltmp0@IMGREL
; CHECK-NEXT: .long .Ltmp1@IMGREL+1
; CHECK-NEXT: .long safe_div_filt1@IMGREL
; CHECK-NEXT: .long [[handler1]]@IMGREL
; CHECK: .text
; CHECK: .seh_endproc
@ -185,11 +173,6 @@ define i32 @main() {
ret i32 0
}
define void @_Unwind_Resume() {
call void @abort()
unreachable
}
declare i32 @__C_specific_handler(...)
declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind
declare void @puts(i8*)

View File

@ -1,4 +1,4 @@
; RUN: opt -S -winehprepare -dwarfehprepare -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
; RUN: opt -S -winehprepare -sehprepare -dwarfehprepare -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
; FIXME: Add and test outlining here.
@ -43,8 +43,10 @@ define internal i32 @filt_g(i8*, i8*) {
; CHECK-LABEL: define i32 @use_seh()
; CHECK: invoke void @maybe_throw()
; CHECK-NEXT: to label %cont unwind label %lpad
; CHECK: eh.resume:
; CHECK-NEXT: unreachable
; CHECK: landingpad
; CHECK-NEXT: cleanup
; CHECK-NEXT: catch
; CHECK-NEXT: call i8* (...) @llvm.eh.actions({{.*}})
; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and