[PATCH] D68718: [llvm-profdata] Make "malformed-ptr-to-counter-array.test" textual

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 10:51:42 PDT 2019


Hi Yvan,

Thanks for the info and your patience. I removed this test to unblock the ARM bots while looking into this (r374915), and have reinstated it with a fix in r374927.

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

Thanks again,
vedant

> On Oct 15, 2019, at 6:02 AM, Yvan Roux via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Hi Vendant,
> 
> the exit code is 1 last logs are here:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10919/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Amalformed-ptr-to-counter-array.test
> 
> I also ran the test manually here is an hexdump of the data file:
> 
> 0000000 7281 6f66 7072 ff6c 0004 0000 0000 0000
> 0000010 0001 0000 0000 0000 0002 0000 0000 0000
> 0000020 0008 0000 0000 0000 0000 0006 0001 0000
> 0000030 0000 0006 0002 0000 0000 0000 0000 0000
> 0000040 b537 191d 754a e413 0002 0000 0000 0000
> 0000050 0000 0006 0001 0100 0000 0000 0000 0000
> 0000060 0000 0000 0000 0000 0002 0000 0000 0000
> 0000070 0037 0000 0000 0000 0041 0000 0000 0000
> 0000080 0003 6162 0072 0000
> 0000088
> 
> llvm-profdata merge code gives:
> 
> 0000000 6cff 7270 666f 8169 0005 0000 0000 0000
> 0000010 0000 0000 0000 0000 0000 0000 0000 0000
> 0000020 0230 0000 0000 0000 0006 0000 0000 0000
> 0000030 0010 0000 0000 0000 0001 0000 0000 0000
> 0000040 0002 0000 0000 0000 0037 0000 0000 0000
> 0000050 0041 0000 0000 0000 0041 0000 0000 0000
> 0000060 0078 0000 0000 0000 2710 0000 0000 0000
> 0000070 0041 0000 0000 0000 0001 0000 0000 0000
> 0000080 86a0 0001 0000 0000 0041 0000 0000 0000
> 0000090 0001 0000 0000 0000 0d40 0003 0000 0000
> 00000a0 0041 0000 0000 0000 0001 0000 0000 0000
> 00000b0 93e0 0004 0000 0000 0041 0000 0000 0000
> 00000c0 0001 0000 0000 0000 1a80 0006 0000 0000
> 00000d0 0041 0000 0000 0000 0001 0000 0000 0000
> 00000e0 a120 0007 0000 0000 0041 0000 0000 0000
> 00000f0 0001 0000 0000 0000 27c0 0009 0000 0000
> 0000100 0037 0000 0000 0000 0002 0000 0000 0000
> 0000110 ae60 000a 0000 0000 0037 0000 0000 0000
> 0000120 0002 0000 0000 0000 3500 000c 0000 0000
> 0000130 0037 0000 0000 0000 0002 0000 0000 0000
> 0000140 bba0 000d 0000 0000 0037 0000 0000 0000
> 0000150 0002 0000 0000 0000 7ef0 000e 0000 0000
> 0000160 0037 0000 0000 0000 0002 0000 0000 0000
> 0000170 1b30 000f 0000 0000 0037 0000 0000 0000
> 0000180 0002 0000 0000 0000 3e58 000f 0000 0000
> 0000190 0037 0000 0000 0000 0002 0000 0000 0000
> 00001a0 41dc 000f 0000 0000 0037 0000 0000 0000
> 00001b0 0002 0000 0000 0000 4236 000f 0000 0000
> 00001c0 0037 0000 0000 0000 0002 0000 0000 0000
> 00001d0 423f 000f 0000 0000 0037 0000 0000 0000
> 00001e0 0002 0000 0000 0000 0001 b537 191d 754a
> 00001f0 e413 0003 0000 0000 0000 0028 0000 0000
> 0000200 0000 6162 0272 0000 0000 0000 0200 0000
> 0000210 0000 0000 3700 0000 0000 0000 4100 0000
> 0000220 0000 0000 0800 0000 0000 0000 0000 0000
> 0000230 0001 0000 0000 0000 0001 0000 0000 0000
> 0000240 01e8 0000 0000 0000
> 0000248
> 
> $ ./bin/llvm-profdata show --all-functions --detailed-summary file.data
> Counters:
>  bar:
>    Hash: 0x0000000000000002
>    Counters: 2
>    Function count: 55
> Instrumentation level: Front-end
> Functions shown: 1
> Total functions: 1
> Maximum function count: 55
> Maximum internal block count: 65
> Detailed summary:
> Total number of blocks: 2
> Total count: 120
> 2 blocks with count >= 55 account for 80 percentage of the total counts.
> 2 blocks with count >= 55 account for 90 percentage of the total counts.
> 2 blocks with count >= 55 account for 95 percentage of the total counts.
> 2 blocks with count >= 55 account for 99 percentage of the total counts.
> 2 blocks with count >= 55 account for 99.9 percentage of the total counts.
> 2 blocks with count >= 55 account for 99.99 percentage of the total counts.
> 2 blocks with count >= 55 account for 99.999 percentage of the total counts.
> 
> Hope it helps
> Yvan
> 
> On Mon, 14 Oct 2019 at 19:20, Vedant Kumar <vedant_kumar at apple.com> wrote:
>> 
>> Hi Yvan,
>> 
>> I'm not sure what went wrong, so I've landed r374792 to weaken the test in an attempt to get more information (or, possibly appease the bots).
>> 
>> It looks a bit like the error message llvm-profdata is expected to print to stderr isn't flushed. If that's the wrong explanation, r374792 should give us more info (e.g. if the exit code is 0, there must be a bug).
>> 
>> thanks,
>> vedant
>> 
>>> On Oct 14, 2019, at 7:59 AM, Vedant Kumar <vedant_kumar at apple.com> wrote:
>>> 
>>> Hi Yvan,
>>> 
>>> Apologies, but I won’t be able to look at this in the next 2-3 hours. Feel free to revert in the interim.
>>> 
>>> thanks,
>>> vedant
>>> 
>>>> On Oct 14, 2019, at 12:59 AM, Yvan Roux <yvan.roux at linaro.org> wrote:
>>>> 
>>>> Hi Vedant,
>>>> 
>>>> this commit broke ARM bots, logs are available here:
>>>> 
>>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10838/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Amalformed-ptr-to-counter-array.test
>>>> 
>>>> Cheers,
>>>> Yvan
>>>> 
>>>> On Sat, 12 Oct 2019 at 02:28, Vedant Kumar via Phabricator via
>>>> llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>>>> 
>>>>> This revision was automatically updated to reflect the committed changes.
>>>>> Closed by commit rG852e3b207651: [llvm-profdata] Make "malformed-ptr-to-counter-array.test" textual (authored by vsk).
>>>>> 
>>>>> Repository:
>>>>> rG LLVM Github Monorepo
>>>>> 
>>>>> CHANGES SINCE LAST ACTION
>>>>> https://reviews.llvm.org/D68718/new/
>>>>> 
>>>>> https://reviews.llvm.org/D68718
>>>>> 
>>>>> Files:
>>>>> llvm/test/tools/llvm-profdata/Inputs/malformed-ptr-to-counter-array.profraw
>>>>> llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
>>>>> 
>>>>> 
>>>>> Index: llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
>>>>> ===================================================================
>>>>> --- llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
>>>>> +++ llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
>>>>> @@ -1,5 +1,50 @@
>>>>> -REQUIRES: zlib
>>>>> +// 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: not llvm-profdata merge -o /dev/null %p/Inputs/malformed-ptr-to-counter-array.profraw 2>&1 | FileCheck %s
>>>>> +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. This should trigger a malformed profile error.
>>>>> +RUN: printf '\0\0\6\0\1\0\0\1' >> %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
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at lists.llvm.org
>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list