1// REQUIRES: linux
2// RUN: split-file %s %t.dir
3// RUN: %clang_profgen -Wl,--build-id=sha1 -o %t.dir/foo %t.dir/foo.c
4// RUN: %clang_profgen -Wl,--build-id=sha1 -o %t.dir/bar %t.dir/bar.c
5
6// Check that foo and bar have the same signatures.
7// RUN: rm -rf %t.profdir
8// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.profraw %run %t.dir/foo
9// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.profraw %run %t.dir/bar 2>&1 | FileCheck %s --check-prefix=MERGE-ERROR
10
11// Check that foo and bar have different binary IDs.
12// RUN: rm -rf %t.profdir %t.profdata
13// RUN: env LLVM_PROFILE_FILE=%t.profdir/%b.profraw %run %t.dir/foo
14// RUN: env LLVM_PROFILE_FILE=%t.profdir/%b.profraw %run %t.dir/bar
15// RUN: llvm-profdata merge -o %t.profdata %t.profdir
16// RUN: llvm-profdata show --binary-ids %t.profdata | FileCheck %s --check-prefix=BINARY-ID
17
18// Check fallback to the default name if binary ID is missing.
19// RUN: %clang_profgen -Wl,--build-id=none -o %t.dir/foo %t.dir/foo.c
20// RUN: env LLVM_PROFILE_FILE=%t.profdir/%b.profraw %run %t.dir/foo 2>&1 | FileCheck %s --check-prefix=MISSING
21
22// MERGE-ERROR: LLVM Profile Error: Profile Merging of file {{.*}}.profraw failed: File exists
23
24// BINARY-ID: Instrumentation level: Front-end
25// BINARY-ID-NEXT: Total functions: 3
26// BINARY-ID-NEXT: Maximum function count: 2
27// BINARY-ID-NEXT: Maximum internal block count: 0
28// BINARY-ID-NEXT: Total number of blocks: 3
29// BINARY-ID-NEXT: Total count: 2
30// BINARY-ID-NEXT: Binary IDs:
31// BINARY-ID-NEXT: {{[0-9a-f]+}}
32// BINARY-ID-NEXT: {{[0-9a-f]+}}
33
34// MISSING: Unable to get binary ID for filename pattern {{.*}}.profraw. Using the default name.
35
36//--- foo.c
37int main(void) { return 0; }
38void foo(void) {}
39
40//--- bar.c
41int main(void) { return 0; }
42void bar(int *a) { *a += 10; }
43

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