This is an archive of the discontinued LLVM Phabricator instance.

[ProfileData] Add unit test infrastructure for sample profile reader/writer
ClosedPublic

Authored by slingn on Dec 3 2015, 2:57 PM.

Details

Summary

Adds support for in-memory round-trip of sample profile data along with basic
round trip unit tests. This will also make it easier to include unit tests for
future changes to sample profiling.

Diff Detail

Repository
rL LLVM

Event Timeline

slingn updated this revision to Diff 41807.Dec 3 2015, 2:57 PM
slingn retitled this revision from to [ProfileData] Add unit test infrastructure for sample profile reader/writer.
slingn updated this object.
slingn added reviewers: davidxl, dnovillo, silvas.
slingn added a subscriber: llvm-commits.
davidxl added inline comments.Dec 3 2015, 3:50 PM
include/llvm/ProfileData/SampleProfReader.h
270 ↗(On Diff #41807)

///

include/llvm/ProfileData/SampleProfWriter.h
32 ↗(On Diff #41807)

Is this constructor redundant now?

silvas added inline comments.Dec 3 2015, 5:37 PM
unittests/ProfileData/SampleProfTest.cpp
31 ↗(On Diff #41807)

Can you just hold this by value?

slingn updated this revision to Diff 42230.Dec 8 2015, 2:29 PM
slingn marked 3 inline comments as done.

Updated for davidxl and silvas comments.

include/llvm/ProfileData/SampleProfWriter.h
32 ↗(On Diff #41807)

Yes - we should be able to just use the stream interface.

unittests/ProfileData/SampleProfTest.cpp
31 ↗(On Diff #41807)

Yes...that implies that SampleProfileWriter::create() should take a raw_ostream & rather than unique_ptr<raw_ostream> in that case. And that means that a caller of SampleProfileWriter::create() owns the output stream rather than the writer.

davidxl added inline comments.Dec 9 2015, 2:39 PM
include/llvm/ProfileData/SampleProfWriter.h
32 ↗(On Diff #42230)

Should it be protected?

61 ↗(On Diff #42230)

why changing this interface? It is not like the stream based create method is used multiple different places.

slingn marked 2 inline comments as done.Dec 9 2015, 4:44 PM
slingn added inline comments.
include/llvm/ProfileData/SampleProfWriter.h
61 ↗(On Diff #42230)

OK. Having a reference to the ostream (and caller owning it) would be slightly cleaner but precludes us having a factory method that takes a file name since somebody has to own the ostream.

I'll put that back and switch back to unique_ptr<raw_ostream>.

slingn updated this revision to Diff 42358.Dec 9 2015, 4:56 PM
slingn marked an inline comment as done.

Updated for davidxl's comments.

Reverted to unique_ptr<raw_ostream> interface and put back SampleProfWriter file path factory function.

davidxl accepted this revision.Dec 9 2015, 5:08 PM
davidxl edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 9 2015, 5:08 PM
This revision was automatically updated to reflect the committed changes.