Skip to content

Commit 1698931

Browse files
[SYCL] Emit textual IR when -S -fsycl-device-only is used (#1314)
Signed-off-by: Joshua Cranmer <[email protected]>
1 parent 8bfa107 commit 1698931

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4751,9 +4751,11 @@ Action *Driver::ConstructPhaseAction(
47514751
return C.MakeAction<BackendJobAction>(Input, Output);
47524752
}
47534753
if (Args.hasArg(options::OPT_fsycl_device_only)) {
4754+
types::ID OutputType =
4755+
Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
47544756
if (Args.hasFlag(options::OPT_fsycl_use_bitcode,
47554757
options::OPT_fno_sycl_use_bitcode, true))
4756-
return C.MakeAction<BackendJobAction>(Input, types::TY_LLVM_BC);
4758+
return C.MakeAction<BackendJobAction>(Input, OutputType);
47574759
// Use of -fsycl-device-only creates a bitcode file, we need to translate
47584760
// that to a SPIR-V file with -fno-sycl-use-bitcode
47594761
auto *BackendAction =

clang/test/Driver/sycl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
// RUN: %clang -### -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
2525
// RUN: %clang -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
26+
// RUN: %clang -### -fsycl-device-only -S %s 2>&1 | FileCheck %s --check-prefix=TEXTUAL
2627
// RUN: %clang -### -fsycl-device-only -fsycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
2728
// RUN: %clang -### -fsycl-device-only -fno-sycl-use-bitcode -c %s 2>&1 | FileCheck %s --check-prefix=NO-BITCODE
2829
// RUN: %clang -### -target spir64-unknown-linux-sycldevice -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=TARGET
@@ -39,6 +40,7 @@
3940
// NO-BITCODE: "{{.*}}llvm-spirv"{{.*}} "-spirv-max-version=1.1"{{.*}} "-spirv-ext=+all"
4041
// TARGET: "-triple" "spir64-unknown-linux-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
4142
// COMBINED: "-triple" "spir64-unknown-{{.*}}-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
43+
// TEXTUAL: "-triple" "spir64-unknown-{{.*}}-sycldevice{{.*}}" "-fsycl-is-device"{{.*}} "-emit-llvm"
4244

4345
/// Verify -fsycl-device-only phases
4446
// RUN: %clang -### -ccc-print-phases -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-PHASES

0 commit comments

Comments
 (0)