[llvm] r241127 - [SanitizerCoverage] Don't add instrumentation to unreachable blocks.

Alexey Samsonov vonosmas at gmail.com
Tue Jul 7 12:13:40 PDT 2015


On Tue, Jul 7, 2015 at 9:59 AM, Kostya Serebryany <kcc at google.com> wrote:

> This patch breaks a change that was sitting in my local workspace
> because it breaks an assumption that all blocks in BlocksToInstrument will
> be instrumented.
> A better place to check isa<UnreachableInst> is in the place where we
> collect BlocksToInstrument,
> i.e. in runOnFunction.
>
> I'll make this change together with my other change.
>

Ok... There is no such thing as "BlocksToInstrument" in trunk now. But
watch out the ugly InjectCoverage
function, though - it doesn't use "AllBlocks" in -fsanitize-coverage=1
mode, and just unconditionally takes F.getEntryBlock().
I'd rather delete this function completely - its return value is never
used, and it's weird to collect AllBlocks/BlocksToInstrument for
lower -fsanitize-coverage levels, if we're not going to use them later.


>
>
> On Tue, Jun 30, 2015 at 4:11 PM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
>
>> Author: samsonov
>> Date: Tue Jun 30 18:11:45 2015
>> New Revision: 241127
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=241127&view=rev
>> Log:
>> [SanitizerCoverage] Don't add instrumentation to unreachable blocks.
>>
>> Modified:
>>     llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>>     llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll
>>
>> Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=241127&r1=241126&r2=241127&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>> (original)
>> +++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Tue
>> Jun 30 18:11:45 2015
>> @@ -375,6 +375,13 @@ void SanitizerCoverageModule::SetNoSanit
>>
>>  void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F,
>> BasicBlock &BB,
>>                                                      bool UseCalls) {
>> +  // Don't insert coverage for unreachable blocks: we will never call
>> +  // __sanitizer_cov() for them, so counting them in
>> +  // NumberOfInstrumentedBlocks() might complicate calculation of code
>> coverage
>> +  // percentage. Also, unreachable instructions frequently have no debug
>> +  // locations.
>> +  if (isa<UnreachableInst>(BB.getTerminator()))
>> +    return;
>>    BasicBlock::iterator IP = BB.getFirstInsertionPt(), BE = BB.end();
>>    // Skip static allocas at the top of the entry block so they don't
>> become
>>    // dynamic when we split the block.  If we used our optimized stack
>> layout,
>>
>> Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll?rev=241127&r1=241126&r2=241127&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll
>> (original)
>> +++ llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll Tue Jun
>> 30 18:11:45 2015
>> @@ -119,3 +119,12 @@ entry:
>>  ; CHECK4: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE:.*]])
>>  ; CHECK4-NOT: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE]])
>>  ; CHECK4: ret void
>> +
>> +define void @call_unreachable() uwtable sanitize_address {
>> +entry:
>> +  unreachable
>> +}
>> +
>> +; CHECK4-LABEL: define void @call_unreachable
>> +; CHECK4-NOT: __sanitizer_cov
>> +; CHECK4: unreachable
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>


-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150707/57df35c5/attachment.html>


More information about the llvm-commits mailing list