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

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

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

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
45

use full words, please, e.g. covered_functions

97

no {} in such code.

155

size_t?

157

<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>

164

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
193

printCoveredFunctions

218

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

227

no {}

245

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
164

Wouldn't that be slower?

218

why do we need not-demangled output?

kcc added inline comments.Nov 10 2015, 1:38 PM
lib/sanitizer_common/sancov.cc
165

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).

219

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
158

did you mean unordered_set?

163

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).

164

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.