Skip to content

Commit fd355c7

Browse files
authored
[SYCL] Move ITT annotation option check to clang options parser (#5315)
Signed-off-by: Mikhail Lychkov <[email protected]>
1 parent 20f3068 commit fd355c7

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,8 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
10441044
// -fsycl-instrument-device-code option was passed. This option can be
10451045
// used only with spir triple.
10461046
if (CodeGenOpts.SPIRITTAnnotations) {
1047-
if (!llvm::Triple(TheModule->getTargetTriple()).isSPIR())
1048-
llvm::report_fatal_error(
1049-
"ITT annotations can only by added to a module with spir target");
1047+
assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() &&
1048+
"ITT annotations can only by added to a module with spir target");
10501049
PerModulePasses.add(createSPIRITTAnnotationsLegacyPass());
10511050
}
10521051

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,13 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
19001900
Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
19011901
}
19021902

1903+
if (Arg *A = Args.getLastArg(OPT_fsycl_instrument_device_code)) {
1904+
if (!T.isSPIR())
1905+
Diags.Report(diag::err_drv_unsupported_opt_for_target)
1906+
<< A->getSpelling() << T.str();
1907+
Opts.SPIRITTAnnotations = true;
1908+
}
1909+
19031910
bool NeedLocTracking = false;
19041911

19051912
if (!Opts.OptRecordFile.empty())
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// Check if -fsycl-instrument-device-code is allowed only for spir target
2+
3+
// RUN: %clang_cc1 -fsycl-instrument-device-code -triple spir-unknown-unknown %s -emit-llvm -o - 2>&1 | FileCheck %s
4+
// RUN: %clang_cc1 -fsycl-instrument-device-code -triple spir64-unknown-unknown %s -emit-llvm -o - 2>&1 | FileCheck %s
5+
// RUN: %clang_cc1 -fsycl-instrument-device-code -triple spir64_gen-unknown-unknown %s -emit-llvm -o - 2>&1 | FileCheck %s
6+
// RUN: %clang_cc1 -fsycl-instrument-device-code -triple spir64_fpga-unknown-unknown %s -emit-llvm -o - 2>&1 | FileCheck %s
7+
// RUN: %clang_cc1 -fsycl-instrument-device-code -triple spir64_x86_64-unknown-unknown %s -emit-llvm -o - 2>&1 | FileCheck %s
8+
// CHECK-NOT: error
9+
10+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple spirv32 -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
11+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple spirv64 -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
12+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple x86_64-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
13+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple i386-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
14+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple xcore-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
15+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple powerpc64-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
16+
// RUN: not %clang_cc1 -fsycl-instrument-device-code -triple armv7-unknown-unknown -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ERR
17+
// CHECK-ERR: error: unsupported option '-fsycl-instrument-device-code' for target

0 commit comments

Comments
 (0)