std::string Msg;
};
-class SoftInstrProfErrors {
- /// Count the number of soft instrprof_errors encountered and keep track of
- /// the first such error for reporting purposes.
-
- /// The first soft error encountered.
- instrprof_error FirstError = instrprof_error::success;
-
- /// The number of hash mismatches.
- unsigned NumHashMismatches = 0;
-
- /// The number of count mismatches.
- unsigned NumCountMismatches = 0;
-
- /// The number of counter overflows.
- unsigned NumCounterOverflows = 0;
-
- /// The number of value site count mismatches.
- unsigned NumValueSiteCountMismatches = 0;
-
-public:
- SoftInstrProfErrors() = default;
-
- ~SoftInstrProfErrors() {
- assert(FirstError == instrprof_error::success &&
- "Unchecked soft error encountered");
- }
-
- /// Track a soft error (\p IE) and increment its associated counter.
- void addError(instrprof_error IE);
-
- /// Get the number of hash mismatches.
- unsigned getNumHashMismatches() const { return NumHashMismatches; }
-
- /// Get the number of count mismatches.
- unsigned getNumCountMismatches() const { return NumCountMismatches; }
-
- /// Get the number of counter overflows.
- unsigned getNumCounterOverflows() const { return NumCounterOverflows; }
-
- /// Get the number of value site count mismatches.
- unsigned getNumValueSiteCountMismatches() const {
- return NumValueSiteCountMismatches;
- }
-
- /// Return the first encountered error and reset FirstError to a success
- /// value.
- Error takeError() {
- if (FirstError == instrprof_error::success)
- return Error::success();
- auto E = make_error<InstrProfError>(FirstError);
- FirstError = instrprof_error::success;
- return E;
- }
-};
-
namespace object {
class SectionRef;
return SectName;
}
-void SoftInstrProfErrors::addError(instrprof_error IE) {
- if (IE == instrprof_error::success)
- return;
-
- if (FirstError == instrprof_error::success)
- FirstError = IE;
-
- switch (IE) {
- case instrprof_error::hash_mismatch:
- ++NumHashMismatches;
- break;
- case instrprof_error::count_mismatch:
- ++NumCountMismatches;
- break;
- case instrprof_error::counter_overflow:
- ++NumCounterOverflows;
- break;
- case instrprof_error::value_site_count_mismatch:
- ++NumValueSiteCountMismatches;
- break;
- default:
- llvm_unreachable("Not a soft error");
- }
-}
-
std::string InstrProfError::message() const {
return getInstrProfErrString(Err, Msg);
}