xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/catchpad-regmask.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Based on this code:
4*9880d681SAndroid Build Coastguard Worker;
5*9880d681SAndroid Build Coastguard Worker; extern "C" int array[4];
6*9880d681SAndroid Build Coastguard Worker; extern "C" void global_array(int idx1, int idx2, int idx3) {
7*9880d681SAndroid Build Coastguard Worker;   try {
8*9880d681SAndroid Build Coastguard Worker;     array[idx1] = 111;
9*9880d681SAndroid Build Coastguard Worker;     throw;
10*9880d681SAndroid Build Coastguard Worker;   } catch (...) {
11*9880d681SAndroid Build Coastguard Worker;     array[idx2] = 222;
12*9880d681SAndroid Build Coastguard Worker;   }
13*9880d681SAndroid Build Coastguard Worker;   array[idx3] = 333;
14*9880d681SAndroid Build Coastguard Worker; }
15*9880d681SAndroid Build Coastguard Worker; extern "C" __declspec(dllimport) int imported;
16*9880d681SAndroid Build Coastguard Worker; extern "C" void access_imported() {
17*9880d681SAndroid Build Coastguard Worker;   try {
18*9880d681SAndroid Build Coastguard Worker;     imported = 111;
19*9880d681SAndroid Build Coastguard Worker;     throw;
20*9880d681SAndroid Build Coastguard Worker;   } catch (...) {
21*9880d681SAndroid Build Coastguard Worker;     imported = 222;
22*9880d681SAndroid Build Coastguard Worker;   }
23*9880d681SAndroid Build Coastguard Worker;   imported = 333;
24*9880d681SAndroid Build Coastguard Worker; }
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
27*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-pc-windows-msvc18.0.0"
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker%eh.ThrowInfo = type { i32, i32, i32, i32 }
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker@array = external global [4 x i32], align 16
32*9880d681SAndroid Build Coastguard Worker@imported = external dllimport global i32, align 4
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
35*9880d681SAndroid Build Coastguard Workerdefine void @global_array(i32 %idx1, i32 %idx2, i32 %idx3) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker  %idxprom = sext i32 %idx1 to i64
38*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds [4 x i32], [4 x i32]* @array, i64 0, i64 %idxprom
39*9880d681SAndroid Build Coastguard Worker  store i32 111, i32* %arrayidx, align 4, !tbaa !2
40*9880d681SAndroid Build Coastguard Worker  invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
41*9880d681SAndroid Build Coastguard Worker          to label %unreachable unwind label %catch.dispatch
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workercatch.dispatch:                                   ; preds = %entry
44*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch] unwind to caller
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workercatch:                                            ; preds = %catch.dispatch
47*9880d681SAndroid Build Coastguard Worker  %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
48*9880d681SAndroid Build Coastguard Worker  %idxprom1 = sext i32 %idx2 to i64
49*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds [4 x i32], [4 x i32]* @array, i64 0, i64 %idxprom1
50*9880d681SAndroid Build Coastguard Worker  store i32 222, i32* %arrayidx2, align 4, !tbaa !2
51*9880d681SAndroid Build Coastguard Worker  catchret from %0 to label %try.cont
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Workertry.cont:                                         ; preds = %catch
54*9880d681SAndroid Build Coastguard Worker  %idxprom3 = sext i32 %idx3 to i64
55*9880d681SAndroid Build Coastguard Worker  %arrayidx4 = getelementptr inbounds [4 x i32], [4 x i32]* @array, i64 0, i64 %idxprom3
56*9880d681SAndroid Build Coastguard Worker  store i32 333, i32* %arrayidx4, align 4, !tbaa !2
57*9880d681SAndroid Build Coastguard Worker  ret void
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Workerunreachable:                                      ; preds = %entry
60*9880d681SAndroid Build Coastguard Worker  unreachable
61*9880d681SAndroid Build Coastguard Worker}
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: global_array: # @global_array
64*9880d681SAndroid Build Coastguard Worker; CHECK: pushq %rbp
65*9880d681SAndroid Build Coastguard Worker; 	First array access
66*9880d681SAndroid Build Coastguard Worker; CHECK: movslq  %ecx, %[[idx:[^ ]*]]
67*9880d681SAndroid Build Coastguard Worker; CHECK: leaq    array(%rip), %[[base:[^ ]*]]
68*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $111, (%[[base]],%[[idx]],4)
69*9880d681SAndroid Build Coastguard Worker;	Might throw an exception and return to below...
70*9880d681SAndroid Build Coastguard Worker; CHECK: callq   _CxxThrowException
71*9880d681SAndroid Build Coastguard Worker; 	Third array access must remat the address of array
72*9880d681SAndroid Build Coastguard Worker; CHECK: movslq  {{.*}}, %[[idx:[^ ]*]]
73*9880d681SAndroid Build Coastguard Worker; CHECK: leaq    array(%rip), %[[base:[^ ]*]]
74*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $333, (%[[base]],%[[idx]],4)
75*9880d681SAndroid Build Coastguard Worker; CHECK: popq %rbp
76*9880d681SAndroid Build Coastguard Worker; CHECK: retq
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Worker; CHECK: "?catch$2@?0?global_array@4HA":
79*9880d681SAndroid Build Coastguard Worker; CHECK: pushq   %rbp
80*9880d681SAndroid Build Coastguard Worker; CHECK: movslq  {{.*}}, %[[idx:[^ ]*]]
81*9880d681SAndroid Build Coastguard Worker; CHECK: leaq    array(%rip), %[[base:[^ ]*]]
82*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $222, (%[[base]],%[[idx]],4)
83*9880d681SAndroid Build Coastguard Worker; CHECK: popq    %rbp
84*9880d681SAndroid Build Coastguard Worker; CHECK: retq                            # CATCHRET
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Workerdeclare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...)
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
91*9880d681SAndroid Build Coastguard Workerdefine void @access_imported() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
92*9880d681SAndroid Build Coastguard Workerentry:
93*9880d681SAndroid Build Coastguard Worker  store i32 111, i32* @imported, align 4, !tbaa !2
94*9880d681SAndroid Build Coastguard Worker  invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
95*9880d681SAndroid Build Coastguard Worker          to label %unreachable unwind label %catch.dispatch
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Workercatch.dispatch:                                   ; preds = %entry
98*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch] unwind to caller
99*9880d681SAndroid Build Coastguard Worker
100*9880d681SAndroid Build Coastguard Workercatch:                                            ; preds = %catch.dispatch
101*9880d681SAndroid Build Coastguard Worker  %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
102*9880d681SAndroid Build Coastguard Worker  store i32 222, i32* @imported, align 4, !tbaa !2
103*9880d681SAndroid Build Coastguard Worker  catchret from %0 to label %try.cont
104*9880d681SAndroid Build Coastguard Worker
105*9880d681SAndroid Build Coastguard Workertry.cont:                                         ; preds = %catch
106*9880d681SAndroid Build Coastguard Worker  store i32 333, i32* @imported, align 4, !tbaa !2
107*9880d681SAndroid Build Coastguard Worker  ret void
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Workerunreachable:                                      ; preds = %entry
110*9880d681SAndroid Build Coastguard Worker  unreachable
111*9880d681SAndroid Build Coastguard Worker}
112*9880d681SAndroid Build Coastguard Worker
113*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: access_imported: # @access_imported
114*9880d681SAndroid Build Coastguard Worker; CHECK: pushq %rbp
115*9880d681SAndroid Build Coastguard Worker; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]
116*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $111, (%[[base]])
117*9880d681SAndroid Build Coastguard Worker;	Might throw an exception and return to below...
118*9880d681SAndroid Build Coastguard Worker; CHECK: callq   _CxxThrowException
119*9880d681SAndroid Build Coastguard Worker; 	Third access must reload the address of imported
120*9880d681SAndroid Build Coastguard Worker; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]
121*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $333, (%[[base]])
122*9880d681SAndroid Build Coastguard Worker; CHECK: popq %rbp
123*9880d681SAndroid Build Coastguard Worker; CHECK: retq
124*9880d681SAndroid Build Coastguard Worker
125*9880d681SAndroid Build Coastguard Worker; CHECK: "?catch$2@?0?access_imported@4HA":
126*9880d681SAndroid Build Coastguard Worker; CHECK: pushq   %rbp
127*9880d681SAndroid Build Coastguard Worker; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]
128*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $222, (%[[base]])
129*9880d681SAndroid Build Coastguard Worker; CHECK: popq    %rbp
130*9880d681SAndroid Build Coastguard Worker; CHECK: retq                            # CATCHRET
131*9880d681SAndroid Build Coastguard Worker
132*9880d681SAndroid Build Coastguard Worker
133*9880d681SAndroid Build Coastguard Workerattributes #0 = { uwtable "disable-tail-calls"="false" "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" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
134*9880d681SAndroid Build Coastguard Workerattributes #1 = { noreturn }
135*9880d681SAndroid Build Coastguard Worker
136*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!0}
137*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!1}
138*9880d681SAndroid Build Coastguard Worker
139*9880d681SAndroid Build Coastguard Worker!0 = !{i32 1, !"PIC Level", i32 2}
140*9880d681SAndroid Build Coastguard Worker!1 = !{!"clang version 3.8.0 "}
141*9880d681SAndroid Build Coastguard Worker!2 = !{!3, !3, i64 0}
142*9880d681SAndroid Build Coastguard Worker!3 = !{!"int", !4, i64 0}
143*9880d681SAndroid Build Coastguard Worker!4 = !{!"omnipotent char", !5, i64 0}
144*9880d681SAndroid Build Coastguard Worker!5 = !{!"Simple C/C++ TBAA"}
145