[compiler-rt] df441c9 - Revert "[DFSan] Handle fast16labels for all API functions."

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 10:52:30 PDT 2020


Author: Matt Morehouse
Date: 2020-07-23T17:49:55Z
New Revision: df441c90152caa338182012a889eff16bb2a64e7

URL: https://github.com/llvm/llvm-project/commit/df441c90152caa338182012a889eff16bb2a64e7
DIFF: https://github.com/llvm/llvm-project/commit/df441c90152caa338182012a889eff16bb2a64e7.diff

LOG: Revert "[DFSan] Handle fast16labels for all API functions."

This reverts commit 19d9c0397e61f2fb59a22d7c699436133a409aea due to
buildbot failure.

Added: 
    

Modified: 
    compiler-rt/lib/dfsan/dfsan.cpp
    compiler-rt/test/dfsan/fast16labels.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index 2d30c2d49419..0e2fb9f5f334 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -158,12 +158,6 @@ static void dfsan_check_label(dfsan_label label) {
   }
 }
 
-static void ReportUnsupportedFast16(const char *func) {
-  Report("FATAL: DataFlowSanitizer: %s is unsupported in fast16labels mode\n",
-         func);
-  Die();
-}
-
 // Resolves the union of two unequal labels.  Nonequality is a precondition for
 // this function (the instrumentation pass inlines the equality test).
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
@@ -259,10 +253,8 @@ dfsan_union(dfsan_label l1, dfsan_label l2) {
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
 dfsan_label dfsan_create_label(const char *desc, void *userdata) {
-  if (flags().fast16labels)
-    ReportUnsupportedFast16("dfsan_create_label");
   dfsan_label label =
-      atomic_fetch_add(&__dfsan_last_label, 1, memory_order_relaxed) + 1;
+    atomic_fetch_add(&__dfsan_last_label, 1, memory_order_relaxed) + 1;
   dfsan_check_label(label);
   __dfsan_label_info[label].l1 = __dfsan_label_info[label].l2 = 0;
   __dfsan_label_info[label].desc = desc;
@@ -319,15 +311,11 @@ dfsan_read_label(const void *addr, uptr size) {
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
 const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label) {
-  if (flags().fast16labels)
-    ReportUnsupportedFast16("dfsan_get_label_info");
   return &__dfsan_label_info[label];
 }
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE int
 dfsan_has_label(dfsan_label label, dfsan_label elem) {
-  if (flags().fast16labels)
-    return label & elem;
   if (label == elem)
     return true;
   const dfsan_label_info *info = dfsan_get_label_info(label);
@@ -340,8 +328,6 @@ dfsan_has_label(dfsan_label label, dfsan_label elem) {
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
 dfsan_has_label_with_desc(dfsan_label label, const char *desc) {
-  if (flags().fast16labels)
-    ReportUnsupportedFast16("dfsan_has_label_with_desc");
   const dfsan_label_info *info = dfsan_get_label_info(label);
   if (info->l1 != 0) {
     return dfsan_has_label_with_desc(info->l1, desc) ||
@@ -361,11 +347,9 @@ dfsan_get_label_count(void) {
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
 dfsan_dump_labels(int fd) {
-  if (flags().fast16labels)
-    ReportUnsupportedFast16("dfsan_dump_labels");
-
   dfsan_label last_label =
       atomic_load(&__dfsan_last_label, memory_order_relaxed);
+
   for (uptr l = 1; l <= last_label; ++l) {
     char buf[64];
     internal_snprintf(buf, sizeof(buf), "%u %u %u ", l,

diff  --git a/compiler-rt/test/dfsan/fast16labels.c b/compiler-rt/test/dfsan/fast16labels.c
index 90c039234c33..a9b716039540 100644
--- a/compiler-rt/test/dfsan/fast16labels.c
+++ b/compiler-rt/test/dfsan/fast16labels.c
@@ -1,13 +1,4 @@
-// RUN: %clang_dfsan %s -o %t
-// RUN: DFSAN_OPTIONS=fast16labels=1 %run %t
-// RUN: DFSAN_OPTIONS=fast16labels=1 not %run %t dfsan_create_label 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CREATE-LABEL
-// RUN: DFSAN_OPTIONS=fast16labels=1 not %run %t dfsan_get_label_info 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=GET-LABEL-INFO
-// RUN: DFSAN_OPTIONS=fast16labels=1 not %run %t dfsan_has_label_with_desc \
-// RUN:   2>&1 | FileCheck %s --check-prefix=HAS-LABEL-WITH-DESC
-// RUN: DFSAN_OPTIONS=fast16labels=1:dump_labels_at_exit=/dev/stdout not %run \
-// RUN:   %t 2>&1 | FileCheck %s --check-prefix=DUMP-LABELS
+// RUN: %clang_dfsan %s -o %t && DFSAN_OPTIONS=fast16labels=1 %run %t
 //
 // Tests DFSAN_OPTIONS=fast16labels=1
 //
@@ -15,45 +6,20 @@
 
 #include <assert.h>
 #include <stdio.h>
-#include <string.h>
 
 int foo(int a, int b) {
   return a + b;
 }
 
-int main(int argc, char *argv[]) {
-  // Death tests for unsupported API usage.
-  const char *command = (argc < 2) ? "" : argv[1];
-  fprintf(stderr, "Running with command %s\n", command);
-  // CREATE-LABEL: FATAL: DataFlowSanitizer: dfsan_create_label is unsupported
-  if (strcmp(command, "dfsan_create_label") == 0)
-    dfsan_create_label("", NULL);
-  // GET-LABEL-INFO: FATAL: DataFlowSanitizer: dfsan_get_label_info is unsupported
-  if (strcmp(command, "dfsan_get_label_info") == 0)
-    dfsan_get_label_info(1);
-  // HAS-LABEL-WITH-DESC: FATAL: DataFlowSanitizer: dfsan_has_label_with_desc is unsupported
-  if (strcmp(command, "dfsan_has_label_with_desc") == 0)
-    dfsan_has_label_with_desc(1, "");
-  // DUMP-LABELS: FATAL: DataFlowSanitizer: dfsan_dump_labels is unsupported
-
-  // Supported usage.
+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);
-  fprintf(stderr, "A: 0x%x\n", dfsan_get_label(a));
-  fprintf(stderr, "B: 0x%x\n", dfsan_get_label(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);
-  fprintf(stderr, "C: 0x%x\n", l);
-  fprintf(stderr, "Testing l == 520\n");
+  printf("C: 0x%x\n", l);
   assert(l == 520);  // OR of the other two labels.
-  fprintf(stderr, "Testing dfsan_has_label(l, 8)\n");
-  assert(dfsan_has_label(l, 8));
-  fprintf(stderr, "Testing dfsan_has_label(l, 512)\n");
-  assert(dfsan_has_label(l, 512));
-  fprintf(stderr, "Testing !dfsan_has_label(l, 1)\n");
-  assert(!dfsan_has_label(l, 1));
-  fprintf(stderr, "returning...\n");
-  return 0;
 }


        


More information about the llvm-commits mailing list