Skip to content

Commit 12a0b11

Browse files
authored
[Driver][SYCL] Disable code coverage for device compilations (#3384)
Code coverage for SYCL device compilation is currently not supported. If used with -fsycl, do not enable for the device compile.
1 parent d02879c commit 12a0b11

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,17 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
531531

532532
if (!DAL) {
533533
DAL = new DerivedArgList(Args.getBaseArgs());
534-
for (Arg *A : Args)
535-
DAL->append(A);
534+
for (Arg *A : Args) {
535+
// Filter out any options we do not want to pass along to the device
536+
// compilation.
537+
switch ((options::ID)A->getOption().getID()) {
538+
default:
539+
DAL->append(A);
540+
break;
541+
case options::OPT_fcoverage_mapping:
542+
break;
543+
}
544+
}
536545
}
537546

538547
const OptTable &Opts = getDriver().getOpts();

clang/test/Driver/sycl-offload.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@
2424
// RUN: %clang -### -fsycl %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
2525
// CHECK-OPTS: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
2626
// CHECK-OPTS: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-host"
27+
28+
/// Check that -fcoverage-mapping is disabled for device
29+
// RUN: %clang -### -fsycl -fprofile-instr-generate -fcoverage-mapping -target x86_64-unknown-linux-gnu -c %s 2>&1 \
30+
// RUN: | FileCheck -check-prefix=CHECK_COVERAGE_MAPPING %s
31+
// CHECK_COVERAGE_MAPPING: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" "-fsycl-is-device"{{.*}} "-fprofile-instrument=clang"
32+
// CHECK_COVERAGE_MAPPING-NOT: "-fcoverage-mapping"
33+
// CHECK_COVERAGE_MAPPING: clang{{.*}} "-cc1" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fprofile-instrument=clang"
34+
// CHECK_COVERAGE_MAPPING: "-fcoverage-mapping"{{.*}} "-fsycl-is-host"

0 commit comments

Comments
 (0)