This is an archive of the discontinued LLVM Phabricator instance.

[profiling] Improve error message for raw profile header mismatches
ClosedPublic

Authored by paquette on Apr 27 2023, 10:56 AM.

Details

Summary

When a user uses a mismatched clang + llvm-profdata, they didn't get a very informative error message. It would just say "unsupported version".

As a result, users are often confused as to what they are supposed to do and tend to assume that it's a bug in the profiling runtime.

This patch improves the error message by:

  • Adding a new class of error (raw_profile_version_mismatch) to make it clear that, specifically, the *raw profile* version is unsupported because of a tool mismatch.
  • Adding an error message that tells the user which raw profile version was encountered, which version was expected, and instructs them to align their tool versions.

To support this, this patch also updates InstrProfError::take to also propagate the optional error message.

Diff Detail

Event Timeline

paquette created this revision.Apr 27 2023, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2023, 10:56 AM
paquette requested review of this revision.Apr 27 2023, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2023, 10:56 AM
jroelofs accepted this revision.Apr 27 2023, 11:09 AM

LGTM

llvm/lib/ProfileData/InstrProfReader.cpp
540

Given how pervasive the problem is, maybe the error message should also link to the docs explaining what the compatibility guarantees are/are-not.

This revision is now accepted and ready to land.Apr 27 2023, 11:09 AM
paquette added inline comments.Apr 27 2023, 2:47 PM
llvm/lib/ProfileData/InstrProfReader.cpp
540

That's a good idea, but the docs are in Clang right now. I'll see if I can move them to LLVM or duplicate them there so that other compiler frontend users aren't confused.

llvm/tools/llvm-profdata/llvm-profdata.cpp
311–314

will remove this when I push

This revision was landed with ongoing or failed builds.Apr 27 2023, 2:52 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2023, 2:52 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Dinistro added inline comments.
llvm/unittests/ProfileData/InstrProfTest.cpp
1359

It seems that this and the following similar line do not compile. I assume that the necessary flags to activate this test were not provided in the CI executed for this revision.

Crashing build: https://lab.llvm.org/buildbot/#/builders/104/builds/11668/steps/6/logs/stdio

Dinistro added inline comments.Apr 28 2023, 5:19 AM
llvm/unittests/ProfileData/InstrProfTest.cpp
1359

I creatred and landed a revision that fixes this https://reviews.llvm.org/D149434

Sorry for the inconvenience and thanks for the fix!