[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / llvm / test / CodeGen / X86 / win-catchpad-nested-cxx.ll
blobb5d914153ffd3c8b7ef591877c9744c1ab7ab579
1 ; RUN: llc -verify-machineinstrs -mtriple=i686-pc-windows-msvc < %s \
2 ; RUN:     | FileCheck --check-prefix=CHECK --check-prefix=X86 %s
3 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc < %s \
4 ; RUN:     | FileCheck --check-prefix=CHECK --check-prefix=X64 %s
6 ; Loosely based on IR for this C++ source code:
7 ;   void f(int p);
8 ;   void try_in_catch() {
9 ;     try {
10 ;       f(1);
11 ;     } catch (...) {
12 ;       try {
13 ;         f(2);
14 ;       } catch (...) {
15 ;         f(3);
16 ;       }
17 ;     }
18 ;   }
20 declare void @f(i32 %p)
21 declare i32 @__CxxFrameHandler3(...)
23 define i32 @try_in_catch() personality ptr @__CxxFrameHandler3 {
24 entry:
25   invoke void @f(i32 1)
26           to label %try.cont unwind label %catch.dispatch.1
27 try.cont:
28   ret i32 0
30 catch.dispatch.1:
31   %cs1 = catchswitch within none [label %handler1] unwind to caller
32 handler1:
33   %h1 = catchpad within %cs1 [ptr null, i32 64, ptr null]
34   invoke void @f(i32 2) [ "funclet"(token %h1) ]
35           to label %catchret1 unwind label %catch.dispatch.2
36 catchret1:
37   catchret from %h1 to label %try.cont
39 catch.dispatch.2:
40   %cs2 = catchswitch within %h1 [label %handler2] unwind to caller
41 handler2:
42   %h2 = catchpad within %cs2 [ptr null, i32 64, ptr null]
43   call void @f(i32 3)
44   catchret from %h2 to label %catchret1
47 ; X86-LABEL: L__ehtable$try_in_catch:
48 ; X64-LABEL: $cppxdata$try_in_catch:
49 ; CHECK-NEXT: .long   429065506
50 ; CHECK-NEXT: .long   4
51 ; CHECK-NEXT: .long   ($stateUnwindMap$try_in_catch)
52 ; CHECK-NEXT: .long   2
53 ; CHECK-NEXT: .long   ($tryMap$try_in_catch)
54 ; ip2state num + ptr
55 ; X86-NEXT: .long   0
56 ; X86-NEXT: .long   0
57 ; X64-NEXT: .long   7
58 ; X64-NEXT: .long   ($ip2state$try_in_catch)
59 ; unwindhelp offset
60 ; X64-NEXT: .long   40
61 ; CHECK-NEXT: .long   0
62 ; EHFlags
63 ; CHECK-NEXT: .long   1
65 ; X86-LABEL: $tryMap$try_in_catch:
66 ; X86-NEXT: .long   2
67 ; X86-NEXT: .long   2
68 ; X86-NEXT: .long   3
69 ; X86-NEXT: .long   1
70 ; X86-NEXT: .long   ($handlerMap$0$try_in_catch)
71 ; X86-NEXT: .long   0
72 ; X86-NEXT: .long   0
73 ; X86-NEXT: .long   3
74 ; X86-NEXT: .long   1
75 ; X86-NEXT: .long   ($handlerMap$1$try_in_catch)
77 ; X64-LABEL: $tryMap$try_in_catch:
78 ; X64-NEXT: .long   0
79 ; X64-NEXT: .long   0
80 ; X64-NEXT: .long   3
81 ; X64-NEXT: .long   1
82 ; X64-NEXT: .long   ($handlerMap$0$try_in_catch)
83 ; X64-NEXT: .long   2
84 ; X64-NEXT: .long   2
85 ; X64-NEXT: .long   3
86 ; X64-NEXT: .long   1
87 ; X64-NEXT: .long   ($handlerMap$1$try_in_catch)
89 ; CHECK: $handlerMap$0$try_in_catch:
90 ; CHECK-NEXT:   .long   64
91 ; CHECK-NEXT:   .long   0
92 ; CHECK-NEXT:   .long   0
93 ; CHECK-NEXT:   .long   "?catch${{[0-9]+}}@?0?try_in_catch@4HA"
94 ; X64-NEXT:   .long   56
96 ; CHECK: $handlerMap$1$try_in_catch:
97 ; CHECK-NEXT:   .long   64
98 ; CHECK-NEXT:   .long   0
99 ; CHECK-NEXT:   .long   0
100 ; CHECK-NEXT:   .long   "?catch${{[0-9]+}}@?0?try_in_catch@4HA"
101 ; X64-NEXT:   .long   56
103 ; X64: $ip2state$try_in_catch:
104 ; X64-NEXT: .long   .Lfunc_begin0@IMGREL
105 ; X64-NEXT: .long   -1
106 ; X64-NEXT: .long   .Ltmp0@IMGREL+1
107 ; X64-NEXT: .long   0
108 ; X64-NEXT: .long   .Ltmp1@IMGREL+1
109 ; X64-NEXT: .long   -1
110 ; X64-NEXT: .long   "?catch$2@?0?try_in_catch@4HA"@IMGREL
111 ; X64-NEXT: .long   1
112 ; X64-NEXT: .long   .Ltmp2@IMGREL+1
113 ; X64-NEXT: .long   2
114 ; X64-NEXT: .long   .Ltmp3@IMGREL+1
115 ; X64-NEXT: .long   1
116 ; X64-NEXT: .long   "?catch$4@?0?try_in_catch@4HA"@IMGREL
117 ; X64-NEXT: .long   3