[llvm] 1ec9dd3 - [sancov] Refactor getPreviousInstructionPc
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 16:30:06 PST 2022
Author: Fangrui Song
Date: 2022-02-22T16:30:02-08:00
New Revision: 1ec9dd3aae0b8c90a91f845ad629ef7d199986c0
URL: https://github.com/llvm/llvm-project/commit/1ec9dd3aae0b8c90a91f845ad629ef7d199986c0
DIFF: https://github.com/llvm/llvm-project/commit/1ec9dd3aae0b8c90a91f845ad629ef7d199986c0.diff
LOG: [sancov] Refactor getPreviousInstructionPc
Note: on some architectures lik AArch64, the PC does not match
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp:`__sanitizer_cov_trace_pc_guard`
Added:
Modified:
llvm/tools/sancov/sancov.cpp
Removed:
################################################################################
diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index c997154bac47c..9a523984df75d 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -687,17 +687,20 @@ findSanitizerCovFunctions(const object::ObjectFile &O) {
return Result;
}
+// Ported from
+// compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h:GetPreviousInstructionPc
+// GetPreviousInstructionPc.
static uint64_t getPreviousInstructionPc(uint64_t PC,
Triple TheTriple) {
- if (TheTriple.isARM()) {
+ if (TheTriple.isARM())
return (PC - 3) & (~1);
- } else if (TheTriple.isAArch64()) {
- return PC - 4;
- } else if (TheTriple.isMIPS()) {
+ if (TheTriple.isMIPS())
return PC - 8;
- } else {
+ if (TheTriple.isRISCV())
+ return PC - 2;
+ if (TheTriple.isX86())
return PC - 1;
- }
+ return PC - 4;
}
// Locate addresses of all coverage points in a file. Coverage point
More information about the llvm-commits
mailing list