diff options
author | Reid Kleckner <rnk@google.com> | 2017-03-23 23:30:41 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-03-23 23:30:41 +0000 |
commit | 392f0626754d9ebf07bb2bdb3b6b04f12feb5025 (patch) | |
tree | 6b6b43bec1c05711f3d9352487535f8d060940b5 /llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | |
parent | b197d5b0a00747c0b6d8f82a275f871f3c9240c2 (diff) | |
download | bcm5719-llvm-392f0626754d9ebf07bb2bdb3b6b04f12feb5025.tar.gz bcm5719-llvm-392f0626754d9ebf07bb2bdb3b6b04f12feb5025.zip |
[sancov] Don't instrument blocks with no insertion point
This prevents crashes when attempting to instrument functions containing
C++ try.
Sanitizer coverage will still fail at runtime when an exception is
thrown through a sancov instrumented function, but that seems marginally
better than what we have now. The full solution is to color the blocks
in LLVM IR and only instrument blocks that have an unambiguous color,
using the appropriate token.
llvm-svn: 298662
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 8f7ac9c971e..59a926150ff 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -445,6 +445,11 @@ static bool shouldInstrumentBlock(const Function& F, const BasicBlock *BB, const if (isa<UnreachableInst>(BB->getTerminator())) return false; + // Don't insert coverage into blocks without a valid insertion point + // (catchswitch blocks). + if (BB->getFirstInsertionPt() == BB->end()) + return false; + if (!ClPruneBlocks || &F.getEntryBlock() == BB) return true; |