Skip to content

Commit

Permalink
[SYCL][NewPM] Add SPIRITTAnnotations pass into optimization (#5300)
Browse files Browse the repository at this point in the history
Add SPIRITTAnnotations pass into clang optimizations pipeline when using
new Pass Manager.

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
  • Loading branch information
mlychkov committed Jan 22, 2022
1 parent 02b7301 commit 10c629a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,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());
}

Expand Down Expand Up @@ -1480,6 +1480,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) {
Expand Down
3 changes: 2 additions & 1 deletion clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 10c629a

Please sign in to comment.