[PATCH] D119233: [sancov][sanitizer-common] Correct sanitizer coverage point
Xiaodong Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 8 04:25:57 PST 2022
XiaodongLoong created this revision.
Herald added subscribers: dexonsmith, fedor.sergeev.
XiaodongLoong requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
Sanitizer coverage point should be the previous instruction PC of the
caller and the offset to the previous instruction might be different
on each CPU architecture.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119233
Files:
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
llvm/include/llvm/ADT/Triple.h
llvm/tools/sancov/sancov.cpp
Index: llvm/tools/sancov/sancov.cpp
===================================================================
--- llvm/tools/sancov/sancov.cpp
+++ llvm/tools/sancov/sancov.cpp
@@ -691,9 +691,9 @@
Triple TheTriple) {
if (TheTriple.isARM()) {
return (PC - 3) & (~1);
- } else if (TheTriple.isAArch64()) {
+ } else if (TheTriple.isAArch64() || TheTriple.isPPC()) {
return PC - 4;
- } else if (TheTriple.isMIPS()) {
+ } else if (TheTriple.isMIPS() || TheTriple.isSparc()) {
return PC - 8;
} else {
return PC - 1;
Index: llvm/include/llvm/ADT/Triple.h
===================================================================
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -775,6 +775,12 @@
return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
}
+ /// Tests whether the target is Sparc.
+ bool isSparc() const {
+ return getArch() == Triple::sparc || getArch() == Triple::sparcv9 ||
+ getArch() == Triple::sparcel;
+ }
+
/// Tests whether the target is SystemZ.
bool isSystemZ() const {
return getArch() == Triple::systemz;
Index: compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
@@ -14,7 +14,8 @@
#include "sanitizer_allocator_internal.h"
#include "sanitizer_atomic.h"
#include "sanitizer_common.h"
-#include "sanitizer_file.h"
+# include "sanitizer_common/sanitizer_stacktrace.h"
+# include "sanitizer_file.h"
using namespace __sanitizer;
@@ -222,7 +223,8 @@
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard, u32* guard) {
if (!*guard) return;
- __sancov::pc_guard_controller.TracePcGuard(guard, GET_CALLER_PC() - 1);
+ __sancov::pc_guard_controller.TracePcGuard(
+ guard, StackTrace::GetPreviousInstructionPc(GET_CALLER_PC()));
}
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard_init,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119233.406769.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220208/d40ad52f/attachment.bin>
More information about the llvm-commits
mailing list