Skip to content

Commit d5454ce

Browse files
committedOct 11, 2016
[profile] Add test for dead_strip+live_support functionality
Differential Revision: https://reviews.llvm.org/D25457 llvm-svn: 283948
1 parent de2ae96 commit d5454ce

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// REQUIRES: osx-ld64-live_support
2+
// REQUIRES: lto
3+
4+
// RUN: %clang_profgen=%t.profraw -fcoverage-mapping -mllvm -enable-name-compression=false -Wl,-dead_strip -o %t %s
5+
// RUN: %run %t
6+
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
7+
// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s -check-prefix=PROF
8+
// RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s -check-prefix=COV
9+
// RUN: nm %t | FileCheck %s -check-prefix=NM
10+
// RUN: otool -s __DATA __llvm_prf_names %t | FileCheck %s -check-prefix=PRF_NAMES
11+
// RUN: otool -s __DATA __llvm_prf_cnts %t | FileCheck %s -check-prefix=PRF_CNTS
12+
13+
// RUN: %clang_lto_profgen=%t.lto.profraw -fcoverage-mapping -mllvm -enable-name-compression=false -Wl,-dead_strip -flto -o %t.lto %s
14+
// RUN: %run %t.lto
15+
// RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw
16+
// RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s -check-prefix=PROF
17+
// RUN: llvm-cov show %t.lto -instr-profile %t.lto.profdata | FileCheck %s -check-prefix=COV
18+
// RUN: nm %t.lto | FileCheck %s -check-prefix=NM
19+
// RUN: otool -s __DATA __llvm_prf_names %t.lto | FileCheck %s -check-prefix=PRF_NAMES
20+
// RUN: otool -s __DATA __llvm_prf_cnts %t.lto | FileCheck %s -check-prefix=PRF_CNTS
21+
22+
// Note: We expect foo() and some of the profiling data associated with it to
23+
// be dead-stripped.
24+
25+
// COV: [[@LINE+1]]{{ *}}|{{ *}}0|void foo()
26+
void foo() {}
27+
28+
// COV: [[@LINE+1]]{{ *}}|{{ *}}1|int main
29+
int main() { return 0; }
30+
31+
// NM-NOT: foo
32+
33+
// PROF: Counters:
34+
// PROF-NEXT: main:
35+
// PROF-NEXT: Hash:
36+
// PROF-NEXT: Counters: 1
37+
// PROF-NEXT: Function count: 1
38+
// PROF-NEXT: Functions shown: 1
39+
// PROF-NEXT: Total functions: 1
40+
// PROF-NEXT: Maximum function count: 1
41+
// PROF-NEXT: Maximum internal block count: 0
42+
43+
// Note: We don't expect the names of dead-stripped functions to disappear from
44+
// __llvm_prf_names, because collectPGOFuncNameStrings() glues the names
45+
// together.
46+
47+
// PRF_NAMES: Contents of (__DATA,__llvm_prf_names) section
48+
// PRF_NAMES-NEXT: {{.*}} 08 00 66 6f 6f 01 6d 61 69 6e{{ +$}}
49+
// | | f o o # m a i n
50+
// | |___________|
51+
// | |
52+
// UncompressedLen = 8 |
53+
// |
54+
// CompressedLen = 0
55+
56+
// Note: We expect the profile counters for dead-stripped functions to also be
57+
// dead-stripped.
58+
59+
// PRF_CNTS: Contents of (__DATA,__llvm_prf_cnts) section
60+
// PRF_CNTS-NEXT: {{.*}} 00 00 00 00 00 00 00 00{{ +$}}

‎compiler-rt/test/profile/lit.cfg

+9-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ target_cflags=[get_required_attr(config, "target_cflags")]
4949
clang_cflags = target_cflags + extra_linkflags
5050
clang_cxxflags = config.cxx_mode_flags + clang_cflags
5151

52-
def build_invocation(compile_flags):
53-
return " " + " ".join([config.clang] + compile_flags) + " "
52+
def build_invocation(compile_flags, with_lto = False):
53+
lto_flags = []
54+
lto_prefix = []
55+
if with_lto and config.lto_supported:
56+
lto_flags += config.lto_flags
57+
lto_prefix += config.lto_launch
58+
return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " "
5459

5560
# Add clang substitutions.
5661
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
@@ -71,6 +76,8 @@ config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cfla
7176
config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
7277
config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") )
7378

79+
config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") )
80+
7481
if config.host_os not in ['Darwin', 'FreeBSD', 'Linux']:
7582
config.unsupported = True
7683

0 commit comments

Comments
 (0)
Please sign in to comment.