[InstCombine] Signed saturation patterns
[llvm-complete.git] / test / CodeGen / X86 / catchpad-reuse.ll
blob4a72b895f304cc2d0300d6cbe2fe6fb2b0711b57
1 ; RUN: llc < %s | FileCheck %s
3 ; IR generated by the following C++ source with modifications to reuse the 'v'
4 ; alloca between catchpads:
5 ; extern "C" void maythrow();
6 ; int main() {
7 ;   try {
8 ;     try {
9 ;       maythrow();
10 ;     } catch (int v) {
11 ;       maythrow();
12 ;     }
13 ;   } catch (int v) {
14 ;     maythrow();
15 ;   }
16 ;   return 0;
17 ; }
19 ; CHECK: $cppxdata$main:
20 ; CHECK-NEXT: .long   429065506               # MagicNumber
21 ; CHECK-NEXT: .long   4                       # MaxState
22 ; CHECK-NEXT: .long   ($stateUnwindMap$main)@IMGREL # UnwindMap
23 ; CHECK-NEXT: .long   2                       # NumTryBlocks
24 ; CHECK-NEXT: .long   ($tryMap$main)@IMGREL   # TryBlockMap
25 ; CHECK-NEXT: .long   5                       # IPMapEntries
26 ; CHECK-NEXT: .long   ($ip2state$main)@IMGREL # IPToStateXData
27 ; CHECK-NEXT: .long   32                      # UnwindHelp
28 ; CHECK-NEXT: .long   0                       # ESTypeList
29 ; CHECK-NEXT: .long   1                       # EHFlags
31 ; CHECK: $tryMap$main:
32 ; CHECK-NEXT: .long   1                       # TryLow
33 ; CHECK-NEXT: .long   1                       # TryHigh
34 ; CHECK-NEXT: .long   2                       # CatchHigh
35 ; CHECK-NEXT: .long   1                       # NumCatches
36 ; CHECK-NEXT: .long   ($handlerMap$0$main)@IMGREL # HandlerArray
37 ; CHECK-NEXT: .long   0                       # TryLow
38 ; CHECK-NEXT: .long   2                       # TryHigh
39 ; CHECK-NEXT: .long   3                       # CatchHigh
40 ; CHECK-NEXT: .long   1                       # NumCatches
41 ; CHECK-NEXT: .long   ($handlerMap$1$main)@IMGREL # HandlerArray
43 ; CHECK: $handlerMap$0$main:
44 ; CHECK-NEXT: .long   0                       # Adjectives
45 ; CHECK-NEXT: .long   "??_R0H@8"@IMGREL       # Type
46 ; CHECK-NEXT: .long   [[v_offset:[0-9]+]]     # CatchObjOffset
47 ; CHECK-NEXT: .long   "?catch$2@?0?main@4HA"@IMGREL # Handler
48 ; CHECK-NEXT: .long   {{.*}}                  # ParentFrameOffset
50 ; CHECK: $handlerMap$1$main:
51 ; CHECK-NEXT: .long   0                       # Adjectives
52 ; CHECK-NEXT: .long   "??_R0H@8"@IMGREL       # Type
53 ; CHECK-NEXT: .long   [[v_offset]]            # CatchObjOffset
54 ; CHECK-NEXT: .long   "?catch$4@?0?main@4HA"@IMGREL # Handler
55 ; CHECK-NEXT: .long   {{.*}}                      # ParentFrameOffset
57 ; ModuleID = 't.cpp'
58 source_filename = "t.cpp"
59 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
60 target triple = "x86_64-pc-windows-msvc19.0.24210"
62 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
64 $"\01??_R0H@8" = comdat any
66 @"\01??_7type_info@@6B@" = external constant i8*
67 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
69 ; Function Attrs: norecurse uwtable
70 define i32 @main() local_unnamed_addr personality i32 (...)* @__CxxFrameHandler3 {
71 entry:
72   %v = alloca i32, align 4
73   invoke void @maythrow()
74           to label %try.cont6 unwind label %catch.dispatch
76 catch.dispatch:                                   ; preds = %entry
77   %0 = catchswitch within none [label %catch] unwind label %catch.dispatch2
79 catch:                                            ; preds = %catch.dispatch
80   %1 = catchpad within %0 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %v]
81   invoke void @maythrow() [ "funclet"(token %1) ]
82           to label %invoke.cont1 unwind label %catch.dispatch2
84 catch.dispatch2:                                  ; preds = %catch, %catch.dispatch
85   %2 = catchswitch within none [label %catch3] unwind to caller
87 catch3:                                           ; preds = %catch.dispatch2
88   %3 = catchpad within %2 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %v]
89   call void @maythrow() [ "funclet"(token %3) ]
90   catchret from %3 to label %try.cont6
92 try.cont6:                                        ; preds = %entry, %invoke.cont1, %catch3
93   ret i32 0
95 invoke.cont1:                                     ; preds = %catch
96   catchret from %1 to label %try.cont6
99 declare void @maythrow() local_unnamed_addr #1
101 declare i32 @__CxxFrameHandler3(...)
103 !llvm.module.flags = !{!0}
104 !llvm.ident = !{!1}
106 !0 = !{i32 1, !"PIC Level", i32 2}
107 !1 = !{!"clang version 4.0.0 "}