Skip to content

Commit

Permalink
[Driver][SYCL] Do not emit IR when using -fsyntax-only (#4897)
Browse files Browse the repository at this point in the history
When using -fsyntax-only with -fsycl, IR should not be emitted.

Signed-off-by: Qichao Gu [email protected]
  • Loading branch information
qichaogu authored Nov 8, 2021
1 parent bea72e6 commit 9340c96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4147,6 +4147,8 @@ class OffloadingActionBuilder final {
continue;
}
}
if (Args.hasArg(options::OPT_fsyntax_only))
OutputType = types::TY_Nothing;
A = C.MakeAction<CompileJobAction>(A, OutputType);
DeviceCompilerInput = A;
}
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,3 +1118,9 @@
// RUN: %clang -### -fsycl -ffreestanding %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-INCOMPATIBILITY %s
// CHK-INCOMPATIBILITY: error: The option -fsycl conflicts with -ffreestanding

/// Using -fsyntax-only with -fsycl should not emit IR
// RUN: %clang -### -fsycl -fsyntax-only %s 2>&1 \
// RUN: | FileCheck -check-prefixes=CHK-FSYNTAX-ONLY,CHK-NO-EMIT-IR %s
// CHK-FSYNTAX-ONLY: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown"{{.*}} "-fsyntax-only"
// CHK-NO-EMIT-IR-NOT: "-emit-llvm-bc"

0 comments on commit 9340c96

Please sign in to comment.