[PATCH] D142033: [OpenCL] Always add nounwind attribute for OpenCL
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 08:51:29 PST 2023
svenvh created this revision.
svenvh added reviewers: Anastasia, yaxunl, bader.
Herald added subscribers: kosarev, Naghasan, ldrumm, kerbowa, jvesely.
Herald added a project: All.
svenvh requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Neither OpenCL nor C++ for OpenCL support exceptions, so add the
`nounwind` attribute unconditionally for those languages.
Unblocks D138958 <https://reviews.llvm.org/D138958>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142033
Files:
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
clang/test/CodeGenOpenCL/convergent.cl
Index: clang/test/CodeGenOpenCL/convergent.cl
===================================================================
--- clang/test/CodeGenOpenCL/convergent.cl
+++ clang/test/CodeGenOpenCL/convergent.cl
@@ -139,4 +139,5 @@
// CHECK: attributes #3 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
// CHECK: attributes #4 = { {{[^}]*}}convergent{{[^}]*}} }
// CHECK: attributes #5 = { {{[^}]*}}convergent{{[^}]*}} }
-// CHECK: attributes #6 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
+// CHECK: attributes #6 = { {{[^}]*}}nounwind{{[^}]*}} }
+// CHECK: attributes #7 = { {{[^}]*}}convergent noduplicate nounwind{{[^}]*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
===================================================================
--- clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
+++ clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
@@ -298,7 +298,7 @@
// CHECK: attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
// CHECK: attributes #3 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
// CHECK: attributes #4 = { nounwind "enqueued-block" }
-// CHECK: attributes #5 = { convergent }
+// CHECK: attributes #5 = { convergent nounwind }
//.
// CHECK: !0 = !{i32 1, !"amdgpu_code_object_version", i32 400}
// CHECK: !1 = !{i32 1, !"wchar_size", i32 4}
Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1969,11 +1969,11 @@
FuncAttrs.addAttribute(llvm::Attribute::Convergent);
}
- // TODO: NoUnwind attribute should be added for other GPU modes OpenCL, HIP,
+ // TODO: NoUnwind attribute should be added for other GPU modes HIP,
// SYCL, OpenMP offload. AFAIK, none of them support exceptions in device
// code.
- if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
- // Exceptions aren't supported in CUDA device code.
+ if ((getLangOpts().CUDA && getLangOpts().CUDAIsDevice) ||
+ getLangOpts().OpenCL) {
FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142033.490190.patch
Type: text/x-patch
Size: 2280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230118/63bf9c6f/attachment.bin>
More information about the cfe-commits
mailing list