Skip to content

Commit c30bcad

Browse files
committedJan 24, 2018
[CUDA] Disable PGO and coverage instrumentation in NVPTX.
NVPTX does not have runtime support necessary for profiling to work and even call arc collection is prohibitively expensive. Furthermore, there's no easy way to collect the samples. NVPTX also does not support global constructors that clang generates if sample/arc collection is enabled. Differential Revision: https://reviews.llvm.org/D42452 llvm-svn: 323345
1 parent fc16f76 commit c30bcad

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
 

‎clang/lib/Driver/ToolChains/Clang.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3625,7 +3625,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
36253625
options::OPT_finstrument_function_entry_bare))
36263626
A->render(Args, CmdArgs);
36273627

3628-
addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
3628+
// NVPTX doesn't support PGO or coverage. There's no runtime support for
3629+
// sampling, overhead of call arc collection is way too high and there's no
3630+
// way to collect the output.
3631+
if (!Triple.isNVPTX())
3632+
addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
36293633

36303634
if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
36313635
ABICompatArg->render(Args, CmdArgs);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Check that profiling/coverage arguments doen't get passed down to device-side
2+
// compilation.
3+
//
4+
// REQUIRES: clang-driver
5+
//
6+
// XRUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \
7+
// XRUN: -fprofile-generate %s 2>&1 | \
8+
// XRUN: FileCheck --check-prefixes=CHECK,PROF %s
9+
//
10+
// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \
11+
// RUN: -fprofile-instr-generate %s 2>&1 | \
12+
// RUN: FileCheck --check-prefixes=CHECK,PROF %s
13+
//
14+
// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \
15+
// RUN: -coverage %s 2>&1 | \
16+
// RUN: FileCheck --check-prefixes=CHECK,GCOV %s
17+
//
18+
// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \
19+
// RUN: -ftest-coverage %s 2>&1 | \
20+
// RUN: FileCheck --check-prefixes=CHECK,GCOV %s
21+
//
22+
// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \
23+
// RUN: -fprofile-instr-generate -fcoverage-mapping %s 2>&1 | \
24+
// RUN: FileCheck --check-prefixes=CHECK,PROF,GCOV %s
25+
//
26+
//
27+
// CHECK-NOT: error: unsupported option '-fprofile
28+
// CHECK-NOT: error: invalid argument
29+
// CHECK-DAG: "-fcuda-is-device"
30+
// CHECK-NOT: "-f{{[^"]*coverage.*}}"
31+
// CHECK-NOT: "-fprofile{{[^"]*}}"
32+
// CHECK: "-triple" "x86_64--linux-gnu"
33+
// PROF-DAG: "-fprofile{{.*}}"
34+
// GCOV-DAG: "-f{{(coverage|emit-coverage).*}}"

0 commit comments

Comments
 (0)
Please sign in to comment.