[compiler-rt] r188401 - [dfsan] Runtime support for ABI list functionality; can now run integration tests with args ABI.

Peter Collingbourne peter at pcc.me.uk
Wed Aug 14 11:54:06 PDT 2013


Author: pcc
Date: Wed Aug 14 13:54:06 2013
New Revision: 188401

URL: http://llvm.org/viewvc/llvm-project?rev=188401&view=rev
Log:
[dfsan] Runtime support for ABI list functionality; can now run integration tests with args ABI.

Differential Revision: http://llvm-reviews.chandlerc.com/D1351

Added:
    compiler-rt/trunk/lib/dfsan/done_abilist.txt
Modified:
    compiler-rt/trunk/lib/dfsan/CMakeLists.txt
    compiler-rt/trunk/lib/dfsan/dfsan.cc
    compiler-rt/trunk/lib/dfsan/lit_tests/CMakeLists.txt
    compiler-rt/trunk/lib/dfsan/lit_tests/basic.c
    compiler-rt/trunk/lib/dfsan/lit_tests/fncall.c
    compiler-rt/trunk/lib/dfsan/lit_tests/propagate.c

Modified: compiler-rt/trunk/lib/dfsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/CMakeLists.txt?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/dfsan/CMakeLists.txt Wed Aug 14 13:54:06 2013
@@ -26,4 +26,15 @@ if(CAN_TARGET_${arch})
   list(APPEND DFSAN_RUNTIME_LIBRARIES clang_rt.dfsan-${arch})
 endif()
 
+add_custom_target(dfsan_abilist ALL
+                                SOURCES ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt)
+add_custom_command(OUTPUT ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+                   VERBATIM
+                   COMMAND
+                     cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt
+                         > ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+                   DEPENDS done_abilist.txt)
+install(FILES ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+        DESTINATION ${LIBCLANG_INSTALL_PATH})
+
 add_subdirectory(lit_tests)

Modified: compiler-rt/trunk/lib/dfsan/dfsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.cc?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc Wed Aug 14 13:54:06 2013
@@ -130,6 +130,12 @@ dfsan_label __dfsan_union_load(const dfs
   return label;
 }
 
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE
+void __dfsan_unimplemented(char *fname) {
+  Report("WARNING: DataFlowSanitizer: call to uninstrumented function %s\n",
+         fname);
+}
+
 // Like __dfsan_union, but for use from the client or custom functions.  Hence
 // the equality comparison is done here before calling __dfsan_union.
 SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
@@ -147,7 +153,6 @@ dfsan_label dfsan_create_label(const cha
   __dfsan_label_info[label].l1 = __dfsan_label_info[label].l2 = 0;
   __dfsan_label_info[label].desc = desc;
   __dfsan_label_info[label].userdata = userdata;
-  __dfsan_retval_tls = 0;  // Ensures return value is unlabelled in the caller.
   return label;
 }
 
@@ -164,11 +169,14 @@ void dfsan_add_label(dfsan_label label,
       *labelp = __dfsan_union(*labelp, label);
 }
 
