[PATCH] D66885: [TSan] Add read/write range interface functions with PC

Joachim Protze via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 08:05:45 PDT 2019


protze.joachim created this revision.
protze.joachim added reviewers: dvyukov, kcc, vitalybuka.
Herald added projects: LLVM, Sanitizers.
Herald added subscribers: Sanitizers, llvm-commits.

For most memory access functions like  `__tsan_write8` there is a variant to provide a pc: `__tsan_write8_pc`. 
This is not the case for `__tsan_write_range`, which allows to annotate memory access for a range of memory. The main advantage we see in the range version is, that it only ticks once and therefore saves entries in the history ring buffer. Therefore, we would prefer to call `__tsan_write_range_pc` over looping on `__tsan_write8_pc`.

This patch adds the two new interface functions __tsan_write_range_pc and __tsan_read_range_pc, which take the additional PC argument.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D66885

Files:
  lib/tsan/rtl/tsan_interface.h
  lib/tsan/rtl/tsan_interface_inl.h


Index: lib/tsan/rtl/tsan_interface_inl.h
===================================================================
--- lib/tsan/rtl/tsan_interface_inl.h
+++ lib/tsan/rtl/tsan_interface_inl.h
@@ -122,3 +122,11 @@
 void __tsan_write_range(void *addr, uptr size) {
   MemoryAccessRange(cur_thread(), CALLERPC, (uptr)addr, size, true);
 }
+
+void __tsan_read_range_pc(void *addr, uptr size, void *pc) {
+  MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, false);
+}
+
+void __tsan_write_range_pc(void *addr, uptr size, void *pc) {
+  MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, true);
+}
Index: lib/tsan/rtl/tsan_interface.h
===================================================================
--- lib/tsan/rtl/tsan_interface.h
+++ lib/tsan/rtl/tsan_interface.h
@@ -94,6 +94,11 @@
 SANITIZER_INTERFACE_ATTRIBUTE
 void __tsan_write_range(void *addr, unsigned long size);  // NOLINT
 
+SANITIZER_INTERFACE_ATTRIBUTE
+void __tsan_read_range_pc(void *addr, unsigned long size, void *pc);  // NOLINT
+SANITIZER_INTERFACE_ATTRIBUTE
+void __tsan_write_range_pc(void *addr, unsigned long size, void *pc);  // NOLINT
+
 // User may provide function that would be called right when TSan detects
 // an error. The argument 'report' is an opaque pointer that can be used to
 // gather additional information using other TSan report API functions.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66885.217649.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190828/5a536a76/attachment.bin>


More information about the llvm-commits mailing list