This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profdata] Handle the cases of overlapping input file and output file
ClosedPublic

Authored by xur on Jul 8 2019, 12:01 PM.

Details

Summary

Currently llvm-profdata does not expect the same file name for the input profile
and the output profile.
>llvm-profdata merge A.profraw B.profraw -o B.profraw
The above command runs successfully but the resulted B.profraw is not correct.
This patch fixes the issue by moving the initialization of writer after loading
the profile.

For the show command, the following will report a confusing error of
"Empty raw profile file":
>llvm-profdata show B.profraw -o B.profraw
It's harder to fix as we need to output something before loading the input profile.
I don't think that a fix for this is worth the effort. I just make the error explicit for
the show command.

Diff Detail

Event Timeline

xur created this revision.Jul 8 2019, 12:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2019, 12:01 PM
davidxl added inline comments.Jul 8 2019, 12:14 PM
llvm/tools/llvm-profdata/llvm-profdata.cpp
1024

Use the same error reporting format:

errs() << ProgName << ": " << ReasonString <<"!\n";

xur updated this revision to Diff 208483.Jul 8 2019, 12:52 PM

Change the error report format suggested by David.

davidxl accepted this revision.Jul 8 2019, 1:05 PM

lgtm

This revision is now accepted and ready to land.Jul 8 2019, 1:05 PM
This revision was automatically updated to reflect the committed changes.