[PATCH] D120432: [sanitizer][sancov] Use pc-1 for s390x

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 12:49:36 PST 2022


MaskRay created this revision.
MaskRay added reviewers: uweigand, vitalybuka.
MaskRay requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

The stack trace addresses may be odd (normally addresses should be even), but
seems a good compromise when the instruction length (2,4,6) cannot be detected
easily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120432

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
  compiler-rt/test/tsan/test.h
  llvm/tools/sancov/sancov.cpp


Index: llvm/tools/sancov/sancov.cpp
===================================================================
--- llvm/tools/sancov/sancov.cpp
+++ llvm/tools/sancov/sancov.cpp
@@ -698,7 +698,7 @@
     return PC - 8;
   if (TheTriple.isRISCV())
     return PC - 2;
-  if (TheTriple.isX86())
+  if (TheTriple.isX86() || TheTriple.isSystemZ())
     return PC - 1;
   return PC - 4;
 }
Index: compiler-rt/test/tsan/test.h
===================================================================
--- compiler-rt/test/tsan/test.h
+++ compiler-rt/test/tsan/test.h
@@ -69,13 +69,13 @@
 #endif
 
 //The const kPCInc must be in sync with StackTrace::GetPreviousInstructionPc
-#if defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__)
+#if defined(__s390__) || defined(__i386__) || defined(__x86_64__)
 // PCs are always 4 byte aligned.
-const int kPCInc = 4;
+const int kPCInc = 1;
 #elif defined(__sparc__) || defined(__mips__)
 const int kPCInc = 8;
 #else
-const int kPCInc = 1;
+const int kPCInc = 4;
 #endif
 
 #ifdef __cplusplus
Index: compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
@@ -98,7 +98,7 @@
   // It seems difficult to figure out the exact instruction length -
   // pc - 2 seems like a safe option for the purposes of stack tracing
   return pc - 2;
-#elif SANITIZER_I386 || SANITIZER_X32 || SANITIZER_X64
+#elif SANITIZER_S390 || SANITIZER_I386 || SANITIZER_X32 || SANITIZER_X64
   return pc - 1;
 #else
   return pc - 4;
Index: compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
@@ -46,7 +46,7 @@
   }
   // bail-out if could not figure out the instruction size
   return 0;
-#elif SANITIZER_I386 || SANITIZER_X32 || SANITIZER_X64
+#elif SANITIZER_S390 || SANITIZER_I386 || SANITIZER_X32 || SANITIZER_X64
   return pc + 1;
 #else
   return pc + 4;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120432.410916.patch
Type: text/x-patch
Size: 2155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220223/5061d6e2/attachment.bin>


More information about the llvm-commits mailing list