1// REQUIRES: target={{.*windows-msvc.*}}
2// REQUIRES: lld-available
3
4// RUN: %clang_profgen -O2 -o %t %s
5// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
6// RUN: llvm-profdata show --binary-ids %t.profraw > %t.out
7// RUN: FileCheck %s --check-prefix=NO-BINARY-ID < %t.out
8// RUN: llvm-profdata merge -o %t.profdata %t.profraw
9
10// RUN: %clang_profgen -fuse-ld=lld -Wl,-build-id -O2 -o %t %s
11// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
12// RUN: llvm-profdata show --binary-ids %t.profraw > %t.profraw.out
13// RUN: FileCheck %s --check-prefix=BINARY-ID-RAW-PROF < %t.profraw.out
14
15// RUN: rm -rf %t.profdir
16// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
17// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
18// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
19// RUN: llvm-profdata show --binary-ids %t.profdir/default_*.profraw > %t.profraw.out
20// RUN: FileCheck %s --check-prefix=ONE-BINARY-ID < %t.profraw.out
21
22// RUN: llvm-profdata merge -o %t.profdata %t.profdir/default_*.profraw
23// RUN: llvm-profdata show --binary-ids %t.profdata > %t.profdata.out
24// RUN: FileCheck %s --check-prefix=ONE-BINARY-ID < %t.profdata.out
25
26// Test raw profiles with DLLs.
27// RUN: rm -rf %t.dir && split-file %s %t.dir
28// RUN: %clang_profgen -O2 %t.dir/foo.c -fuse-ld=lld -Wl,-build-id -Wl,-dll -o %t.dir/foo.dll
29// RUN: %clang_profgen -O2 %t.dir/bar.c -fuse-ld=lld -Wl,-build-id -Wl,-dll -o %t.dir/bar.dll
30// RUN: %clang_profgen -O2 %t.dir/main.c -fuse-ld=lld -Wl,-build-id %t.dir/foo.lib %t.dir/bar.lib -o %t.dir/main.exe
31// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.dir/main.exe
32// RUN: llvm-profdata show --binary-ids %t.profraw > %t.profraw.out
33// RUN: llvm-profdata merge -o %t.profdata %t.profraw
34// RUN: FileCheck %s --check-prefix=MULTI-BINARY-ID < %t.profraw.out
35
36// RUN: llvm-profdata merge -o %t.profdata %t.profraw
37// RUN: llvm-profdata show --binary-ids %t.profdata > %t.profdata.out
38// RUN: FileCheck %s --check-prefix=MULTI-BINARY-ID < %t.profraw.out
39
40//--- foo.c
41__declspec(dllexport) void foo() {}
42
43//--- bar.c
44__declspec(dllexport) void bar() {}
45
46//--- main.c
47__declspec(dllimport) void foo();
48__declspec(dllimport) void bar();
49int main() {
50 foo();
51 bar();
52 return 0;
53}
54
55// NO-BINARY-ID: Instrumentation level: Front-end
56// NO-BINARY-ID-NEXT: Total functions: 3
57// NO-BINARY-ID-NEXT: Maximum function count: 1
58// NO-BINARY-ID-NEXT: Maximum internal block count: 0
59// NO-BINARY-ID-NOT: Binary IDs:
60
61// BINARY-ID-RAW-PROF: Instrumentation level: Front-end
62// BINARY-ID-RAW-PROF-NEXT: Total functions: 3
63// BINARY-ID-RAW-PROF-NEXT: Maximum function count: 1
64// BINARY-ID-RAW-PROF-NEXT: Maximum internal block count: 0
65// BINARY-ID-RAW-PROF-NEXT: Binary IDs:
66// BINARY-ID-RAW-PROF-NEXT: {{[0-9a-f]+}}
67
68// ONE-BINARY-ID: Instrumentation level: Front-end
69// ONE-BINARY-ID-NEXT: Total functions: 3
70// ONE-BINARY-ID-NEXT: Maximum function count: 3
71// ONE-BINARY-ID-NEXT: Maximum internal block count: 0
72// ONE-BINARY-ID-NEXT: Binary IDs:
73// ONE-BINARY-ID-NEXT: {{[0-9a-f]+}}
74
75// MULTI-BINARY-ID: Instrumentation level: Front-end
76// MULTI-BINARY-ID-NEXT: Total functions: 3
77// MULTI-BINARY-ID-NEXT: Maximum function count: 1
78// MULTI-BINARY-ID-NEXT: Maximum internal block count: 0
79// MULTI-BINARY-ID-NEXT: Binary IDs:
80// MULTI-BINARY-ID-NEXT: {{[0-9a-f]+}}
81// MULTI-BINARY-ID-NEXT: {{[0-9a-f]+}}
82// MULTI-BINARY-ID-NEXT: {{[0-9a-f]+}}
83

source code of compiler-rt/test/profile/Windows/binary-id.c