[compiler-rt] 69721fc - [DFSan] Support fast16labels mode in dfsan_union.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 11:27:46 PDT 2020
Author: Matt Morehouse
Date: 2020-08-17T11:27:28-07:00
New Revision: 69721fc9d1b5df9a7a32d2fee6d72c8c7c9bf644
URL: https://github.com/llvm/llvm-project/commit/69721fc9d1b5df9a7a32d2fee6d72c8c7c9bf644
DIFF: https://github.com/llvm/llvm-project/commit/69721fc9d1b5df9a7a32d2fee6d72c8c7c9bf644.diff
LOG: [DFSan] Support fast16labels mode in dfsan_union.
While the instrumentation never calls dfsan_union in fast16labels mode,
the custom wrappers do. We detect fast16labels mode by checking whether
any labels have been created. If not, we must be using fast16labels
mode.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D86012
Added:
Modified:
compiler-rt/lib/dfsan/dfsan.cpp
compiler-rt/test/dfsan/custom.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index b2f474890e1d..0251b9d50ca0 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -170,6 +170,11 @@ dfsan_label __dfsan_union(dfsan_label l1, dfsan_label l2) {
if (l2 == 0)
return l1;
+ // If no labels have been created, yet l1 and l2 are non-zero, we are using
+ // fast16labels mode.
+ if (atomic_load(&__dfsan_last_label, memory_order_relaxed) == 0)
+ return l1 | l2;
+
if (l1 > l2)
Swap(l1, l2);
diff --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp
index e1ccf44ae7e0..7802f88f2c24 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -1,5 +1,6 @@
// RUN: %clang_dfsan %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
// RUN: %clang_dfsan -mllvm -dfsan-args-abi %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
+// RUN: %clang_dfsan -DFAST_16_LABELS -mllvm -dfsan-fast-16-labels %s -o %t && DFSAN_OPTIONS="strict_data_dependencies=0" %run %t
// RUN: %clang_dfsan -DSTRICT_DATA_DEPENDENCIES %s -o %t && %run %t
// RUN: %clang_dfsan -DSTRICT_DATA_DEPENDENCIES -mllvm -dfsan-args-abi %s -o %t && %run %t
@@ -952,10 +953,19 @@ void test_snprintf() {
}
int main(void) {
+#ifdef FAST_16_LABELS
+ i_label = 1;
+ j_label = 2;
+ k_label = 4;
+#else
i_label = dfsan_create_label("i", 0);
j_label = dfsan_create_label("j", 0);
k_label = dfsan_create_label("k", 0);
+#endif
i_j_label = dfsan_union(i_label, j_label);
+ assert(i_j_label != i_label);
+ assert(i_j_label != j_label);
+ assert(i_j_label != k_label);
test_calloc();
test_clock_gettime();
More information about the llvm-commits
mailing list