<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 7, 2015 at 9:59 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This patch breaks a change that was sitting in my local workspace<div>because it breaks an assumption that all blocks in BlocksToInstrument will be instrumented. </div><div>A better place to check <span style="font-size:12.8000001907349px">isa<UnreachableInst> is in the place where we collect BlocksToInstrument, </span></div><div><span style="font-size:12.8000001907349px">i.e. in runOnFunction. </span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">I'll make this change together with my other change. </span></div></div></blockquote><div><br></div><div>Ok... There is no such thing as "BlocksToInstrument" in trunk now. But watch out the ugly InjectCoverage</div><div>function, though - it doesn't use "AllBlocks" in -fsanitize-coverage=1 mode, and just unconditionally takes F.getEntryBlock().</div><div>I'd rather delete this function completely - its return value is never used, and it's weird to collect AllBlocks/BlocksToInstrument for</div><div>lower -fsanitize-coverage levels, if we're not going to use them later.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8000001907349px"><br></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 30, 2015 at 4:11 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: samsonov<br>
Date: Tue Jun 30 18:11:45 2015<br>
New Revision: 241127<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241127-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=WLX0Re8mYT7a6AntAG9hVCp6olckIQYd-IoAicjpCAQ&s=2kq3YsQXHgr-Qs1mubPf6aErVoGkV-qJS7ymp-riNzs&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241127&view=rev</a><br>
Log:<br>
[SanitizerCoverage] Don't add instrumentation to unreachable blocks.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp<br>
    llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Transforms_Instrumentation_SanitizerCoverage.cpp-3Frev-3D241127-26r1-3D241126-26r2-3D241127-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=WLX0Re8mYT7a6AntAG9hVCp6olckIQYd-IoAicjpCAQ&s=CqIm3Ym3u0ArcVRQNGnvfiFQRNjopaQ7NaqYGKCw5lE&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=241127&r1=241126&r2=241127&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Tue Jun 30 18:11:45 2015<br>
@@ -375,6 +375,13 @@ void SanitizerCoverageModule::SetNoSanit<br>
<br>
 void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB,<br>
                                                     bool UseCalls) {<br>
+  // Don't insert coverage for unreachable blocks: we will never call<br>
+  // __sanitizer_cov() for them, so counting them in<br>
+  // NumberOfInstrumentedBlocks() might complicate calculation of code coverage<br>
+  // percentage. Also, unreachable instructions frequently have no debug<br>
+  // locations.<br>
+  if (isa<UnreachableInst>(BB.getTerminator()))<br>
+    return;<br>
   BasicBlock::iterator IP = BB.getFirstInsertionPt(), BE = BB.end();<br>
   // Skip static allocas at the top of the entry block so they don't become<br>
   // dynamic when we split the block.  If we used our optimized stack layout,<br>
<br>
Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Instrumentation_SanitizerCoverage_coverage.ll-3Frev-3D241127-26r1-3D241126-26r2-3D241127-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=WLX0Re8mYT7a6AntAG9hVCp6olckIQYd-IoAicjpCAQ&s=1ChBK5qrLlmDnstyENY2DAB6Xd2QGE4WV2zmHqKOodk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll?rev=241127&r1=241126&r2=241127&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll (original)<br>
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll Tue Jun 30 18:11:45 2015<br>
@@ -119,3 +119,12 @@ entry:<br>
 ; CHECK4: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE:.*]])<br>
 ; CHECK4-NOT: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE]])<br>
 ; CHECK4: ret void<br>
+<br>
+define void @call_unreachable() uwtable sanitize_address {<br>
+entry:<br>
+  unreachable<br>
+}<br>
+<br>
+; CHECK4-LABEL: define void @call_unreachable<br>
+; CHECK4-NOT: __sanitizer_cov<br>
+; CHECK4: unreachable<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>