diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 1d903aa1fc17c..6831938fd4c6d 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -650,8 +650,11 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple, addLibraries(SYCLDeviceBfloat16FallbackLib); } + // Link in ITT annotations library unless fsycl-no-instrument-device-code + // is specified. This ensures that we are ABI-compatible with the + // instrumented device code, which was the default not so long ago. if (Args.hasFlag(options::OPT_fsycl_instrument_device_code, - options::OPT_fno_sycl_instrument_device_code, false)) + options::OPT_fno_sycl_instrument_device_code, true)) addLibraries(SYCLDeviceAnnotationLibs); #if !defined(_WIN32) diff --git a/clang/test/Driver/sycl-instrumentation-old-model.c b/clang/test/Driver/sycl-instrumentation-old-model.c index 3e07d6d1ca298..bf1471fad84ef 100644 --- a/clang/test/Driver/sycl-instrumentation-old-model.c +++ b/clang/test/Driver/sycl-instrumentation-old-model.c @@ -20,12 +20,16 @@ // CHECK-SPIRV-SAME: "{{.*}}libsycl-itt-stubs.bc" // CHECK-HOST-NOT: "-cc1"{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-instrument-device-code" -// ITT annotations in device code are disabled by default. +// ITT annotations in device code are disabled by default. However, for SYCL offloading, +// we still link ITT annotations libraries to ensure ABI compatibility with previous release. // RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=spir64 -### %s 2>&1 \ -// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s +// RUN: | FileCheck -check-prefixes=CHECK-ITT-LINK-ONLY %s // RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s +// CHECK-ITT-LINK-ONLY-NOT: "-fsycl-instrument-device-code" +// CHECK-ITT-LINK-ONLY: llvm-link{{.*}} {{.*}}libsycl-itt-{{.*}} + // RUN: %clangxx -fsycl --no-offload-new-driver -fno-sycl-instrument-device-code -fsycl-targets=spir64 -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s // RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-instrument-device-code -nocudalib -### %s 2>&1 \ diff --git a/clang/test/Driver/sycl-instrumentation.c b/clang/test/Driver/sycl-instrumentation.c index ccb3d857d46af..c2dbf8b6b83f7 100644 --- a/clang/test/Driver/sycl-instrumentation.c +++ b/clang/test/Driver/sycl-instrumentation.c @@ -19,12 +19,16 @@ // CHECK-SPIRV-SAME: libsycl-itt-compiler-wrappers.new.o // CHECK-SPIRV-SAME: libsycl-itt-stubs.new.o -// ITT annotations in device code are disabled by default. +// ITT annotations in device code are disabled by default. However, for SYCL offloading, +// we still link ITT annotations libraries to ensure ABI compatibility with previous release. // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=spir64 -### %s 2>&1 \ -// RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s +// RUN: | FileCheck -check-prefixes=CHECK-ITT-LINK-ONLY %s // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s +// CHECK-ITT-LINK-ONLY-NOT: "-fsycl-instrument-device-code" +// CHECK-ITT-LINK-ONLY: clang-linker-wrapper{{.*}} {{.*}}libsycl-itt-{{.*}} + // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-instrument-device-code -fsycl-targets=spir64 -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-NONPASSED %s // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-instrument-device-code -nocudalib -### %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-new-driver.c b/clang/test/Driver/sycl-offload-new-driver.c index b6732b3e9312e..dd656192b80f3 100644 --- a/clang/test/Driver/sycl-offload-new-driver.c +++ b/clang/test/Driver/sycl-offload-new-driver.c @@ -34,7 +34,7 @@ // RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \ // RUN: --sysroot=%S/Inputs/SYCL -### %s 2>&1 \ // RUN: | FileCheck -check-prefix WRAPPER_OPTIONS %s -// 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" +// 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" // WRAPPER_OPTIONS-SAME: "-sycl-device-library-location={{.*}}/lib" /// Verify phases used to generate SPIR-V instead of LLVM-IR