File tree 3 files changed +38
-3
lines changed
3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -1591,6 +1591,16 @@ static void getTrivialDefaultFunctionAttributes(
1591
1591
auto convgt = mlir::cir::ConvergentAttr::get (CGM.getBuilder ().getContext ());
1592
1592
funcAttrs.set (convgt.getMnemonic (), convgt);
1593
1593
}
1594
+
1595
+ // TODO: NoThrow attribute should be added for other GPU modes CUDA, SYCL,
1596
+ // HIP, OpenMP offload.
1597
+ // AFAIK, neither of them support exceptions in device code.
1598
+ if ((langOpts.CUDA && langOpts.CUDAIsDevice ) || langOpts.SYCLIsDevice )
1599
+ llvm_unreachable (" NYI" );
1600
+ if (langOpts.OpenCL ) {
1601
+ auto noThrow = mlir::cir::NoThrowAttr::get (CGM.getBuilder ().getContext ());
1602
+ funcAttrs.set (noThrow.getMnemonic (), noThrow);
1603
+ }
1594
1604
}
1595
1605
1596
1606
void CIRGenModule::getTrivialDefaultFunctionAttributes (
Original file line number Diff line number Diff line change 8
8
9
9
// CIR: #fn_attr[[CONV_NOINLINE_ATTR:[0-9]*]] = #cir<extra({convergent = #cir.convergent, inline = #cir.inline<no>
10
10
// CIR-NEXT: #fn_attr[[CONV_DECL_ATTR:[0-9]*]] = #cir<extra({convergent = #cir.convergent
11
- // CIR-NEXT: #fn_attr[[CONV_NOTHROW_ATTR:[0-9]*]] = #cir<extra({convergent = #cir.convergent, nothrow = #cir.nothrow
12
11
13
12
__attribute__((noinline ))
14
13
void non_convfun (void ) {
@@ -37,7 +36,7 @@ void test_merge_if(int a) {
37
36
g ();
38
37
}
39
38
}
40
- // CIR: cir.func @test_merge_if{{.*}} extra(#fn_attr[[CONV_NOTHROW_ATTR ]])
39
+ // CIR: cir.func @test_merge_if{{.*}} extra(#fn_attr[[CONV_DECL_ATTR ]])
41
40
42
41
// The LLVM IR below is equivalent to:
43
42
// if (a) {
@@ -81,7 +80,7 @@ void test_no_merge_if(int a) {
81
80
g ();
82
81
}
83
82
}
84
- // CIR: cir.func @test_no_merge_if{{.*}} extra(#fn_attr[[CONV_NOTHROW_ATTR ]])
83
+ // CIR: cir.func @test_no_merge_if{{.*}} extra(#fn_attr[[CONV_DECL_ATTR ]])
85
84
86
85
// LLVM-LABEL: define{{.*}} spir_func void @test_no_merge_if
87
86
// LLVM: %[[tobool:.+]] = icmp eq i32 %[[ARG:.+]], 0
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -fclangir -triple=spirv64-unknown-unknown -emit-cir -o %t.cir %s
2
+ // RUN: FileCheck %s -input-file=%t.cir -check-prefixes CIR
3
+ // RUN: %clang_cc1 -fclangir -triple=spirv64-unknown-unknown -emit-llvm -o %t.ll %s
4
+ // RUN: FileCheck %s -input-file=%t.ll -check-prefixes LLVM
5
+
6
+ // CIR-LABEL: #fn_attr =
7
+ // CIR: cl.kernel = #cir.cl.kernel
8
+ // CIR: nothrow = #cir.nothrow
9
+
10
+ // CIR-LABEL: #fn_attr1 =
11
+ // CIR-NOT: cl.kernel = #cir.cl.kernel
12
+ // CIR: nothrow = #cir.nothrow
13
+
14
+ kernel void ker () {};
15
+ // CIR: cir.func @ker{{.*}} extra(#fn_attr) {
16
+ // LLVM: define{{.*}}@ker(){{.*}} #0
17
+
18
+ void foo () {};
19
+ // CIR: cir.func @foo{{.*}} extra(#fn_attr1) {
20
+ // LLVM: define{{.*}}@foo(){{.*}} #1
21
+
22
+ // LLVM-LABEL: attributes #0
23
+ // LLVM: nounwind
24
+
25
+ // LLVM-LABEL: attributes #1
26
+ // LLVM: nounwind
You can’t perform that action at this time.
0 commit comments