This is an archive of the discontinued LLVM Phabricator instance.

Sancov in C++.
ClosedPublic

Authored by aizatsky on Nov 4 2015, 3:57 PM.

Details

Summary

First batch of sancov.py rewrite in C++.
Supports "-print" and "-coveredfns" commands.

Diff Detail

Repository
rL LLVM

Event Timeline

aizatsky updated this revision to Diff 39282.Nov 4 2015, 3:57 PM
aizatsky retitled this revision from to Sancov in C++..
aizatsky updated this object.
aizatsky updated this revision to Diff 39284.Nov 4 2015, 4:07 PM
  • cleanup
aizatsky added a reviewer: kcc.Nov 4 2015, 4:07 PM
aizatsky added a subscriber: llvm-commits.
kcc edited edge metadata.Nov 4 2015, 4:19 PM

is a test possible here?

lib/sanitizer_common/sancov.cc
86 ↗(On Diff #39284)

I wonder if you can reuse functionality from clang/Basic/FileManager.h
It's rather sad that we need to re-implement such basic stuff here.

silvas added a subscriber: silvas.Nov 4 2015, 9:13 PM
silvas added inline comments.
lib/sanitizer_common/sancov.cc
86 ↗(On Diff #39284)

There's a FIXME on FileManager::removeDotPaths saying FIXME: Move this to llvm::sys::path. so I think now is a perfect time to address that FIXME.

aizatsky updated this revision to Diff 39732.Nov 9 2015, 11:55 AM
aizatsky edited edge metadata.

merge

Updated to use remove_dots utility fn.

kcc added a comment.Nov 9 2015, 3:29 PM

more to follow

lib/sanitizer_common/sancov.cc
44 ↗(On Diff #39732)

use full words, please, e.g. covered_functions

96 ↗(On Diff #39732)

no {} in such code.

154 ↗(On Diff #39732)

size_t?

156 ↗(On Diff #39732)

<optional> I am not a huge fan of lambda functions when they don't save code or make it more readable.
Will it not be shorter *and* simpler to write regular loop here? </optional>

163 ↗(On Diff #39732)

won't it be simpler to insert everything into a set, and they copy into a vector?

kcc added inline comments.Nov 9 2015, 3:57 PM
lib/sanitizer_common/sancov.cc
192 ↗(On Diff #39732)

printCoveredFunctions

217 ↗(On Diff #39732)

not necessary in this change, but we'll need an option for demangling, similar to "-functions" option of llvm-symbolizer

226 ↗(On Diff #39732)

no {}

244 ↗(On Diff #39732)

no {}

aizatsky updated this revision to Diff 39818.Nov 10 2015, 9:46 AM
aizatsky marked 7 inline comments as done.

review

All done. PTAL.

lib/sanitizer_common/sancov.cc
163 ↗(On Diff #39732)

Wouldn't that be slower?

217 ↗(On Diff #39732)

why do we need not-demangled output?

kcc added inline comments.Nov 10 2015, 1:38 PM
lib/sanitizer_common/sancov.cc
164 ↗(On Diff #39818)

First, speed is not important here, code simplicity is much more so.

Second, I actually think it might be faster in case you need to merge lots of coverage files.
Your current code reserves vector for the total combined size of all the files.
Using set you will only need memory proportional to the result (yes, with a large multiplicative constant).

218 ↗(On Diff #39818)

Sometimes you may need to pass this further to some scripts and there is no way to un-demangle function names back.
Sometimes the fully demangled names are too long and we need "short names"

aizatsky updated this revision to Diff 39854.Nov 10 2015, 2:48 PM
aizatsky marked 2 inline comments as done.

review

added flag & using set.

kcc added inline comments.Nov 10 2015, 2:54 PM
lib/sanitizer_common/sancov.cc
157 ↗(On Diff #39854)

did you mean unordered_set?

162 ↗(On Diff #39854)

I wouldn't bother with reserve, but I would actually use set, not an unordered_set so that the resulting PCs are sorted (just in case).

163 ↗(On Diff #39854)

no {}

aizatsky marked 3 inline comments as done.Nov 10 2015, 3:07 PM

all done.

kcc accepted this revision.Nov 10 2015, 5:27 PM
kcc edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 10 2015, 5:27 PM
This revision was automatically updated to reflect the committed changes.