Skip to content

Commit 71952df

Browse files
authored
[OpenMP][SPIRV] Disable exceptions for OpenMP SPIR-V (llvm#169094)
More missed target checks. Signed-off-by: Nick Sarnie <[email protected]>
1 parent ad0acf4 commit 71952df

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

clang/lib/CodeGen/CGException.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E,
450450
// Therefore, we emit a trap which will abort the program, and
451451
// prompt a warning indicating that a trap will be emitted.
452452
const llvm::Triple &T = Target.getTriple();
453-
if (CGM.getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN())) {
453+
if (CGM.getLangOpts().OpenMPIsTargetDevice && T.isGPU()) {
454454
EmitTrapCall(llvm::Intrinsic::trap);
455455
return;
456456
}
@@ -627,7 +627,7 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
627627
// If we encounter a try statement on in an OpenMP target region offloaded to
628628
// a GPU, we treat it as a basic block.
629629
const bool IsTargetDevice =
630-
(CGM.getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN()));
630+
(CGM.getLangOpts().OpenMPIsTargetDevice && T.isGPU());
631631
if (!IsTargetDevice)
632632
EnterCXXTryStmt(S);
633633
EmitStmt(S.getTryBlock());

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,8 +4293,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
42934293

42944294
// Set the flag to prevent the implementation from emitting device exception
42954295
// handling code for those requiring so.
4296-
if ((Opts.OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN())) ||
4297-
Opts.OpenCLCPlusPlus) {
4296+
if ((Opts.OpenMPIsTargetDevice && T.isGPU()) || Opts.OpenCLCPlusPlus) {
42984297

42994298
Opts.Exceptions = 0;
43004299
Opts.CXXExceptions = 0;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -Wno-openmp-target-exception -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=spirv64-intel -emit-llvm-bc %s -o %t-host.bc
2+
// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -Wno-openmp-target-exception -fopenmp -x c++ -triple spirv64-intel -fopenmp-targets=spirv64-intel -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-host.bc -o - | \
3+
// RUN: FileCheck -implicit-check-not='{{invoke|throw|cxa}}' %s
4+
void foo() {
5+
// CHECK: call addrspace(9) void @llvm.trap()
6+
// CHECK-NEXT: call spir_func addrspace(9) void @__kmpc_target_deinit()
7+
#pragma omp target
8+
throw "bad";
9+
}

0 commit comments

Comments
 (0)