Skip to content

Commit c1b6835

Browse files
Pavel Chupinaelovikov-intel
andauthored
[SYCL][PM] Fix DeadArgumentEliminationSYCLPass with new pass manager (#6074)
* [SYCL][PM] Fix DeadArgumentEliminationSYCLPass with new pass manager * Add it properly to the PM, implementing in clang. It might be not the most "correct" way but it is consistent with other similar passes' location and any cleanups should be done all at once, not creating divergence between different passes. * Add test to check pass run in optimized compilations * Fix documentation, it's enabled by default long time ago Co-authored-by: Andrei Elovikov <andrei.elovikov@intel.com>
1 parent d673f03 commit c1b6835

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "llvm/Transforms/Coroutines/CoroSplit.h"
6363
#include "llvm/Transforms/IPO.h"
6464
#include "llvm/Transforms/IPO/AlwaysInliner.h"
65+
#include "llvm/Transforms/IPO/DeadArgumentElimination.h"
6566
#include "llvm/Transforms/IPO/LowerTypeTests.h"
6667
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
6768
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
@@ -1490,6 +1491,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
14901491
}
14911492
if (LangOpts.SYCLIsDevice) {
14921493
MPM.addPass(SYCLMutatePrintfAddrspacePass());
1494+
if (!CodeGenOpts.DisableLLVMPasses && LangOpts.EnableDAEInSpirKernels)
1495+
MPM.addPass(DeadArgumentEliminationSYCLPass());
14931496
}
14941497

14951498
// Add SPIRITTAnnotations pass to the pass manager if
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -fno-legacy-pass-manager -fdebug-pass-manager -fenable-sycl-dae -o /dev/null -x c++ < %s 2>&1 | FileCheck %s
2+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O0 -fno-legacy-pass-manager -fdebug-pass-manager -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
3+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -fno-legacy-pass-manager -fdebug-pass-manager -fenable-sycl-dae -disable-llvm-passes -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
4+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -fenable-sycl-dae -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix OLDPM
5+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
6+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -fenable-sycl-dae -disable-llvm-passes -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
7+
8+
// Verify that Dead Arguments Elimination for SYCL kernels is/is not added to the PM.
9+
10+
// CHECK: Running pass: DeadArgumentEliminationSYCLPass on [module]
11+
// OLDPM: Dead Argument Elimination for SYCL kernels
12+
// DISABLE-NOT: DeadArgumentEliminationSYCLPass
13+
// DISABLE-NOT: Dead Argument Elimination for SYCL kernels

sycl/doc/UsersManual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ and not recommended to use in production environment.
7070
Enables (or disables) LLVM IR dead argument elimination pass to remove
7171
unused arguments for the kernel functions before translation to SPIR-V.
7272
Currently has effect only on spir64\* targets.
73-
Disabled by default.
73+
Enabled by default.
7474

7575
**`-f[no-]sycl-id-queries-fit-in-int`**
7676

0 commit comments

Comments
 (0)