forked from OSchip/llvm-project
[compiler-rt] Fix diagnostic in InstrProfError
This patch fixes some issues introduced in https://reviews.llvm.org/D108942: 1) Remove the default label to fix the bots that use -Werror,-Wcovered-switch-default 2) Modify the malformed test to fix the bots that are built without zlib support 3) Modify some error messages in malformed profiles
This commit is contained in:
parent
1f01b31755
commit
126e7611c7
|
@ -147,7 +147,7 @@ static std::string getInstrProfErrString(instrprof_error Err,
|
||||||
|
|
||||||
// If optional error message is not empty, append it to the message.
|
// If optional error message is not empty, append it to the message.
|
||||||
if (!ErrMsg.empty())
|
if (!ErrMsg.empty())
|
||||||
OS << ": '" << ErrMsg << "'";
|
OS << ": " << ErrMsg;
|
||||||
|
|
||||||
return OS.str();
|
return OS.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,22 +463,21 @@ Error RawInstrProfReader<IntPtrT>::readRawCounts(
|
||||||
if (CounterOffset < 0)
|
if (CounterOffset < 0)
|
||||||
return error(
|
return error(
|
||||||
instrprof_error::malformed,
|
instrprof_error::malformed,
|
||||||
("counter offset(" + Twine(CounterOffset) + ")" + " is < 0").str());
|
("counter offset " + Twine(CounterOffset) + " is negative").str());
|
||||||
|
|
||||||
if (CounterOffset > MaxNumCounters)
|
if (CounterOffset > MaxNumCounters)
|
||||||
return error(instrprof_error::malformed,
|
return error(instrprof_error::malformed,
|
||||||
("counter offset(" + Twine(CounterOffset) + ")" + " > " +
|
("counter offset " + Twine(CounterOffset) +
|
||||||
"max number of counters(" + Twine((uint32_t)MaxNumCounters) +
|
" is greater than the maximum number of counters " +
|
||||||
")")
|
Twine((uint32_t)MaxNumCounters))
|
||||||
.str());
|
.str());
|
||||||
|
|
||||||
if (((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters)
|
if (((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters)
|
||||||
return error(instrprof_error::malformed,
|
return error(instrprof_error::malformed,
|
||||||
("number of counters is out of bounds(counter offset(" +
|
("number of counters " +
|
||||||
Twine((uint32_t)CounterOffset) + ") + " +
|
Twine(((uint32_t)CounterOffset + NumCounters)) +
|
||||||
"number of counters(" + Twine(NumCounters) + ") > " +
|
" is greater than the maximum number of counters " +
|
||||||
"max number of counters(" + Twine((uint32_t)MaxNumCounters) +
|
Twine((uint32_t)MaxNumCounters))
|
||||||
"))")
|
|
||||||
.str());
|
.str());
|
||||||
|
|
||||||
auto RawCounts = makeArrayRef(getCounter(CounterOffset), NumCounters);
|
auto RawCounts = makeArrayRef(getCounter(CounterOffset), NumCounters);
|
||||||
|
|
|
@ -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: printf '\0\1\2\3\0\0\0\0' >> %t.profraw
|
||||||
|
|
||||||
// RUN: not llvm-profdata show --binary-ids %t.profraw 2>&1 | FileCheck %s
|
// 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
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
|
// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
|
||||||
|
|
||||||
RUN: printf '\201rforpl\377' > %t.profraw
|
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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\1\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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\1\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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\xe\0\0\0\0\0\0\0' >> %t.profraw
|
RUN: printf '\10\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw
|
RUN: printf '\0\0\4\0\1\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x89\x7a\x40\x00\x00\x00\x00\x00' >> %t.profraw
|
RUN: printf '\0\0\4\0\2\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
|
||||||
|
|
||||||
// Data Section
|
// Data Section
|
||||||
//
|
//
|
||||||
|
@ -30,22 +30,18 @@ RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
// #include "llvm/ProfileData/InstrProfData.inc"
|
// #include "llvm/ProfileData/InstrProfData.inc"
|
||||||
// };
|
// };
|
||||||
|
|
||||||
RUN: printf '\xfa\xd5\x8d\xe7\x36\x64\x95\xdb' >> %t.profraw // NameRef
|
RUN: printf '\254\275\030\333\114\302\370\134' >> %t.profraw
|
||||||
RUN: printf '\x18\0\0\0\0\0\0\0' >> %t.profraw // FuncHash
|
RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw // RelativeCounterPtr
|
RUN: printf '\0\0\4\0\1\0\0\0' >> %t.profraw
|
||||||
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
|
||||||
RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Values
|
RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw // NumCounters and NumValueSites
|
|
||||||
|
|
||||||
// Counter section
|
|
||||||
RUN: printf '\1\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 '\023\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x04\x0c\x78\xda\xcb\x4d\xcc\xcc' >> %t.profraw
|
RUN: printf '\3\0foo\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x03\x00\x04\x1b\x01\xa6\x00\x00' >> %t.profraw
|
|
||||||
|
|
||||||
// Write some garbage data at the end so we get "not enough space for another header" message
|
// Write some garbage data at the end so we get "not enough space for another header" message
|
||||||
RUN: printf '\x03\x00\' >> %t.profraw
|
RUN: printf '\x03\x00\' >> %t.profraw
|
||||||
|
|
||||||
RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s
|
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
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
|
// INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
|
||||||
|
|
||||||
RUN: printf '\201rforpl\377' > %t.profraw
|
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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\1\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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\1\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 '\0\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\xe\0\0\0\0\0\0\0' >> %t.profraw
|
RUN: printf '\10\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\xf8\xff\xff\xff\xff\xff\xff\xff' >> %t.profraw
|
RUN: printf '\0\0\4\0\1\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x89\x7a\x40\x00\x00\x00\x00\x00' >> %t.profraw
|
RUN: printf '\0\0\4\0\2\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
|
||||||
|
|
||||||
// Data Section
|
// Data Section
|
||||||
//
|
//
|
||||||
|
@ -30,20 +30,16 @@ RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
// #include "llvm/ProfileData/InstrProfData.inc"
|
// #include "llvm/ProfileData/InstrProfData.inc"
|
||||||
// };
|
// };
|
||||||
|
|
||||||
RUN: printf '\xfa\xd5\x8d\xe7\x36\x64\x95\xdb' >> %t.profraw // NameRef
|
RUN: printf '\254\275\030\333\114\302\370\134' >> %t.profraw
|
||||||
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 '\1\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\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 '\023\0\0\0\0\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x04\x0c\x78\xda\xcb\x4d\xcc\xcc' >> %t.profraw
|
RUN: printf '\3\0foo\0\0\0' >> %t.profraw
|
||||||
RUN: printf '\x03\x00\x04\x1b\x01\xa6\x00\x00' >> %t.profraw
|
|
||||||
|
|
||||||
RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s
|
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
|
||||||
|
|
|
@ -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: printf '\3\0bar\0\0\0' >> %t.profraw
|
||||||
|
|
||||||
RUN: not llvm-profdata merge -o /dev/null %t.profraw 2>&1 | FileCheck %s
|
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
|
CHECK: error: no profile can be merged
|
||||||
|
|
Loading…
Reference in New Issue