Skip to content

Commit 54be90a

Browse files
authored
[Driver][SYCL] Do not pass along code coverage and profiling to device (#5423)
Code Coverage and the enabling profiling options are not supported for device compilations for SPIR-V. Disable the passing of these options to the device compilation only, but allow for these to continue to work for the host side
1 parent 957d9d2 commit 54be90a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5960,7 +5960,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
59605960
// NVPTX/AMDGCN doesn't support PGO or coverage. There's no runtime support
59615961
// for sampling, overhead of call arc collection is way too high and there's
59625962
// no way to collect the output.
5963-
if (!Triple.isNVPTX() && !Triple.isAMDGCN())
5963+
// Disable for SPIR-V compilations as well.
5964+
if (!Triple.isNVPTX() && !Triple.isAMDGCN() && !Triple.isSPIR())
59645965
addPGOAndCoverageFlags(TC, C, D, Output, Args, SanitizeArgs, CmdArgs);
59655966

59665967
Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ);

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,6 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
652652
default:
653653
DAL->append(A);
654654
break;
655-
case options::OPT_fcoverage_mapping:
656-
break;
657655
}
658656
}
659657
}

clang/test/Driver/sycl-offload.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,19 @@
3030
/// Check that -fcoverage-mapping is disabled for device
3131
// RUN: %clang -### -fsycl -fprofile-instr-generate -fcoverage-mapping -target x86_64-unknown-linux-gnu -c %s 2>&1 \
3232
// RUN: | FileCheck -check-prefix=CHECK_COVERAGE_MAPPING %s
33-
// CHECK_COVERAGE_MAPPING: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fprofile-instrument=clang"
33+
// CHECK_COVERAGE_MAPPING: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}}
34+
// CHECK_COVERAGE_MAPPING-NOT: "-fprofile-instrument=clang"
3435
// CHECK_COVERAGE_MAPPING-NOT: "-fcoverage-mapping"
3536
// CHECK_COVERAGE_MAPPING: clang{{.*}} "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-host"{{.*}} "-fprofile-instrument=clang"{{.*}} "-fcoverage-mapping"{{.*}}
3637

38+
/// Check that -fprofile-arcs -ftest-coverage is disabled for device
39+
// RUN: %clang -### -fsycl -fprofile-arcs -ftest-coverage -target x86_64-unknown-linux-gnu -c %s 2>&1 \
40+
// RUN: | FileCheck -check-prefix=CHECK_TEST_COVERAGE %s
41+
// CHECK_TEST_COVERAGE: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}}
42+
// CHECK_TEST_COVERAGE-NOT: "-ftest-coverage"
43+
// CHECK_TEST_COVERAGE-NOT: "-fprofile-arcs"
44+
// CHECK_TEST_COVERAGE: clang{{.*}} "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-host"{{.*}} "-ftest-coverage" "-fprofile-arcs"
45+
3746
/// check for PIC for device wrap compilation when using -shared or -fPIC
3847
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -shared %s 2>&1 \
3948
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s

0 commit comments

Comments
 (0)