Skip to content

Commit ee81855

Browse files
committed
[Driver][SYCL] Enable Dead Parameter Elimination Optimization
This is enabled by default for -fsycl, and can be disabled via the -fno-sycl-early-optimizations switch. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent e1e3658 commit ee81855

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,6 +4123,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
41234123
CmdArgs.push_back("-mllvm");
41244124
CmdArgs.push_back("-sycl-opt");
41254125
}
4126+
// Turn on Dead Parameter Elimination Optimization with early optimizations
4127+
if (Args.hasFlag(options::OPT_fsycl_early_optimizations,
4128+
options::OPT_fno_sycl_early_optimizations, true))
4129+
CmdArgs.push_back("-fenable-sycl-dae");
41264130

41274131
// Pass the triple of host when doing SYCL
41284132
auto AuxT = llvm::Triple(llvm::sys::getProcessTriple());
@@ -7807,6 +7811,10 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
78077811
// OPT_fsycl_device_code_split is not checked as it is an alias to
78087812
// -fsycl-device-code-split=per_source
78097813

7814+
// Turn on Dead Parameter Elimination Optimization with early optimizations
7815+
if (TCArgs.hasFlag(options::OPT_fsycl_early_optimizations,
7816+
options::OPT_fno_sycl_early_optimizations, true))
7817+
addArgs(CmdArgs, TCArgs, {"-emit-param-info"});
78107818
if (JA.getType() == types::TY_LLVM_BC) {
78117819
// single file output requested - this means only perform necessary IR
78127820
// transformations (like specialization constant intrinsic lowering) and

clang/test/Driver/sycl-device-optimizations.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@
2828
// RUN: %clang_cl -### -fsycl -fintelfpga %s 2>&1 \
2929
// RUN: | FileCheck -check-prefix=CHECK-NO-SYCL-EARLY-OPTS %s
3030
// CHECK-NO-SYCL-EARLY-OPTS: "-fno-sycl-early-optimizations"
31+
32+
/// Check that Dead Parameter Elimination Optimization is enabled
33+
// RUN: %clang -### -fsycl %s 2>&1 \
34+
// RUN: | FileCheck -check-prefix=CHECK-DAE %s
35+
// RUN: %clang -### -fsycl -fsycl-early-optimizations %s 2>&1 \
36+
// RUN: | FileCheck -check-prefix=CHECK-DAE %s
37+
// CHECK-DAE: clang{{.*}} "-fenable-sycl-dae"
38+
// CHECK-DAE: sycl-post-link{{.*}} "-emit-param-info"

0 commit comments

Comments
 (0)