xref: /llvm-project/llvm/test/tools/llvm-profdata/binary-ids-padding.test (revision 922a431e10fa28519eb5d62e094f19b1008612a1)
1// Header
2//
3// INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
4// INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
5// INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL))
6// INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
7// INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
8// INSTR_PROF_RAW_HEADER(uint64_t, NumBitmaskBytes, NumBitmaskBytes)
9// INSTR_PROF_RAW_HEADER(uint64_t, NamesSize,  NamesSize)
10// INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin)
11// INSTR_PROF_RAW_HEADER(uint64_t, BitmaskDelta, (uintptr_t)BitmaskBegin)
12// INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin)
13// INSTR_PROF_RAW_HEADER(uint64_t, VNamesSize, VNamesSize)
14// INSTR_PROF_RAW_HEADER(uint64_t, NumVTables, NumVTables)
15// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
16
17// gnuwin32 printf does not work for this test because it will print \15 (CR)
18// whenever \12 (LF) is in the input string.
19UNSUPPORTED: system-windows
20RUN: printf '\201rforpl\377' > %t.profraw
21RUN: printf '\12\0\0\0\0\0\0\0' >> %t.profraw
22// There will be 2 20-byte binary IDs, so the total Binary IDs size will be 64 bytes.
23//   2 * 8  binary ID sizes
24// + 2 * 20 binary IDs (of size 20)
25// + 2 * 4  binary ID paddings
26// --------
27// = 64     bytes
28RUN: printf '\100\0\0\0\0\0\0\0' >> %t.profraw
29RUN: printf '\2\0\0\0\0\0\0\0' >> %t.profraw
30RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
31RUN: printf '\3\0\0\0\0\0\0\0' >> %t.profraw
32RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
33RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
34RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
35RUN: printf '\20\0\0\0\0\0\0\0' >> %t.profraw
36RUN: printf '\0\0\4\0\1\0\0\0' >> %t.profraw
37RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
38RUN: printf '\0\0\4\0\2\0\0\0' >> %t.profraw
39RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
40RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
41RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
42
43// Binary IDs - There are only two in this case that are 20 bytes.
44RUN: printf '\24\0\0\0\0\0\0\0' >> %t.profraw
45RUN: printf '\0\1\2\3\4\5\6\7' >> %t.profraw
46RUN: printf '\0\1\2\3\4\5\6\7' >> %t.profraw
47RUN: printf '\0\1\2\3\0\0\0\0' >> %t.profraw
48RUN: printf '\24\0\0\0\0\0\0\0' >> %t.profraw
49RUN: printf '\1\1\1\1\1\1\1\1' >> %t.profraw
50RUN: printf '\2\2\2\2\2\2\2\2' >> %t.profraw
51RUN: printf '\3\3\3\3\0\0\0\0' >> %t.profraw
52
53// Data Section
54//
55// struct ProfData {
56// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
57//    Type Name;
58// #include "llvm/ProfileData/InstrProfData.inc"
59// };
60
61RUN: printf '\254\275\030\333\114\302\370\134' >> %t.profraw
62RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
63RUN: printf '\0\0\4\0\1\0\0\0' >> %t.profraw
64RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
65RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
66RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
67RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
68RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
69
70RUN: printf '\067\265\035\031\112\165\023\344' >> %t.profraw
71RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw
72RUN: printf '\xc8\xff\3\0\1\0\0\0' >> %t.profraw
73RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
74RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
75RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
76RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw
77RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
78
79RUN: printf '\023\0\0\0\0\0\0\0' >> %t.profraw
80RUN: printf '\067\0\0\0\0\0\0\0' >> %t.profraw
81RUN: printf '\101\0\0\0\0\0\0\0' >> %t.profraw
82RUN: printf '\7\0foo\1bar\0\0\0\0\0\0\0' >> %t.profraw
83
84// RUN: llvm-profdata show --binary-ids  %t.profraw | FileCheck %s
85// CHECK: Instrumentation level: Front-end
86// CHECK: Binary IDs:
87// CHECK-NEXT: 0001020304050607000102030405060700010203
88// CHECK-NEXT: 0101010101010101020202020202020203030303
89