diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index d3e0317203548..44218220529ef 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1045,7 +1045,7 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager( // used only with spir triple. if (CodeGenOpts.SPIRITTAnnotations) { assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() && - "ITT annotations can only by added to a module with spir target"); + "ITT annotations can only be added to a module with spir target"); PerModulePasses.add(createSPIRITTAnnotationsLegacyPass()); } @@ -1479,6 +1479,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline( MPM.addPass(SYCLMutatePrintfAddrspacePass()); } + // Add SPIRITTAnnotations pass to the pass manager if + // -fsycl-instrument-device-code option was passed. This option can be used + // only with spir triple. + if (CodeGenOpts.SPIRITTAnnotations) { + assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() && + "ITT annotations can only be added to a module with spir target"); + MPM.addPass(SPIRITTAnnotationsPass()); + } + // Allocate static local memory in SYCL kernel scope for each allocation // call. It should be called after inlining pass. if (LangOpts.SYCLIsDevice) { diff --git a/clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp b/clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp index 72c744601fcfd..6a6168735dce0 100644 --- a/clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp +++ b/clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp @@ -1,7 +1,8 @@ /// Check if start/finish ITT annotations are being added during compilation of /// SYCL device code -// RUN: %clang_cc1 -fsycl-is-device -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fsycl-is-device -flegacy-pass-manager -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fsycl-is-device -fno-legacy-pass-manager -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s // CHECK: kernel_function // CHECK-NEXT: entry: