diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 6bd02abfe1e5db..1168ad27fe52d2 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -147,7 +147,7 @@ static std::string getInstrProfErrString(instrprof_error Err, // If optional error message is not empty, append it to the message. if (!ErrMsg.empty()) - OS << ": '" << ErrMsg << "'"; + OS << ": " << ErrMsg; return OS.str(); } diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 4fd878a2230d15..b4e8025dbef928 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -463,22 +463,21 @@ Error RawInstrProfReader::readRawCounts( if (CounterOffset < 0) return error( instrprof_error::malformed, - ("counter offset(" + Twine(CounterOffset) + ")" + " is < 0").str()); + ("counter offset " + Twine(CounterOffset) + " is negative").str()); if (CounterOffset > MaxNumCounters) return error(instrprof_error::malformed, - ("counter offset(" + Twine(CounterOffset) + ")" + " > " + - "max number of counters(" + Twine((uint32_t)MaxNumCounters) + - ")") + ("counter offset " + Twine(CounterOffset) + + " is greater than the maximum number of counters " + + Twine((uint32_t)MaxNumCounters)) .str()); if (((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters) return error(instrprof_error::malformed, - ("number of counters is out of bounds(counter offset(" + - Twine((uint32_t)CounterOffset) + ") + " + - "number of counters(" + Twine(NumCounters) + ") > " + - "max number of counters(" + Twine((uint32_t)MaxNumCounters) + - "))") + ("number of counters " + + Twine(((uint32_t)CounterOffset + NumCounters)) + + " is greater than the maximum number of counters " + + Twine((uint32_t)MaxNumCounters)) .str()); auto RawCounts = makeArrayRef(getCounter(CounterOffset), NumCounters); diff --git a/llvm/test/tools/llvm-profdata/large-binary-id-size.test b/llvm/test/tools/llvm-profdata/large-binary-id-size.test index 72612da47e835b..2394431e94de48 100644 --- a/llvm/test/tools/llvm-profdata/large-binary-id-size.test +++ b/llvm/test/tools/llvm-profdata/large-binary-id-size.test @@ -17,4 +17,4 @@ RUN: printf '\0\1\2\3\4\5\6\7' >> %t.profraw RUN: printf '\0\1\2\3\0\0\0\0' >> %t.profraw // RUN: not llvm-profdata show --binary-ids %t.profraw 2>&1 | FileCheck %s -// CHECK: malformed instrumentation profile data: 'not enough data to read binary id data' +// CHECK: malformed instrumentation profile data: not enough data to read binary id data diff --git a/llvm/test/tools/llvm-profdata/malformed-not-space-for-another-header.test b/llvm/test/tools/llvm-profdata/malformed-not-space-for-another-header.test index 6ed3c0a3f047cc..06f418d0235d26 100644 --- a/llvm/test/tools/llvm-profdata/malformed-not-space-for-another-header.test +++ b/llvm/test/tools/llvm-profdata/malformed-not-space-for-another-header.test @@ -11,16 +11,16 @@ // INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) RUN: printf '\201rforpl\377' > %t.profraw -RUN: printf '\x8\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\0\0\0\0\0\0' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw -RUN: printf '\xe\0\0\0\0\0\0\0' >> %t.profraw -RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw -RUN: printf '\x89\x7a\x40\x00\x00\x00\x00\x00' >> %t.profraw -RUN: printf '\1\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\4\0\1\0\0\0' >> %t.profraw +RUN: printf '\0\0\4\0\2\0\0\0' >> %t.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Data Section // @@ -30,22 +30,18 @@ RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw // #include "llvm/ProfileData/InstrProfData.inc" // }; -RUN: printf '\xfa\xd5\x8d\xe7\x36\x64\x95\xdb' >> %t.profraw // NameRef -RUN: printf '\x18\0\0\0\0\0\0\0' >> %t.profraw // FuncHash -RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw // RelativeCounterPtr -RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // FunctionPointer -RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Values -RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw // NumCounters and NumValueSites - -// Counter section +RUN: printf '\254\275\030\333\114\302\370\134' >> %t.profraw +RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\0\0\4\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 '\1\0\0\0\0\0\0\0' >> %t.profraw -// Name section (Name section is 14 bytes and 2 bytes padding is added) -RUN: printf '\x04\x0c\x78\xda\xcb\x4d\xcc\xcc' >> %t.profraw -RUN: printf '\x03\x00\x04\x1b\x01\xa6\x00\x00' >> %t.profraw +RUN: printf '\023\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\3\0foo\0\0\0' >> %t.profraw // Write some garbage data at the end so we get "not enough space for another header" message RUN: printf '\x03\x00\' >> %t.profraw RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s -CHECK: malformed instrumentation profile data: 'not enough space for another header' +CHECK: malformed instrumentation profile data: not enough space for another header diff --git a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test index ab63639fddc4ee..b718cf0fd8e972 100644 --- a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test +++ b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test @@ -11,16 +11,16 @@ // INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) RUN: printf '\201rforpl\377' > %t.profraw -RUN: printf '\x8\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\0\0\0\0\0\0' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw -RUN: printf '\xe\0\0\0\0\0\0\0' >> %t.profraw -RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw -RUN: printf '\x89\x7a\x40\x00\x00\x00\x00\x00' >> %t.profraw -RUN: printf '\1\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\4\0\1\0\0\0' >> %t.profraw +RUN: printf '\0\0\4\0\2\0\0\0' >> %t.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Data Section // @@ -30,20 +30,16 @@ RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw // #include "llvm/ProfileData/InstrProfData.inc" // }; -RUN: printf '\xfa\xd5\x8d\xe7\x36\x64\x95\xdb' >> %t.profraw // NameRef -RUN: printf '\x18\0\0\0\0\0\0\0' >> %t.profraw // FuncHash -RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw // RelativeCounterPtr -RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // FunctionPointer -RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Values -// Make NumCounters = 0 so that we get "number of counters is zero" error message -RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // NumCounters and NumValueSites - -// Counter section +RUN: printf '\254\275\030\333\114\302\370\134' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\0\0\4\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 +// Make NumCounters = 0 so that we get "number of counters is zero" error message +RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw -// Name section (Name section is 14 bytes and 2 bytes padding is added) -RUN: printf '\x04\x0c\x78\xda\xcb\x4d\xcc\xcc' >> %t.profraw -RUN: printf '\x03\x00\x04\x1b\x01\xa6\x00\x00' >> %t.profraw +RUN: printf '\023\0\0\0\0\0\0\0' >> %t.profraw +RUN: printf '\3\0foo\0\0\0' >> %t.profraw RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s -CHECK: malformed instrumentation profile data: 'number of counters is zero' +CHECK: malformed instrumentation profile data: number of counters is zero 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 index 8667f727d0cc9f..c7a8fd4db6d652 100644 --- a/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test +++ b/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test @@ -53,5 +53,5 @@ RUN: printf '\101\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\3\0bar\0\0\0' >> %t.profraw RUN: not llvm-profdata merge -o /dev/null %t.profraw 2>&1 | FileCheck %s -CHECK: warning: {{.+}}: malformed instrumentation profile data: 'number of counters is out of bounds(counter offset(1) + number of counters(2) > max number of counters(2))' +CHECK: warning: {{.+}}: malformed instrumentation profile data: number of counters 3 is greater than the maximum number of counters 2 CHECK: error: no profile can be merged