0f8e805cc7c6762769f98e5f7f2590c25d17ba2b
[oota-llvm.git] / test / CodeGen / WinEH / cppeh-shared-empty-catch.ll
1 ; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
2
3 ; This test is based on the following source, built with -O2
4 ;
5 ; void f() {
6 ;   try {
7 ;     g();
8 ;     try {
9 ;       throw;
10 ;     } catch (int) {
11 ;     }
12 ;   } catch (...) {
13 ;   }
14 ; }
15 ;
16
17 ; ModuleID = '<stdin>'
18 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
19 target triple = "x86_64-pc-windows-msvc"
20
21 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
22 %eh.CatchHandlerType = type { i32, i8* }
23 %eh.ThrowInfo = type { i32, i32, i32, i32 }
24
25 $"\01??_R0H@8" = comdat any
26
27 @"\01??_7type_info@@6B@" = external constant i8*
28 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
29 @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"
30
31 ; CHECK-LABEL: define void @"\01?f@@YAXXZ"()
32 ; CHECK: entry:
33 ; CHECK:   call void (...) @llvm.frameescape()
34 ; CHECK:   invoke void @"\01?g@@YAXXZ"()
35
36 ; Function Attrs: nounwind
37 define void @"\01?f@@YAXXZ"() #0 {
38 entry:
39   invoke void @"\01?g@@YAXXZ"()
40           to label %invoke.cont unwind label %lpad
41
42 ; CHECK-LABEL: invoke.cont:
43 ; CHECK:   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null)
44 ; CHECK:           to label %unreachable unwind label %[[LPAD1_LABEL:lpad[0-9]+]]
45
46 invoke.cont:                                      ; preds = %entry
47   invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #4
48           to label %unreachable unwind label %lpad1
49
50 lpad:                                             ; preds = %entry
51   %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
52           catch i8* null
53   %1 = extractvalue { i8*, i32 } %0, 0
54   br label %catch2
55
56 ; Note: Even though this landing pad has two catch clauses, it only has one action because both
57 ;       handlers do the same thing.
58 ; CHECK: [[LPAD1_LABEL]]:
59 ; CHECK:   landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
60 ; CHECK-NEXT:           catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
61 ; CHECK-NEXT:           catch i8* null
62 ; CHECK-NEXT:   [[RECOVER:\%.+]] = call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* (i8*, i8*)* @"\01?f@@YAXXZ.catch1")
63 ; CHECK-NEXT:   indirectbr i8* [[RECOVER]], [label %try.cont4]
64
65 lpad1:                                            ; preds = %invoke.cont
66   %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
67           catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
68           catch i8* null
69   %3 = extractvalue { i8*, i32 } %2, 0
70   br label %catch2
71
72 catch2:                                           ; preds = %lpad1, %lpad
73   %exn.slot.0 = phi i8* [ %3, %lpad1 ], [ %1, %lpad ]
74   tail call void @llvm.eh.begincatch(i8* %exn.slot.0, i8* null) #3
75   tail call void @llvm.eh.endcatch() #3
76   br label %try.cont4
77
78 try.cont4:                                        ; preds = %catch, %catch2
79   ret void
80
81 unreachable:                                      ; preds = %invoke.cont
82   unreachable
83
84 ; CHECK: }
85 }
86
87 declare void @"\01?g@@YAXXZ"() #1
88
89 declare i32 @__CxxFrameHandler3(...)
90
91 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
92
93 ; Function Attrs: nounwind readnone
94 declare i32 @llvm.eh.typeid.for(i8*) #2
95
96 ; Function Attrs: nounwind
97 declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3
98
99 ; Function Attrs: nounwind
100 declare void @llvm.eh.endcatch() #3
101
102 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
103 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
104 attributes #2 = { nounwind readnone }
105 attributes #3 = { nounwind }
106 attributes #4 = { noreturn }
107
108 !llvm.ident = !{!0}
109
110 !0 = !{!"clang version 3.7.0 (trunk 235112) (llvm/trunk 235121)"}