diff options
Diffstat (limited to 'llvm/test/CodeGen/WinEH')
-rw-r--r-- | llvm/test/CodeGen/WinEH/cppeh-demote-liveout.ll | 8 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/cppeh-mixed-catch-and-cleanup.ll | 106 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/cppeh-shared-empty-catch.ll | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-catch-all.ll | 4 | ||||
-rw-r--r-- | llvm/test/CodeGen/WinEH/seh-simple.ll | 6 |
5 files changed, 116 insertions, 10 deletions
diff --git a/llvm/test/CodeGen/WinEH/cppeh-demote-liveout.ll b/llvm/test/CodeGen/WinEH/cppeh-demote-liveout.ll index 8be0fbc4c3a..2de2cc67aaa 100644 --- a/llvm/test/CodeGen/WinEH/cppeh-demote-liveout.ll +++ b/llvm/test/CodeGen/WinEH/cppeh-demote-liveout.ll @@ -55,18 +55,18 @@ resume: ; CHECK: invoke void @might_throw() ; ; CHECK: landingpad -; CHECK: indirectbr i8* {{.*}}, [label %ehreturn] +; CHECK: indirectbr i8* {{.*}}, [label %catchit.split] ; -; CHECK: ehreturn: +; CHECK: catchit.split: ; CHECK: load i32, i32* %val.lpad.reg2mem ; CHECK: br label %ret ; ; CHECK: ret: -; CHECK: %rv = phi i32 [ {{.*}}, %entry ], [ {{.*}}, %ehreturn ] +; CHECK: %rv = phi i32 [ {{.*}}, %entry ], [ {{.*}}, %catchit.split ] ; CHECK: ret i32 ; CHECK-LABEL: define internal i8* @liveout_catch.catch(i8*, i8*) ; CHECK: %[[val:[^ ]*]] = load i32, i32* ; CHECK-NEXT: %[[val_lpad:[^ ]*]] = add i32 %[[val]], 1 ; CHECK-NEXT: store i32 %[[val_lpad]], i32* -; CHECK: ret i8* blockaddress(@liveout_catch, %ehreturn) +; CHECK: ret i8* blockaddress(@liveout_catch, %catchit.split) diff --git a/llvm/test/CodeGen/WinEH/cppeh-mixed-catch-and-cleanup.ll b/llvm/test/CodeGen/WinEH/cppeh-mixed-catch-and-cleanup.ll new file mode 100644 index 00000000000..52f613276d5 --- /dev/null +++ b/llvm/test/CodeGen/WinEH/cppeh-mixed-catch-and-cleanup.ll @@ -0,0 +1,106 @@ +; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s + +; This test is based on the following code: +; +; void test() +; { +; try { +; Obj o; +; may_throw(); +; } catch (...) { +; } +; } +; +; The purpose of this test is to verify that we create separate catch and +; cleanup handlers. When compiling for the C++ 11 standard, this isn't +; strictly necessary, since calling the destructor from the catch handler +; would be logically equivalent to calling it from a cleanup handler. +; However, if the -std=c++98 option is used, an exception in the cleanup +; code should terminate the process (the MSVCRT runtime will do that) but +; if the destructor is called from the catch handler, it wouldn't terminate +; the process + + +; ModuleID = 'cppeh-mixed-catch-and-cleanup.cpp' +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +%class.Obj = type { i8 } + +; This just verifies that the function was processed by WinEHPrepare. +; +; CHECK-LABEL: define void @"\01?test@@YAXXZ"() +; CHECK: entry: +; CHECK: call void (...) @llvm.frameescape +; CHECK: } + +; Function Attrs: nounwind uwtable +define void @"\01?test@@YAXXZ"() #0 { +entry: + %o = alloca %class.Obj, align 1 + %exn.slot = alloca i8* + %ehselector.slot = alloca i32 + invoke void @"\01?may_throw@@YAXXZ"() + to label %invoke.cont unwind label %lpad + +invoke.cont: ; preds = %entry + call void @"\01??1Obj@@QEAA@XZ"(%class.Obj* %o) #3 + br label %try.cont + +lpad: ; preds = %entry + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) + 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 + call void @"\01??1Obj@@QEAA@XZ"(%class.Obj* %o) #3 + %exn = load i8*, i8** %exn.slot + call void @llvm.eh.begincatch(i8* %exn, i8* null) #3 + call void @llvm.eh.endcatch() #3 + br label %try.cont + +try.cont: ; preds = %catch, %invoke.cont + ret void +} + +; Verify that a cleanup handler was created and that it calls ~Obj(). +; CHECK-LABEL: define internal void @"\01?test@@YAXXZ.cleanup"(i8*, i8*) +; CHECK: entry: +; CHECK: @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0) +; CHECK: call void @"\01??1Obj@@QEAA@XZ" +; CHECK: ret void +; CHECK: } + +; Verify that a catch handler was created and that it does not call ~Obj(). +; CHECK-LABEL: define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) +; CHECK: entry: +; CHECK-NOT: call void @"\01??1Obj@@QEAA@XZ" +; CHECK: ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont) +; CHECK: } + + + +declare void @"\01?may_throw@@YAXXZ"() #1 + +declare i32 @__CxxFrameHandler3(...) + +; Function Attrs: nounwind +declare void @"\01??1Obj@@QEAA@XZ"(%class.Obj*) #2 + +; Function Attrs: nounwind +declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3 + +; Function Attrs: nounwind +declare void @llvm.eh.endcatch() #3 + +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" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { "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 "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 } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"PIC Level", i32 2} +!1 = !{!"clang version 3.7.0 (trunk 235779) (llvm/trunk 235769)"} diff --git a/llvm/test/CodeGen/WinEH/cppeh-shared-empty-catch.ll b/llvm/test/CodeGen/WinEH/cppeh-shared-empty-catch.ll index 0f8e805cc7c..dd99a092b20 100644 --- a/llvm/test/CodeGen/WinEH/cppeh-shared-empty-catch.ll +++ b/llvm/test/CodeGen/WinEH/cppeh-shared-empty-catch.ll @@ -59,7 +59,7 @@ lpad: ; preds = %entry ; CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) ; CHECK-NEXT: catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0 ; CHECK-NEXT: catch i8* null -; CHECK-NEXT: [[RECOVER:\%.+]] = call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1") +; CHECK-NEXT: [[RECOVER:\%.+]] = call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch") ; CHECK-NEXT: indirectbr i8* [[RECOVER]], [label %try.cont4] lpad1: ; preds = %invoke.cont diff --git a/llvm/test/CodeGen/WinEH/seh-catch-all.ll b/llvm/test/CodeGen/WinEH/seh-catch-all.ll index ab6c9effbf4..c2a652b8099 100644 --- a/llvm/test/CodeGen/WinEH/seh-catch-all.ll +++ b/llvm/test/CodeGen/WinEH/seh-catch-all.ll @@ -51,9 +51,9 @@ __try.cont: ; preds = %__except, %invoke.c ; CHECK-LABEL: define void @seh_catch_all() ; CHECK: landingpad ; CHECK-NEXT: catch i8* null -; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@seh_catch_all, %catch.all)) +; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@seh_catch_all, %lpad.split)) ; CHECK-NEXT: indirectbr ; -; CHECK: catch.all: +; CHECK: lpad.split: ; CHECK-NOT: extractvalue ; CHECK: call i32 @puts diff --git a/llvm/test/CodeGen/WinEH/seh-simple.ll b/llvm/test/CodeGen/WinEH/seh-simple.ll index a2a2139c270..aa9a6ca03b1 100644 --- a/llvm/test/CodeGen/WinEH/seh-simple.ll +++ b/llvm/test/CodeGen/WinEH/seh-simple.ll @@ -63,10 +63,10 @@ return: ; CHECK-LABEL: define i32 @catch_all() ; CHECK: landingpad { i8*, i32 } ; CHECK-NEXT: catch i8* null -; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@catch_all, %catch.all)) -; CHECK-NEXT: indirectbr {{.*}} [label %catch.all] +; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@catch_all, %lpad.split)) +; CHECK-NEXT: indirectbr {{.*}} [label %lpad.split] ; -; CHECK: catch.all: +; CHECK: lpad.split: ; CHECK: store i32 1, i32* %retval |