This is an archive of the discontinued LLVM Phabricator instance.

[profile] Add interface to get profile filename
ClosedPublic

Authored by tejohnson on Jul 18 2018, 8:09 PM.

Details

Summary

Add __llvm_profile_get_filename interface to get the profile filename,
which can be used for identifying which profile file belongs to an app
when multiple binaries are instrumented and dumping profiles into the
same directory. The filename includes the path.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson created this revision.Jul 18 2018, 8:09 PM
Herald added subscribers: Restricted Project, delcypher. · View Herald TranscriptJul 18 2018, 8:09 PM
davidxl added inline comments.Jul 18 2018, 11:55 PM
lib/profile/InstrProfilingFile.c
529 ↗(On Diff #156206)

Why not directly passing the malloced buffer to getCurFilename?

tejohnson added inline comments.Jul 19 2018, 7:24 AM
lib/profile/InstrProfilingFile.c
529 ↗(On Diff #156206)

getCurFilename doesn't always use the provided FilenameBuf, only if it needs to substitute in a value to the filename pattern. If not, the FilenamePat is returned (note also that this code is modeled after __llvm_profile_get_path_prefix).

davidxl added inline comments.Jul 19 2018, 9:26 AM
lib/profile/InstrProfilingFile.c
529 ↗(On Diff #156206)

Perhaps add an additional argument to getCurFilename to force copying into the buffer?

tejohnson marked an inline comment as done.Jul 19 2018, 10:09 AM

Address comment

davidxl accepted this revision.Jul 19 2018, 10:19 AM

lgtm

lib/profile/InstrProfiling.h
177 ↗(On Diff #156305)

please also add a comment that if user calls __llvm_profile_set_filename later after this call, the actual file name may differ from what is returned here.

This revision is now accepted and ready to land.Jul 19 2018, 10:19 AM
tejohnson marked an inline comment as done.Jul 19 2018, 10:27 AM

Address comment

This revision was automatically updated to reflect the committed changes.