Skip to content

Commit 2b4c247

Browse files
committed
[Clang] Link ITT libraries in device code by default
1 parent 853917d commit 2b4c247

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,11 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
650650
addLibraries(SYCLDeviceBfloat16FallbackLib);
651651
}
652652

653+
// Link in ITT annotations library unless fsycl-no-instrument-device-code
654+
// is specified. This ensures that we are ABI-compatible with the
655+
// instrumented device code, which was the default not so long ago.
653656
if (Args.hasFlag(options::OPT_fsycl_instrument_device_code,
654-
options::OPT_fno_sycl_instrument_device_code, false))
657+
options::OPT_fno_sycl_instrument_device_code, true))
655658
addLibraries(SYCLDeviceAnnotationLibs);
656659

657660
#if !defined(_WIN32)

clang/test/Driver/sycl-instrumentation-old-model.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@
2020
// CHECK-SPIRV-SAME: "{{.*}}libsycl-itt-stubs.bc"
2121
// CHECK-HOST-NOT: "-cc1"{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-instrument-device-code"
2222

23-
// ITT annotations in device code are disabled by default.
23+
// ITT annotations in device code are disabled by default. However, for SYCL offloading,
24+
// we still link ITT annotations libraries to ensure ABI compatibility with previous release.
2425
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=spir64 -### %s 2>&1 \
25-
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
26+
// RUN: | FileCheck -check-prefixes=CHECK-ITT-LINK-ONLY %s
2627
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -### %s 2>&1 \
2728
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
2829

30+
// CHECK-ITT-LINK-ONLY-NOT: "-fsycl-instrument-device-code"
31+
// CHECK-ITT-LINK-ONLY: llvm-link{{.*}} {{.*}}libsycl-itt-{{.*}}
32+
2933
// RUN: %clangxx -fsycl --no-offload-new-driver -fno-sycl-instrument-device-code -fsycl-targets=spir64 -### %s 2>&1 \
3034
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
3135
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-instrument-device-code -nocudalib -### %s 2>&1 \

clang/test/Driver/sycl-instrumentation.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
// CHECK-SPIRV-SAME: libsycl-itt-compiler-wrappers.new.o
2020
// CHECK-SPIRV-SAME: libsycl-itt-stubs.new.o
2121

22-
// ITT annotations in device code are disabled by default.
22+
// ITT annotations in device code are disabled by default. However, for SYCL offloading,
23+
// we still link ITT annotations libraries to ensure ABI compatibility with previous release.
2324
// RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=spir64 -### %s 2>&1 \
24-
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
25+
// RUN: | FileCheck -check-prefixes=CHECK-ITT-LINK-ONLY %s
2526
// RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -### %s 2>&1 \
2627
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
2728

29+
// CHECK-ITT-LINK-ONLY-NOT: "-fsycl-instrument-device-code"
30+
// CHECK-ITT-LINK-ONLY: clang-linker-wrapper{{.*}} {{.*}}libsycl-itt-{{.*}}
31+
2832
// RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-instrument-device-code -fsycl-targets=spir64 -### %s 2>&1 \
2933
// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s
3034
// RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-instrument-device-code -nocudalib -### %s 2>&1 \

clang/test/Driver/sycl-offload-new-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
3535
// RUN: --sysroot=%S/Inputs/SYCL -### %s 2>&1 \
3636
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS %s
37-
// WRAPPER_OPTIONS: clang-linker-wrapper{{.*}} "-sycl-device-libraries=libsycl-crt.new.o,libsycl-complex.new.o,libsycl-complex-fp64.new.o,libsycl-cmath.new.o,libsycl-cmath-fp64.new.o,libsycl-imf.new.o,libsycl-imf-fp64.new.o,libsycl-imf-bf16.new.o,libsycl-fallback-cassert.new.o,libsycl-fallback-cstring.new.o,libsycl-fallback-complex.new.o,libsycl-fallback-complex-fp64.new.o,libsycl-fallback-cmath.new.o,libsycl-fallback-cmath-fp64.new.o,libsycl-fallback-imf.new.o,libsycl-fallback-imf-fp64.new.o,libsycl-fallback-imf-bf16.new.o"
37+
// WRAPPER_OPTIONS: clang-linker-wrapper{{.*}} "-sycl-device-libraries=libsycl-crt.new.o,libsycl-complex.new.o,libsycl-complex-fp64.new.o,libsycl-cmath.new.o,libsycl-cmath-fp64.new.o,libsycl-imf.new.o,libsycl-imf-fp64.new.o,libsycl-imf-bf16.new.o,libsycl-fallback-cassert.new.o,libsycl-fallback-cstring.new.o,libsycl-fallback-complex.new.o,libsycl-fallback-complex-fp64.new.o,libsycl-fallback-cmath.new.o,libsycl-fallback-cmath-fp64.new.o,libsycl-fallback-imf.new.o,libsycl-fallback-imf-fp64.new.o,libsycl-fallback-imf-bf16.new.o,libsycl-itt-user-wrappers.new.o,libsycl-itt-compiler-wrappers.new.o,libsycl-itt-stubs.new.o"
3838
// WRAPPER_OPTIONS-SAME: "-sycl-device-library-location={{.*}}/lib"
3939

4040
/// Verify phases used to generate SPIR-V instead of LLVM-IR

0 commit comments

Comments
 (0)