Skip to content

Commit 10c629a

Browse files
authored
[SYCL][NewPM] Add SPIRITTAnnotations pass into optimization (#5300)
Add SPIRITTAnnotations pass into clang optimizations pipeline when using new Pass Manager. Signed-off-by: Mikhail Lychkov <[email protected]>
1 parent 02b7301 commit 10c629a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
10461046
// used only with spir triple.
10471047
if (CodeGenOpts.SPIRITTAnnotations) {
10481048
assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() &&
1049-
"ITT annotations can only by added to a module with spir target");
1049+
"ITT annotations can only be added to a module with spir target");
10501050
PerModulePasses.add(createSPIRITTAnnotationsLegacyPass());
10511051
}
10521052

@@ -1480,6 +1480,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
14801480
MPM.addPass(SYCLMutatePrintfAddrspacePass());
14811481
}
14821482

1483+
// Add SPIRITTAnnotations pass to the pass manager if
1484+
// -fsycl-instrument-device-code option was passed. This option can be used
1485+
// only with spir triple.
1486+
if (CodeGenOpts.SPIRITTAnnotations) {
1487+
assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() &&
1488+
"ITT annotations can only be added to a module with spir target");
1489+
MPM.addPass(SPIRITTAnnotationsPass());
1490+
}
1491+
14831492
// Allocate static local memory in SYCL kernel scope for each allocation
14841493
// call. It should be called after inlining pass.
14851494
if (LangOpts.SYCLIsDevice) {

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)