diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-catch-all.ll | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-inlined-finally.ll | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-outlined-finally.ll | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-prepared-basic.ll | 83 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-simple.ll | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/seh-basic.ll | 175 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/seh-except-finally.ll | 167 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/seh-filter.ll | 21 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/seh-finally.ll | 12 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/seh-safe-div.ll | 45 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/win_eh_prepare.ll | 6 |
11 files changed, 236 insertions, 281 deletions
diff --git a/llvm/test/CodeGen/WinEH/seh-catch-all.ll b/llvm/test/CodeGen/WinEH/seh-catch-all.ll index ab6c9effbf4..fb2b9ba7cfd 100644 --- a/llvm/test/CodeGen/WinEH/seh-catch-all.ll +++ b/llvm/test/CodeGen/WinEH/seh-catch-all.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -winehprepare < %s | FileCheck %s +; RUN: opt -S -winehprepare -sehprepare < %s | FileCheck %s target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc" diff --git a/llvm/test/CodeGen/WinEH/seh-inlined-finally.ll b/llvm/test/CodeGen/WinEH/seh-inlined-finally.ll index 21645cfc8ca..2e6171a8ced 100644 --- a/llvm/test/CodeGen/WinEH/seh-inlined-finally.ll +++ b/llvm/test/CodeGen/WinEH/seh-inlined-finally.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -winehprepare < %s | FileCheck %s +; RUN: opt -S -winehprepare -sehprepare < %s | FileCheck %s ; Check that things work when the mid-level optimizer inlines the finally ; block. diff --git a/llvm/test/CodeGen/WinEH/seh-outlined-finally.ll b/llvm/test/CodeGen/WinEH/seh-outlined-finally.ll index 19558b70530..bc9d3221ad4 100644 --- a/llvm/test/CodeGen/WinEH/seh-outlined-finally.ll +++ b/llvm/test/CodeGen/WinEH/seh-outlined-finally.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -winehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s +; RUN: opt -S -winehprepare -sehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s ; Test case based on this code: ; diff --git a/llvm/test/CodeGen/WinEH/seh-prepared-basic.ll b/llvm/test/CodeGen/WinEH/seh-prepared-basic.ll deleted file mode 100644 index 880bb3c33a8..00000000000 --- a/llvm/test/CodeGen/WinEH/seh-prepared-basic.ll +++ /dev/null @@ -1,83 +0,0 @@ -; RUN: llc < %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 "} diff --git a/llvm/test/CodeGen/WinEH/seh-simple.ll b/llvm/test/CodeGen/WinEH/seh-simple.ll index 0f863a681b5..344a0c87215 100644 --- a/llvm/test/CodeGen/WinEH/seh-simple.ll +++ b/llvm/test/CodeGen/WinEH/seh-simple.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -winehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s +; RUN: opt -S -winehprepare -sehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc" diff --git a/llvm/test/CodeGen/X86/seh-basic.ll b/llvm/test/CodeGen/X86/seh-basic.ll new file mode 100644 index 00000000000..69d70d70948 --- /dev/null +++ b/llvm/test/CodeGen/X86/seh-basic.ll @@ -0,0 +1,175 @@ +; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s + +define void @two_invoke_merged() { +entry: + invoke void @try_body() + to label %again unwind label %lpad + +again: + invoke void @try_body() + to label %done unwind label %lpad + +done: + ret void + +lpad: + %vals = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + catch i8* bitcast (i32 (i8*, i8*)* @filt0 to i8*) + catch i8* bitcast (i32 (i8*, i8*)* @filt1 to i8*) + %sel = extractvalue { i8*, i32 } %vals, 1 + call void @use_selector(i32 %sel) + ret void +} + +; Normal path code + +; CHECK-LABEL: {{^}}two_invoke_merged: +; CHECK: .seh_proc two_invoke_merged +; CHECK: .seh_handler __C_specific_handler, @unwind, @except +; CHECK: .Ltmp0: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp1: +; CHECK: .Ltmp2: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp3: +; CHECK: retq + +; Landing pad code + +; CHECK: .Ltmp5: +; CHECK: movl $1, %ecx +; CHECK: jmp +; CHECK: .Ltmp6: +; CHECK: movl $2, %ecx +; CHECK: callq use_selector + +; CHECK: .seh_handlerdata +; CHECK-NEXT: .long 2 +; CHECK-NEXT: .long .Ltmp0@IMGREL +; CHECK-NEXT: .long .Ltmp3@IMGREL+1 +; CHECK-NEXT: .long filt0@IMGREL +; CHECK-NEXT: .long .Ltmp5@IMGREL +; CHECK-NEXT: .long .Ltmp0@IMGREL +; CHECK-NEXT: .long .Ltmp3@IMGREL+1 +; CHECK-NEXT: .long filt1@IMGREL +; CHECK-NEXT: .long .Ltmp6@IMGREL +; CHECK: .text +; CHECK: .seh_endproc + +define void @two_invoke_gap() { +entry: + invoke void @try_body() + to label %again unwind label %lpad + +again: + call void @do_nothing_on_unwind() + invoke void @try_body() + to label %done unwind label %lpad + +done: + ret void + +lpad: + %vals = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + catch i8* bitcast (i32 (i8*, i8*)* @filt0 to i8*) + %sel = extractvalue { i8*, i32 } %vals, 1 + call void @use_selector(i32 %sel) + ret void +} + +; Normal path code + +; CHECK-LABEL: {{^}}two_invoke_gap: +; CHECK: .seh_proc two_invoke_gap +; CHECK: .seh_handler __C_specific_handler, @unwind, @except +; CHECK: .Ltmp11: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp12: +; CHECK: callq do_nothing_on_unwind +; CHECK: .Ltmp13: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp14: +; CHECK: retq + +; Landing pad code + +; CHECK: .Ltmp16: +; CHECK: movl $1, %ecx +; CHECK: callq use_selector + +; CHECK: .seh_handlerdata +; CHECK-NEXT: .long 2 +; CHECK-NEXT: .long .Ltmp11@IMGREL +; CHECK-NEXT: .long .Ltmp12@IMGREL+1 +; CHECK-NEXT: .long filt0@IMGREL +; CHECK-NEXT: .long .Ltmp16@IMGREL +; CHECK-NEXT: .long .Ltmp13@IMGREL +; CHECK-NEXT: .long .Ltmp14@IMGREL+1 +; CHECK-NEXT: .long filt0@IMGREL +; CHECK-NEXT: .long .Ltmp16@IMGREL +; CHECK: .text +; CHECK: .seh_endproc + +define void @two_invoke_nounwind_gap() { +entry: + invoke void @try_body() + to label %again unwind label %lpad + +again: + call void @cannot_unwind() + invoke void @try_body() + to label %done unwind label %lpad + +done: + ret void + +lpad: + %vals = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + catch i8* bitcast (i32 (i8*, i8*)* @filt0 to i8*) + %sel = extractvalue { i8*, i32 } %vals, 1 + call void @use_selector(i32 %sel) + ret void +} + +; Normal path code + +; CHECK-LABEL: {{^}}two_invoke_nounwind_gap: +; CHECK: .seh_proc two_invoke_nounwind_gap +; CHECK: .seh_handler __C_specific_handler, @unwind, @except +; CHECK: .Ltmp21: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp22: +; CHECK: callq cannot_unwind +; CHECK: .Ltmp23: +; CHECK: callq try_body +; CHECK-NEXT: .Ltmp24: +; CHECK: retq + +; Landing pad code + +; CHECK: .Ltmp26: +; CHECK: movl $1, %ecx +; CHECK: callq use_selector + +; CHECK: .seh_handlerdata +; CHECK-NEXT: .long 1 +; CHECK-NEXT: .long .Ltmp21@IMGREL +; CHECK-NEXT: .long .Ltmp24@IMGREL+1 +; CHECK-NEXT: .long filt0@IMGREL +; CHECK-NEXT: .long .Ltmp26@IMGREL +; CHECK: .text +; CHECK: .seh_endproc + +declare void @try_body() +declare void @do_nothing_on_unwind() +declare void @cannot_unwind() nounwind +declare void @use_selector(i32) + +declare i32 @filt0(i8* %eh_info, i8* %rsp) +declare i32 @filt1(i8* %eh_info, i8* %rsp) + +declare void @handler0() +declare void @handler1() + +declare i32 @__C_specific_handler(...) +declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind diff --git a/llvm/test/CodeGen/X86/seh-except-finally.ll b/llvm/test/CodeGen/X86/seh-except-finally.ll deleted file mode 100644 index c796f1ef288..00000000000 --- a/llvm/test/CodeGen/X86/seh-except-finally.ll +++ /dev/null @@ -1,167 +0,0 @@ -; RUN: llc < %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 } diff --git a/llvm/test/CodeGen/X86/seh-filter.ll b/llvm/test/CodeGen/X86/seh-filter.ll new file mode 100644 index 00000000000..6a3a23edb1a --- /dev/null +++ b/llvm/test/CodeGen/X86/seh-filter.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=x86_64-windows-msvc < %s | FileCheck %s + +declare void @g() +define void @f() { + invoke void @g() to label %return unwind label %lpad + +return: + ret void + +lpad: + %ehptrs = landingpad {i8*, i32} personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + filter [0 x i8*] zeroinitializer + call void @__cxa_call_unexpected(i8* null) + unreachable +} +declare i32 @__C_specific_handler(...) +declare void @__cxa_call_unexpected(i8*) + +; We don't emit entries for filters. +; CHECK: .seh_handlerdata +; CHECK: .long 0 diff --git a/llvm/test/CodeGen/X86/seh-finally.ll b/llvm/test/CodeGen/X86/seh-finally.ll index 91baed570f2..00601dcad54 100644 --- a/llvm/test/CodeGen/X86/seh-finally.ll +++ b/llvm/test/CodeGen/X86/seh-finally.ll @@ -32,18 +32,12 @@ terminate.lpad: ; preds = %lpad unreachable } -; CHECK-LABEL: main: +; CHECK: main: + +; FIXME: No handlers yet! ; 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*) diff --git a/llvm/test/CodeGen/X86/seh-safe-div.ll b/llvm/test/CodeGen/X86/seh-safe-div.ll index 80b15b60102..ba54f1cca60 100644 --- a/llvm/test/CodeGen/X86/seh-safe-div.ll +++ b/llvm/test/CodeGen/X86/seh-safe-div.ll @@ -71,34 +71,46 @@ __try.cont: ; CHECK: leaq [[rloc:.*\(%rsp\)]], %rcx ; CHECK: callq try_body ; CHECK-NEXT: .Ltmp1 -; CHECK: [[cont_bb:\.LBB0_[0-9]+]]: +; CHECK: .LBB0_7: ; CHECK: movl [[rloc]], %eax ; CHECK: retq ; Landing pad code -; CHECK: [[handler0:\.Ltmp[0-9]+]]: # Block address taken +; CHECK: .Ltmp3: +; CHECK: movl $1, %[[sel:[a-z]+]] +; CHECK: .Ltmp4 +; CHECK: movl $2, %[[sel]] +; CHECK: .L{{.*}}: +; CHECK: cmpl $1, %[[sel]] + ; CHECK: # %handler0 ; CHECK: callq puts ; CHECK: movl $-1, [[rloc]] -; CHECK: jmp [[cont_bb]] +; CHECK: jmp .LBB0_7 + +; CHECK: cmpl $2, %[[sel]] -; CHECK: [[handler1:\.Ltmp[0-9]+]]: # Block address taken ; CHECK: # %handler1 ; CHECK: callq puts ; CHECK: movl $-2, [[rloc]] -; CHECK: jmp [[cont_bb]] +; 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: .seh_handlerdata -; 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: .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: .text ; CHECK: .seh_endproc @@ -173,6 +185,11 @@ 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*) diff --git a/llvm/test/CodeGen/X86/win_eh_prepare.ll b/llvm/test/CodeGen/X86/win_eh_prepare.ll index a33dd92ad72..e5a7d055a78 100644 --- a/llvm/test/CodeGen/X86/win_eh_prepare.ll +++ b/llvm/test/CodeGen/X86/win_eh_prepare.ll @@ -43,10 +43,8 @@ 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: landingpad -; CHECK-NEXT: cleanup -; CHECK-NEXT: catch -; CHECK-NEXT: call i8* (...) @llvm.eh.actions({{.*}}) +; CHECK: eh.resume: +; CHECK-NEXT: unreachable ; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and |