1 ; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
3 ; This test was generated from the following source:
17 ; ModuleID = 'min-unwind.cpp'
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19 target triple = "x86_64-pc-windows-msvc"
21 ; This structure should be created for the frame allocation.
22 ; CHECK: %struct._Z4testv.ehdata = type { i32, i8*, %class.SomeClass }
24 %class.SomeClass = type { [28 x i32] }
26 ; The function entry should be rewritten like this.
27 ; CHECK: define void @_Z4testv() #0 {
29 ; CHECK: %frame.alloc = call i8* @llvm.frameallocate(i32 128)
30 ; CHECK: %eh.data = bitcast i8* %frame.alloc to %struct._Z4testv.ehdata*
31 ; CHECK-NOT: %obj = alloca %class.SomeClass, align 4
32 ; CHECK: %obj = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 2
34 ; Function Attrs: uwtable
35 define void @_Z4testv() #0 {
37 %obj = alloca %class.SomeClass, align 4
38 %exn.slot = alloca i8*
39 %ehselector.slot = alloca i32
40 call void @_ZN9SomeClassC1Ev(%class.SomeClass* %obj)
41 invoke void @_Z9may_throwv()
42 to label %invoke.cont unwind label %lpad
44 invoke.cont: ; preds = %entry
45 call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
48 lpad: ; preds = %entry
49 %tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
51 %tmp1 = extractvalue { i8*, i32 } %tmp, 0
52 store i8* %tmp1, i8** %exn.slot
53 %tmp2 = extractvalue { i8*, i32 } %tmp, 1
54 store i32 %tmp2, i32* %ehselector.slot
55 call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
58 eh.resume: ; preds = %lpad
59 %exn = load i8*, i8** %exn.slot
60 %sel = load i32, i32* %ehselector.slot
61 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn, 0
62 %lpad.val2 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1
63 resume { i8*, i32 } %lpad.val2
66 ; This cleanup handler should be outlined.
67 ; CHECK: define internal void @_Z4testv.cleanup(i8*, i8*) {
69 ; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)
70 ; CHECK: %eh.data = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*
71 ; CHECK: %obj = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 2
72 ; CHECK: call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
76 declare void @_ZN9SomeClassC1Ev(%class.SomeClass*) #1
78 declare void @_Z9may_throwv() #1
80 declare i32 @__CxxFrameHandler3(...)
82 declare void @_ZN9SomeClassD1Ev(%class.SomeClass*) #1
84 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
85 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
86 attributes #2 = { noinline noreturn nounwind }
87 attributes #3 = { noreturn nounwind }
88 attributes #4 = { nounwind }
92 !0 = !{!"clang version 3.7.0 (trunk 226027)"}