[PATCH] D62870: Experimantal dfsan mode "fast16labels=1"
Kostya Serebryany via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 11:27:00 PDT 2019
kcc created this revision.
kcc added a reviewer: kcc.
Herald added subscribers: Sanitizers, delcypher.
Herald added projects: LLVM, Sanitizers.
dfsan mode "fast16labels=1".
In this mode the labels are treated as 16-bit bit masks.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D62870
Files:
lib/dfsan/dfsan.cc
lib/dfsan/dfsan_flags.inc
test/dfsan/fast16labels.c
Index: test/dfsan/fast16labels.c
===================================================================
--- /dev/null
+++ test/dfsan/fast16labels.c
@@ -0,0 +1,25 @@
+// RUN: %clang_dfsan %s -o %t && DFSAN_OPTIONS=fast16labels=1 %run %t
+//
+// Tests DFSAN_OPTIONS=fast16labels=1
+//
+#include <sanitizer/dfsan_interface.h>
+
+#include <assert.h>
+#include <stdio.h>
+
+int foo(int a, int b) {
+ return a + b;
+}
+
+int main() {
+ int a = 10;
+ int b = 20;
+ dfsan_set_label(8, &a, sizeof(a));
+ dfsan_set_label(512, &b, sizeof(b));
+ int c = foo(a, b);
+ printf("A: 0x%x\n", dfsan_get_label(a));
+ printf("B: 0x%x\n", dfsan_get_label(b));
+ dfsan_label l = dfsan_get_label(c);
+ printf("C: 0x%x\n", l);
+ assert(l == 520); // OR of the other two labels.
+}
Index: lib/dfsan/dfsan_flags.inc
===================================================================
--- lib/dfsan/dfsan_flags.inc
+++ lib/dfsan/dfsan_flags.inc
@@ -29,3 +29,7 @@
DFSAN_FLAG(const char *, dump_labels_at_exit, "", "The path of the file where "
"to dump the labels when the "
"program terminates.")
+DFSAN_FLAG(bool, fast16labels, false,
+ "Enables experimental mode where DFSan supports only 16 power-of-2 labels "
+ "(1, 2, 4, 8, ... 32768) and the label union is computed as a bit-wise OR."
+)
Index: lib/dfsan/dfsan.cc
===================================================================
--- lib/dfsan/dfsan.cc
+++ lib/dfsan/dfsan.cc
@@ -162,6 +162,8 @@
// this function (the instrumentation pass inlines the equality test).
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
dfsan_label __dfsan_union(dfsan_label l1, dfsan_label l2) {
+ if (flags().fast16labels)
+ return l1 | l2;
DCHECK_NE(l1, l2);
if (l1 == 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62870.202993.patch
Type: text/x-patch
Size: 1811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/8f6eb924/attachment.bin>
More information about the llvm-commits
mailing list