Skip to content

Commit d23adc8

Browse files
author
Artem Gindinson
committed
[SYCL] Unconditionally enable SPIR ITT annotations
Instead of maintaining a (malfunctioning) driver option, unconditionally pass the CC1 option `-fsycl-instrument-device-code` for SPIR-V-based targets. Signed-off-by: Artem Gindinson <[email protected]>
1 parent 1b47b92 commit d23adc8

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ CODEGENOPT(PassByValueIsNoAlias, 1, 0)
435435
CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
436436

437437
// Whether to instrument SPIR device code with ITT annotations
438-
CODEGENOPT(SPIRITTAnnotations, 1, 0)
438+
CODEGENOPT(SPIRITTAnnotations, 1, 1)
439439

440440
/// Sets the IEEE bit in the expected default floating point mode register.
441441
/// Floating point opcodes that support exception flag gathering quiet and

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,6 +4660,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46604660
CmdArgs.push_back("-fsycl-allow-func-ptr");
46614661
}
46624662

4663+
if (Triple.isSPIR())
4664+
CmdArgs.push_back("-fsycl-instrument-device-code");
4665+
46634666
if (!SYCLStdArg) {
46644667
// The user had not pass SYCL version, thus we'll employ no-sycl-strict
46654668
// to allow address-space unqualified pointers in function params/return
@@ -6404,15 +6407,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
64046407
// Forward -cl options to -cc1
64056408
RenderOpenCLOptions(Args, CmdArgs, InputType);
64066409

6407-
// Forward -fsycl-instrument-device-code option to cc1. This option can only
6408-
// be used with spir triple.
6409-
if (Arg *A = Args.getLastArg(options::OPT_fsycl_instrument_device_code)) {
6410-
if (!Triple.isSPIR())
6411-
D.Diag(diag::err_drv_unsupported_opt_for_target)
6412-
<< A->getAsString(Args) << TripleStr;
6413-
CmdArgs.push_back("-fsycl-instrument-device-code");
6414-
}
6415-
64166410
if (IsHIP) {
64176411
if (Args.hasFlag(options::OPT_fhip_new_launch_api,
64186412
options::OPT_fno_hip_new_launch_api, true))
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
/// Check that SPIR ITT instrumentation is disabled by default:
2-
// RUN: %clang -### %s 2>&1 \
3-
// RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s
4-
// CHECK-DEFAULT-NOT: "-fsycl-instrument-device-code"
5-
6-
/// Check if "fsycl_instrument_device_code" is passed to -cc1:
7-
// RUN: %clang -### -fsycl-instrument-device-code %s 2>&1 \
8-
// RUN: | FileCheck -check-prefix=CHECK-ENABLED %s
9-
// CHECK-ENABLED: "-cc1"{{.*}} "-fsycl-instrument-device-code"
10-
11-
/// Check if "fsycl_instrument_device_code" usage with a non-spirv target
12-
/// results in an error.
13-
// RUN: %clang -### -fsycl-instrument-device-code --target=x86 %s 2>&1
14-
// expected-error{{unsupported option '-fsycl-instrument-device-code' for target 'x86_64-unknown-linux-gnu'}}
1+
/// Check if -fsycl-instrument-device-code is passed to device-side -cc1:
2+
// RUN: %clangxx -fsycl -fsycl-targets=spir64 -### %s 2>&1 \
3+
// RUN: | FileCheck -check-prefixes=CHECK-SPIRV,CHECK-HOST %s
4+
// RUN: %clangxx -fsycl -fsycl-targets=nvptx-nvidia-cuda -### %s 2>&1 \
5+
// RUN: | FileCheck -check-prefix=CHECK-NONSPIRV %s
6+
// CHECK-SPIRV: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-instrument-device-code"
7+
// CHECK-HOST-NOT: "-cc1"{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-instrument-device-code"
8+
// CHECK-NONSPIRV-NOT: "-fsycl-instrument-device-code"

0 commit comments

Comments
 (0)