This is an archive of the discontinued LLVM Phabricator instance.

[PGO] Value profiling text format reader/writer support
ClosedPublic

Authored by davidxl on Dec 3 2015, 3:05 PM.

Details

Summary

This patch adds the missing functionality in parsable text format support for value profiling.

Diff Detail

Event Timeline

davidxl updated this revision to Diff 41810.Dec 3 2015, 3:05 PM
davidxl retitled this revision from to [PGO] Value profiling text format reader/writer support.
davidxl updated this object.
davidxl added reviewers: vsk, betulb.
davidxl added a subscriber: llvm-commits.
vsk edited edge metadata.Dec 10 2015, 5:34 PM

Sorry for the latency, comments inline --

lib/ProfileData/InstrProfReader.cpp
107–109

I'd prefer to keep format changes for separate NFC commits.

127

This looks correct but a bit repetitive. What do you think of using a macro like:

#define AdvanceAndReadInt(Line, Dst) \
    if ((Line).is_at_end()) \
        return error(instrprof_error::truncated); \
    if (((Line)++)->getAsInteger(10, (Dst)))
        return error(instrprof_error::truncated); \

You could move the various "uint32_t" definitions up, or define them within the macro.

207

This could use a comment like "// Check if we have value profile data, and if so, read it.".

test/tools/llvm-profdata/Inputs/vp-malform.proftext
6

I don't think these input files should have RUN lines.

44

It's not obvious that this is the error. Please add notes to your tests which make it clear what's being tested.

49

Ditto for CHECK lines.

test/tools/llvm-profdata/Inputs/vp-malform2.proftext
6

Same comments from the last file.

Could you trim this file down a bit? It seems very similar to the last one.

test/tools/llvm-profdata/Inputs/vp-truncate.proftext
6

Same note about the RUN lines.

davidxl marked 5 inline comments as done.Dec 12 2015, 3:55 PM
davidxl added inline comments.
lib/ProfileData/InstrProfReader.cpp
107–109

This was fixed already.

127

good suggestion.

test/tools/llvm-profdata/Inputs/vp-malform.proftext
44

Added a comment before the malformed line

davidxl updated this revision to Diff 42643.Dec 12 2015, 3:58 PM
davidxl edited edge metadata.

Update the patch addressing vsk's comments.

vsk added a comment.Dec 14 2015, 8:53 AM

Thanks, lgtm with two minor changes.

lib/ProfileData/InstrProfReader.cpp
112

Could you move these inside readValueProfileData and #undef them at the end of the function?

113

These macro function arguments should be wrapped in parens.

Done.

thanks,

David

This revision was automatically updated to reflect the committed changes.