From c7ec51a7c3ede8c1024b90d5fdc91979a9f01bf8 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 15 Oct 2019 17:53:48 +0000 Subject: [PATCH] [llvm-profdata] Reinstate tools/llvm-profdata/malformed-ptr-to-counter-array.test I removed this test to unblock the ARM bots while looking into failures (r374915), and am reinstating it now with a fix. I believe the problem was that counter ptr address I used, '\0\0\6\0\1\0\0\1', set the high bits of the pointer, not the low bits like I wanted. On x86_64 this superficially looks like it tests r370826, but it doesn't, as it would have been caught before r370826. However, on ARM (or, 32-bit hosts more generally), I suspect the high bits were cleared, and you get a 'valid' profile. I verified that setting the *low* bits of the pointer does trigger the new condition: -// Note: The CounterPtr here is off-by-one. This should trigger a malformed profile error. -RUN: printf '\0\0\6\0\1\0\0\1' >> %t.profraw +// Note: The CounterPtr here is off-by-one. +// +// Octal '\11' is 9 in decimal: this should push CounterOffset to 1. As there are two counters, +// the profile reader should error out. +RUN: printf '\11\0\6\0\1\0\0\0' >> %t.profraw This reverts commit c7cf5b3e4b918c9769fd760f28485b8d943ed968. llvm-svn: 374927 --- .../malformed-ptr-to-counter-array.test | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test diff --git a/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test b/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test new file mode 100644 index 0000000..c355bdc --- /dev/null +++ b/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test @@ -0,0 +1,52 @@ +// Header +// +// INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic()) +// INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version()) +// INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize) +// INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize) +// INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize) +// INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin) +// INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin) +// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) + +RUN: printf '\201rforpl\377' > %t.profraw +RUN: printf '\4\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\2\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\10\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\0\0\6\0\1\0\0\0' >> %t.profraw +RUN: printf '\0\0\6\0\2\0\0\0' >> %t.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw + +// Data Section +// +// struct ProfData { +// #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \ +// Type Name; +// #include "llvm/ProfileData/InstrProfData.inc" +// }; + +RUN: printf '\067\265\035\031\112\165\023\344' >> %t.profraw +RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw + +// Note: The CounterPtr here is off-by-one. +// +// Octal '\11' is 9 in decimal: this should push CounterOffset to 1. As there are two counters, +// the profile reader should error out. +RUN: printf '\11\0\6\0\1\0\0\0' >> %t.profraw + +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw + +// Counter Section + +RUN: printf '\067\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\101\0\0\0\0\0\0\0' >> %t.profraw + +// Name Section + +RUN: printf '\3\0bar\0\0\0' >> %t.profraw + +RUN: not llvm-profdata merge -o /dev/null %t.profraw 2>&1 | FileCheck %s +CHECK: Malformed instrumentation profile data -- 2.7.4