This is an archive of the discontinued LLVM Phabricator instance.

[profile] clean up file handling code
ClosedPublic

Authored by davidxl on May 24 2016, 9:51 AM.

Details

Reviewers
vsk
Summary
  1. Split file name setting code into two parts -- parsing code and the getter code
  2. better warning/error handling
  3. Removed the last dependence on malloc in profile runtime (the default path)

Diff Detail

Event Timeline

davidxl updated this revision to Diff 58254.May 24 2016, 9:51 AM
davidxl retitled this revision from to [profile] clean up file handling code.
davidxl updated this object.
davidxl added a reviewer: vsk.
davidxl added a subscriber: llvm-commits.
davidxl updated this revision to Diff 58270.May 24 2016, 10:37 AM

Add check in caller of file name parser.

vsk edited edge metadata.May 24 2016, 10:53 AM

Nice, thanks.

lib/profile/InstrProfilingFile.c
88

nit, This sounds like a name for a boolean. How about FilenameBuf?

112–117

This is a behavior change, right? Do we really only want to truncate profiles if the filename pattern changes?

126

Could you use strncpy?

129

^ Same comment

152

nit, Use -> Using

161

^ Same nit

davidxl marked 5 inline comments as done.May 24 2016, 12:07 PM
davidxl added inline comments.
lib/profile/InstrProfilingFile.c
112–118

there is no change. If the pattern str changes, the filename will also change which requires truncation in previous implementation.

davidxl updated this revision to Diff 58288.May 24 2016, 12:08 PM
davidxl edited edge metadata.

Addressed review feedbacks.

vsk accepted this revision.May 24 2016, 12:50 PM
vsk edited edge metadata.
vsk added inline comments.
lib/profile/InstrProfilingFile.c
112–118

Got it, silly mistake on my part.

This revision is now accepted and ready to land.May 24 2016, 12:50 PM
MatzeB added a subscriber: MatzeB.May 24 2016, 2:54 PM
MatzeB added inline comments.
lib/profile/InstrProfilingFile.c
129

Note that strncpy is a really silly function: If you actually happen to write n or more characters you will not have a terminating '\0' character... My personal rule is to never use strncpy() but something like snprintf(buf, bufsize, "%s%s", one, two);

vsk closed this revision.Aug 1 2016, 6:16 PM

Done in compiler-rt/r270617