This is an archive of the discontinued LLVM Phabricator instance.

[PGO] Refactor common profile dumping code for File and Buffer API
ClosedPublic

Authored by davidxl on Nov 15 2015, 10:31 PM.

Details

Summary

The implementation of the buffer API and File API share almost identical code causing lots of duplicate update work. This patch refactors the implementation using a writer callback mechanism.

Diff Detail

Event Timeline

davidxl updated this revision to Diff 40249.Nov 15 2015, 10:31 PM
davidxl retitled this revision from to [PGO] Refactor common profile dumping code for File and Buffer API.
davidxl updated this object.
davidxl added a reviewer: vsk.
davidxl added a subscriber: llvm-commits.
vsk edited edge metadata.Nov 16 2015, 9:34 AM

Thanks, just a few nits --

lib/profile/InstrProfilingBuffer.c
44–50

ElmS -> ElmSize?

44–50

C code in compiler-rt looks like it uses all lowercase and "_" separators in function names. We should preserve that style.

lib/profile/InstrProfilingFile.c
20–22

Same ElmS nit

lib/profile/InstrProfilingWriter.c
58

CHECK_fwrite -> CHECK_write

davidxl marked 3 inline comments as done.Nov 16 2015, 10:55 AM
davidxl added inline comments.
lib/profile/InstrProfilingBuffer.c
44–50

yes public C APIs are all lower cases, but these two new functions are internal APIs (just like existing functions like writeFile etc). They have global linkage mainly because the cross module references.

davidxl updated this revision to Diff 40311.Nov 16 2015, 10:56 AM
davidxl edited edge metadata.

Updated patch according to Vedant's comments.

vsk added a comment.Nov 16 2015, 12:33 PM

Lgtm.

lib/profile/InstrProfilingBuffer.c
44–50

Ah ok

This revision was automatically updated to reflect the committed changes.