-SANITIZER_INTERFACE_ATTRIBUTE dfsan_label dfsan_get_label(long data) {
-  // The label for 'data' is implicitly passed by the instrumentation pass in
-  // the first element of __dfsan_arg_tls.  So we can just return it.
-  __dfsan_retval_tls = 0;  // Ensures return value is unlabelled in the caller.
-  return __dfsan_arg_tls[0];
+// Unlike the other dfsan interface functions the behavior of this function
+// depends on the label of one of its arguments.  Hence it is implemented as a
+// custom function.
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
+__dfsw_dfsan_get_label(long data, dfsan_label data_label,
+                       dfsan_label *ret_label) {
+  *ret_label = 0;
+  return data_label;
 }
 
 SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
@@ -180,12 +188,10 @@ dfsan_read_label(const void *addr, size_
 
 SANITIZER_INTERFACE_ATTRIBUTE
 const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label) {
-  __dfsan_retval_tls = 0;  // Ensures return value is unlabelled in the caller.
   return &__dfsan_label_info[label];
 }
 
 int dfsan_has_label(dfsan_label label, dfsan_label elem) {
-  __dfsan_retval_tls = 0;  // Ensures return value is unlabelled in the caller.
   if (label == elem)
     return true;
   const dfsan_label_info *info = dfsan_get_label_info(label);
@@ -197,7 +203,6 @@ int dfsan_has_label(dfsan_label label, d
 }
 
 dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc) {
-  __dfsan_retval_tls = 0;  // Ensures return value is unlabelled in the caller.
   const dfsan_label_info *info = dfsan_get_label_info(label);
   if (info->l1 != 0) {
     return dfsan_has_label_with_desc(info->l1, desc) ||

Added: compiler-rt/trunk/lib/dfsan/done_abilist.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/done_abilist.txt?rev=188401&view=auto
==============================================================================
--- compiler-rt/trunk/lib/dfsan/done_abilist.txt (added)
+++ compiler-rt/trunk/lib/dfsan/done_abilist.txt Wed Aug 14 13:54:06 2013
@@ -0,0 +1,30 @@
+fun:main=uninstrumented
+fun:main=discard
+
+# DFSan interface functions.
+fun:dfsan_union=uninstrumented
+fun:dfsan_union=discard
+
+fun:dfsan_create_label=uninstrumented
+fun:dfsan_create_label=discard
+
+fun:dfsan_set_label=uninstrumented
+fun:dfsan_set_label=discard
+
+fun:dfsan_add_label=uninstrumented
+fun:dfsan_add_label=discard
+
+fun:dfsan_get_label=uninstrumented
+fun:dfsan_get_label=custom
+
+fun:dfsan_read_label=uninstrumented
+fun:dfsan_read_label=discard
+
+fun:dfsan_get_label_info=uninstrumented
+fun:dfsan_get_label_info=discard
+
+fun:dfsan_has_label=uninstrumented
+fun:dfsan_has_label=discard
+
+fun:dfsan_has_label_with_desc=uninstrumented
+fun:dfsan_has_label_with_desc=discard

Modified: compiler-rt/trunk/lib/dfsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/CMakeLists.txt?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/dfsan/lit_tests/CMakeLists.txt Wed Aug 14 13:54:06 2013
@@ -9,7 +9,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
   # Run DFSan tests only if we're sure we may produce working binaries.
   set(DFSAN_TEST_DEPS
     ${SANITIZER_COMMON_LIT_TEST_DEPS}
-    ${DFSAN_RUNTIME_LIBRARIES})
+    ${DFSAN_RUNTIME_LIBRARIES}
+    dfsan_abilist)
   set(DFSAN_TEST_PARAMS
     dfsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
   add_lit_testsuite(check-dfsan "Running the DataFlowSanitizer tests"

Modified: compiler-rt/trunk/lib/dfsan/lit_tests/basic.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/basic.c?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/lit_tests/basic.c (original)
+++ compiler-rt/trunk/lib/dfsan/lit_tests/basic.c Wed Aug 14 13:54:06 2013
@@ -1,4 +1,5 @@
 // RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
 
 // Tests that labels are propagated through loads and stores.
 

Modified: compiler-rt/trunk/lib/dfsan/lit_tests/fncall.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/fncall.c?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/lit_tests/fncall.c (original)
+++ compiler-rt/trunk/lib/dfsan/lit_tests/fncall.c Wed Aug 14 13:54:06 2013
@@ -1,4 +1,5 @@
 // RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
 
 // Tests that labels are propagated through function calls.
 

Modified: compiler-rt/trunk/lib/dfsan/lit_tests/propagate.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/propagate.c?rev=188401&r1=188400&r2=188401&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/lit_tests/propagate.c (original)
+++ compiler-rt/trunk/lib/dfsan/lit_tests/propagate.c Wed Aug 14 13:54:06 2013
@@ -1,4 +1,5 @@
 // RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
 
 // Tests that labels are propagated through computation and that union labels
 // are properly created.





More information about the llvm-commits mailing list