1
1
// RUN: %clang_cc1 -verify -fompss-2 -fexceptions -fcxx-exceptions -disable-llvm-passes -ferror-limit 100 %s -S -emit-llvm -o - | FileCheck %s
2
2
// expected-no-diagnostics
3
3
4
-
5
- // TODO: Fix this
6
4
void foo1 () {
7
5
#pragma oss task
8
6
{
9
7
throw 1 ;
10
8
}
11
9
}
12
10
13
- void foo1 () {
11
+ // CHECK: %0 = call token @llvm.directive.region.entry() [ "DIR.OSS"([5 x i8] c"TASK\00") ]
12
+ // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 4)
13
+ // CHECK-NEXT: %1 = bitcast i8* %exception to i32*
14
+ // CHECK-NEXT: store i32 1, i32* %1, align 16
15
+ // CHECK-NEXT: invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
16
+ // CHECK-NEXT: to label %invoke.cont unwind label %terminate.lpad
17
+ // CHECK: invoke.cont: ; preds = %entry
18
+ // CHECK-NEXT: br label %throw.cont
19
+ // CHECK: throw.cont: ; preds = %invoke.cont
20
+ // CHECK-NEXT: call void @llvm.directive.region.exit(token %0)
21
+ // CHECK-NEXT: ret void
22
+ // CHECK: terminate.lpad: ; preds = %entry
23
+ // CHECK-NEXT: %2 = landingpad { i8*, i32 }
24
+ // CHECK-NEXT: catch i8* null
25
+ // CHECK-NEXT: %3 = extractvalue { i8*, i32 } %2, 0
26
+ // CHECK-NEXT: call void @__clang_call_terminate(i8* %3) #4
27
+ // CHECK-NEXT: unreachable
28
+
29
+ void foo2 () {
14
30
#pragma oss task
15
31
{
16
32
try {
@@ -20,8 +36,10 @@ void foo1() {
20
36
}
21
37
#pragma oss task
22
38
{
39
+ int n;
23
40
try {
24
41
throw 1 ;
42
+ n++;
25
43
} catch (int e) {
26
44
}
27
45
}
@@ -30,15 +48,92 @@ void foo1() {
30
48
// Each task has its own exn.slot, ehselector.slot, and all it's exception
31
49
// handling BB
32
50
33
- // CHECK: %0 = call token @llvm.directive.region.entry() [ "DIR.OSS"([5 x i8] c"TASK\00") ]
34
- // CHECK-NEXT: %exn.slot = alloca i8*
35
- // CHECK-NEXT: %ehselector.slot = alloca i32
36
- // CHECK: try.cont: ; preds = %catch
37
- // CHECK: call void @llvm.directive.region.exit(token %0)
38
- // CHECK-NEXT: %9 = call token @llvm.directive.region.entry() [ "DIR.OSS"([5 x i8] c"TASK\00") ]
39
- // CHECK-NEXT: %exn.slot4 = alloca i8*
40
- // CHECK-NEXT: %ehselector.slot5 = alloca i32
41
- // CHECK: try.cont12: ; preds = %catch9
42
- // CHECK: call void @llvm.directive.region.exit(token %9)
43
- // CHECK-NEXT: ret void
51
+ // CHECK: %0 = call token @llvm.directive.region.entry() [ "DIR.OSS"([5 x i8] c"TASK\00") ]
52
+ // CHECK-NEXT: %exn.slot = alloca i8*
53
+ // CHECK-NEXT: %ehselector.slot = alloca i32
54
+ // CHECK-NEXT: %e = alloca i32, align 4
55
+ // CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 4) #1
56
+ // CHECK-NEXT: %1 = bitcast i8* %exception to i32*
57
+ // CHECK-NEXT: store i32 1, i32* %1, align 16
58
+ // CHECK-NEXT: invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
59
+ // CHECK-NEXT: to label %invoke.cont unwind label %lpad
60
+ // CHECK: invoke.cont: ; preds = %entry
61
+ // CHECK-NEXT: br label %throw.cont
62
+ // CHECK: throw.cont: ; preds = %invoke.cont
63
+ // CHECK-NEXT: br label %try.cont
64
+ // CHECK: lpad: ; preds = %entry
65
+ // CHECK-NEXT: %2 = landingpad { i8*, i32 }
66
+ // CHECK-NEXT: catch i8* bitcast (i8** @_ZTIi to i8*)
67
+ // CHECK-NEXT: catch i8* null
68
+ // CHECK-NEXT: %3 = extractvalue { i8*, i32 } %2, 0
69
+ // CHECK-NEXT: store i8* %3, i8** %exn.slot, align 8
70
+ // CHECK-NEXT: %4 = extractvalue { i8*, i32 } %2, 1
71
+ // CHECK-NEXT: store i32 %4, i32* %ehselector.slot, align 4
72
+ // CHECK-NEXT: br label %catch.dispatch
73
+ // CHECK: catch.dispatch: ; preds = %lpad
74
+ // CHECK-NEXT: %sel = load i32, i32* %ehselector.slot, align 4
75
+ // CHECK-NEXT: %5 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #1
76
+ // CHECK-NEXT: %matches = icmp eq i32 %sel, %5
77
+ // CHECK-NEXT: br i1 %matches, label %catch, label %terminate.handler
78
+ // CHECK: catch: ; preds = %catch.dispatch
79
+ // CHECK-NEXT: %exn = load i8*, i8** %exn.slot, align 8
80
+ // CHECK-NEXT: %6 = call i8* @__cxa_begin_catch(i8* %exn) #1
81
+ // CHECK-NEXT: %7 = bitcast i8* %6 to i32*
82
+ // CHECK-NEXT: %8 = load i32, i32* %7, align 4
83
+ // CHECK-NEXT: store i32 %8, i32* %e, align 4
84
+ // CHECK-NEXT: call void @__cxa_end_catch() #1
85
+ // CHECK-NEXT: br label %try.cont
86
+ // CHECK: try.cont: ; preds = %catch, %throw.cont
87
+ // CHECK-NEXT: call void @llvm.directive.region.exit(token %0)
88
+
89
+ // CHECK: %9 = call token @llvm.directive.region.entry() [ "DIR.OSS"([5 x i8] c"TASK\00") ]
90
+ // CHECK-NEXT: %n = alloca i32, align 4
91
+ // CHECK-NEXT: %exn.slot4 = alloca i8*
92
+ // CHECK-NEXT: %ehselector.slot5 = alloca i32
93
+ // CHECK-NEXT: %e12 = alloca i32, align 4
94
+ // CHECK-NEXT: %exception2 = call i8* @__cxa_allocate_exception(i64 4) #1
95
+ // CHECK-NEXT: %10 = bitcast i8* %exception2 to i32*
96
+ // CHECK-NEXT: store i32 1, i32* %10, align 16
97
+ // CHECK-NEXT: invoke void @__cxa_throw(i8* %exception2, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
98
+ // CHECK-NEXT: to label %invoke.cont6 unwind label %lpad3
99
+ // CHECK: invoke.cont6: ; preds = %try.cont
100
+ // CHECK-NEXT: br label %throw.cont7
101
+ // CHECK: throw.cont7: ; preds = %invoke.cont6
102
+ // CHECK-NEXT: %11 = load i32, i32* %n, align 4
103
+ // CHECK-NEXT: %inc = add nsw i32 %11, 1
104
+ // CHECK-NEXT: store i32 %inc, i32* %n, align 4
105
+ // CHECK-NEXT: br label %try.cont14
106
+ // CHECK: terminate.handler: ; preds = %catch.dispatch
107
+ // CHECK-NEXT: %exn1 = load i8*, i8** %exn.slot, align 8
108
+ // CHECK-NEXT: call void @__clang_call_terminate(i8* %exn1) #4
109
+ // CHECK-NEXT: unreachable
110
+ // CHECK: lpad3: ; preds = %try.cont
111
+ // CHECK-NEXT: %12 = landingpad { i8*, i32 }
112
+ // CHECK-NEXT: catch i8* bitcast (i8** @_ZTIi to i8*)
113
+ // CHECK-NEXT: catch i8* null
114
+ // CHECK-NEXT: %13 = extractvalue { i8*, i32 } %12, 0
115
+ // CHECK-NEXT: store i8* %13, i8** %exn.slot4, align 8
116
+ // CHECK-NEXT: %14 = extractvalue { i8*, i32 } %12, 1
117
+ // CHECK-NEXT: store i32 %14, i32* %ehselector.slot5, align 4
118
+ // CHECK-NEXT: br label %catch.dispatch8
119
+ // CHECK: catch.dispatch8: ; preds = %lpad3
120
+ // CHECK-NEXT: %sel9 = load i32, i32* %ehselector.slot5, align 4
121
+ // CHECK-NEXT: %15 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #1
122
+ // CHECK-NEXT: %matches10 = icmp eq i32 %sel9, %15
123
+ // CHECK-NEXT: br i1 %matches10, label %catch11, label %terminate.handler16
124
+ // CHECK: catch11: ; preds = %catch.dispatch8
125
+ // CHECK-NEXT: %exn13 = load i8*, i8** %exn.slot4, align 8
126
+ // CHECK-NEXT: %16 = call i8* @__cxa_begin_catch(i8* %exn13) #1
127
+ // CHECK-NEXT: %17 = bitcast i8* %16 to i32*
128
+ // CHECK-NEXT: %18 = load i32, i32* %17, align 4
129
+ // CHECK-NEXT: store i32 %18, i32* %e12, align 4
130
+ // CHECK-NEXT: call void @__cxa_end_catch() #1
131
+ // CHECK-NEXT: br label %try.cont14
132
+ // CHECK: try.cont14: ; preds = %catch11, %throw.cont7
133
+ // CHECK-NEXT: call void @llvm.directive.region.exit(token %9)
134
+ // CHECK-NEXT: ret void
135
+ // CHECK: terminate.handler16: ; preds = %catch.dispatch8
136
+ // CHECK-NEXT: %exn15 = load i8*, i8** %exn.slot4, align 8
137
+ // CHECK-NEXT: call void @__clang_call_terminate(i8* %exn15) #4
138
+ // CHECK-NEXT: unreachable
44
139
0 commit comments