[PATCH] D53039: [sancov] Generalize the code to get the previous instruction to multiple architectures
George Karpenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 9 17:59:32 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344103: [sancov] Generalize the code to get the previous instruction to multiple… (authored by george.karpenkov, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D53039?vs=168865&id=168929#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53039
Files:
llvm/trunk/tools/sancov/sancov.cpp
Index: llvm/trunk/tools/sancov/sancov.cpp
===================================================================
--- llvm/trunk/tools/sancov/sancov.cpp
+++ llvm/trunk/tools/sancov/sancov.cpp
@@ -766,6 +766,19 @@
return Result;
}
+static uint64_t getPreviousInstructionPc(uint64_t PC,
+ Triple TheTriple) {
+ if (TheTriple.isARM()) {
+ return (PC - 3) & (~1);
+ } else if (TheTriple.isAArch64()) {
+ return PC - 4;
+ } else if (TheTriple.isMIPS()) {
+ return PC - 8;
+ } else {
+ return PC - 1;
+ }
+}
+
// Locate addresses of all coverage points in a file. Coverage point
// is defined as the 'address of instruction following __sanitizer_cov
// call - 1'.
@@ -832,7 +845,7 @@
}
uint64_t Addr = Index + SectionAddr;
// Sanitizer coverage uses the address of the next instruction - 1.
- uint64_t CovPoint = Addr + Size - 1;
+ uint64_t CovPoint = getPreviousInstructionPc(Addr + Size, TheTriple);
uint64_t Target;
if (MIA->isCall(Inst) &&
MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53039.168929.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181010/7ff67c53/attachment.bin>
More information about the llvm-commits
mailing list