Skip to content

Commit 9340c96

Browse files
authored
[Driver][SYCL] Do not emit IR when using -fsyntax-only (#4897)
When using -fsyntax-only with -fsycl, IR should not be emitted. Signed-off-by: Qichao Gu qichao.gu@intel.com
1 parent bea72e6 commit 9340c96

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,6 +4147,8 @@ class OffloadingActionBuilder final {
41474147
continue;
41484148
}
41494149
}
4150+
if (Args.hasArg(options::OPT_fsyntax_only))
4151+
OutputType = types::TY_Nothing;
41504152
A = C.MakeAction<CompileJobAction>(A, OutputType);
41514153
DeviceCompilerInput = A;
41524154
}

clang/test/Driver/sycl-offload.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,3 +1118,9 @@
11181118
// RUN: %clang -### -fsycl -ffreestanding %s 2>&1 \
11191119
// RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s
11201120
// CHK-INCOMPATIBILITY: error: The option -fsycl conflicts with -ffreestanding
1121+
1122+
/// Using -fsyntax-only with -fsycl should not emit IR
1123+
// RUN: %clang -### -fsycl -fsyntax-only %s 2>&1 \
1124+
// RUN: | FileCheck -check-prefixes=CHK-FSYNTAX-ONLY,CHK-NO-EMIT-IR %s
1125+
// CHK-FSYNTAX-ONLY: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown"{{.*}} "-fsyntax-only"
1126+
// CHK-NO-EMIT-IR-NOT: "-emit-llvm-bc"

0 commit comments

Comments
 (0)