Skip to content

Commit ce9b724

Browse files
committed
[SYCL][NewPM] Add SPIRITTAnnotations pass into optimization
Add SPIRITTAnnotations pass into clang optimizations pipeline when using new Pass Manager. Signed-off-by: Mikhail Lychkov <[email protected]>
1 parent c18f43c commit ce9b724

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,16 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
14811481
MPM.addPass(SYCLMutatePrintfAddrspacePass());
14821482
}
14831483

1484+
// Add SPIRITTAnnotations pass to the pass manager if
1485+
// -fsycl-instrument-device-code option was passed. This option can be used
1486+
// only with spir triple.
1487+
if (CodeGenOpts.SPIRITTAnnotations) {
1488+
if (!llvm::Triple(TheModule->getTargetTriple()).isSPIR())
1489+
llvm::report_fatal_error(
1490+
"ITT annotations can only by added to a module with spir target");
1491+
MPM.addPass(SPIRITTAnnotationsPass());
1492+
}
1493+
14841494
// Add a verifier pass if requested. We don't have to do this if the action
14851495
// requires code generation because there will already be a verifier pass in
14861496
// the code-generation pipeline.

clang/test/CodeGenSYCL/kernel-simple-instrumentation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// Check if start/finish ITT annotations are being added during compilation of
22
/// SYCL device code
33

4-
// RUN: %clang_cc1 -fsycl-is-device -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
4+
// RUN: %clang_cc1 -fsycl-is-device -flegacy-pass-manager -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
5+
// RUN: %clang_cc1 -fsycl-is-device -fno-legacy-pass-manager -fsycl-instrument-device-code -triple spir64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
56

67
// CHECK: kernel_function
78
// CHECK-NEXT: entry:

0 commit comments

Comments
 (0)