[PATCH] D58740: [sancov] Instrument reachable blocks that end in unreachable
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 28 14:53:47 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355152: [sancov] Instrument reachable blocks that end in unreachable (authored by rnk, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58740?vs=188629&id=188796#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58740/new/
https://reviews.llvm.org/D58740
Files:
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
Index: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -454,12 +454,12 @@
const DominatorTree *DT,
const PostDominatorTree *PDT,
const SanitizerCoverageOptions &Options) {
- // Don't insert coverage for unreachable blocks: we will never call
- // __sanitizer_cov() for them, so counting them in
+ // Don't insert coverage for blocks containing nothing but unreachable: 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()))
+ if (isa<UnreachableInst>(BB->getFirstNonPHIOrDbgOrLifetime()))
return false;
// Don't insert coverage into blocks without a valid insertion point
Index: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
===================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
@@ -23,6 +23,19 @@
ret void
}
+declare void @longjmp(i8*) noreturn
+
+; We expect three coverage points here for each BB.
+define void @cond_longjmp(i1 %cond, i8* %jmp_buf) sanitize_address {
+entry:
+ br i1 %cond, label %lj, label %done
+done:
+ ret void
+lj:
+ call void @longjmp(i8* %jmp_buf)
+ unreachable
+}
+
; CHECK_PC-LABEL: define void @foo
; CHECK_PC: call void @__sanitizer_cov_trace_pc
@@ -31,6 +44,13 @@
; CHECK_PC-NOT: call void @__sanitizer_cov_trace_pc
; CHECK_PC: ret void
; CHECK_PC-NOT: call void @__sanitizer_cov_module_init
+; CHECK_PC-LABEL: @cond_longjmp
+; CHECK_PC: call void @__sanitizer_cov_trace_pc
+; CHECK_PC: call void @__sanitizer_cov_trace_pc
+; CHECK_PC: ret void
+; CHECK_PC: call void @__sanitizer_cov_trace_pc
+; CHECK_PC: call void @longjmp
+; CHECK_PC: unreachable
; CHECK_PC_GUARD: section "__sancov_guards", comdat($foo), align 4
; CHECK_PC_GUARD-LABEL: define void @foo
@@ -42,6 +62,13 @@
; CHECK_PC_GUARD-LABEL: @external_bar
; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
; CHECK_PC_GUARD: ret void
+; CHECK_PC_GUARD-LABEL: @cond_longjmp
+; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
+; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
+; CHECK_PC_GUARD: ret void
+; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
+; CHECK_PC_GUARD: call void @longjmp
+; CHECK_PC_GUARD: unreachable
; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @__start___sancov_guards to i32*), i32* bitcast (i32** @__stop___sancov_guards to i32*))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58740.188796.patch
Type: text/x-patch
Size: 2996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190228/4e5bef42/attachment.bin>
More information about the llvm-commits
mailing list