<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">+ Max<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 10, 2018, at 1:25 PM, Harp, Thom via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">Compared to LLVM’s gcov-compatible coverage method, SBCC’s resource requirements are much bigger.  The total size of all .profraw files from my system is almost 1GB while the same system,</span></div></div></div></blockquote><div><br class=""></div><div>Have you tried enabling run-time raw profile merging with "%Nm" (<a href="https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program" class="">https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program</a>)?</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""> built for gcov, totals only 150MB of .gcda files.  I removed emitEmptyMapping from CoverageMapping.cpp to see what happens,</span></div></div></div></blockquote><div><br class=""></div><div>Some engineers working on Chromium tried something similar using an experimental cl::opt (-limited-coverage-experimental) which may have a comparable same effect. I've CC'd Max who may be able to say more about this.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""> and the SBCC coverage dumps dropped from 1GB to about 26MB.  There are also significant gains in runtime memory use and on-disk image size.<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class="">I don’t mind losing the zero counts for code that is unused</span></div></div></div></blockquote><div><br class=""></div><div>In this case, I'd suggest trying the cl::opt I mentioned above, with the caveat that it can skew coverage reporting quite a bit.</div><div><br class=""></div><div>IMO having some mapping information for unused code is arguably one of the more important use cases for coverage reporting.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""> but I want to understand how clang determines what’s used and what isn’t.</span></div></div></div></blockquote><div><br class=""></div><span class="">See AddDeferredUnusedCoverageMapping, ClearUnusedCoverageMapping, and EmitDeferredUnusedCoverageMappings. I'm not the original author so I might not have this totally right, but I think the idea here is that:</span></div><div><span class=""><br class=""></span></div><span class="">- In CodeGenModule::EmitTopLevelDecl, we might not be sure a Decl actually needs to be emitted, so we mark it as deferred for coverage reporting purposes. If we never generate code for it, we'd emit a simple empty coverage mapping.<br class=""></span><span class=""><br class=""></span><span class="">- If it turns out that a Decl marked as deferred is actually emitted, we clear the deferred bit, because we no longer want an empty mapping.</span><div class=""><span class=""><br class=""></span></div><div class=""><span class="">best,</span></div><div class=""><span class="">vedant<br class=""></span><span class=""><br class=""><br class=""><blockquote type="cite" class="">  I traced the decision up to CodeGenPGO::assignRegionCounters in CodeGenPGO.cpp, where implicit functions and some constructor/destructor variants are eliminated but I can’t explain the bulk of it.<br class=""> <br class="">Can someone help me understand how clang determines what code is used and what isn’t in this context?<br class=""> <br class="">Thanks.<br class="">-thom<br class=""> <br class="">_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></blockquote></span><br class=""></div></body></html>