xref: /llvm-project/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.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
22RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
23RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
24RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
25RUN: printf '\2\0\0\0\0\0\0\0' >> %t.profraw
26RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
27RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
28RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
29RUN: printf '\10\0\0\0\0\0\0\0' >> %t.profraw
30RUN: printf '\0\0\6\0\1\0\0\0' >> %t.profraw
31RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
32RUN: printf '\0\0\6\0\2\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 '\0\0\0\0\0\0\0\0' >> %t.profraw
36
37// Data Section
38//
39// struct ProfData {
40// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \
41//    Type Name;
42// #include "llvm/ProfileData/InstrProfData.inc"
43// };
44
45RUN: printf '\067\265\035\031\112\165\023\344' >> %t.profraw
46RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw
47
48// Note: The CounterPtr here is off-by-one.
49//
50// Octal '\11' is 9 in decimal: this should push CounterOffset to 1. As there are two counters,
51// the profile reader should error out.
52RUN: printf '\11\0\6\0\1\0\0\0' >> %t.profraw
53RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
54
55RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
56RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
57RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw
58RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
59
60// Counter Section
61
62RUN: printf '\067\0\0\0\0\0\0\0' >> %t.profraw
63RUN: printf '\101\0\0\0\0\0\0\0' >> %t.profraw
64
65// Name Section
66
67RUN: printf '\3\0bar\0\0\0' >> %t.profraw
68
69RUN: not llvm-profdata merge -o /dev/null %t.profraw 2>&1 | FileCheck %s
70CHECK: warning: {{.+}}: malformed instrumentation profile data: number of counters 2 is greater than the maximum number of counters 0
71CHECK: error: no profile can be merged
72