[compiler-rt] r176248 - [msan] Lit tests for __attribute__((no_sanitize_memory)).

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Feb 28 03:25:54 PST 2013


Author: eugenis
Date: Thu Feb 28 05:25:54 2013
New Revision: 176248

URL: http://llvm.org/viewvc/llvm-project?rev=176248&view=rev
Log:
[msan] Lit tests for __attribute__((no_sanitize_memory)).

Added:
    compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc   (with props)
    compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc   (with props)

Added: compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc?rev=176248&view=auto
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc (added)
+++ compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc Thu Feb 28 05:25:54 2013
@@ -0,0 +1,34 @@
+// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O1 %s -o %t && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O2 %s -o %t && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t >%t.out 2>&1
+
+// RUN: %clangxx_msan -m64 -O0 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O1 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O2 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O3 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
+
+// Test that (no_sanitize_memory) functions
+// * don't check shadow values (-DCHECK_IN_F)
+// * treat all values loaded from memory as fully initialized (-UCHECK_IN_F)
+
+#include <stdlib.h>
+#include <stdio.h>
+
+__attribute__((noinline))
+__attribute__((no_sanitize_memory))
+int f(void) {
+  int x;
+  int * volatile p = &x;
+#ifdef CHECK_IN_F
+  if (*p)
+    exit(0);
+#endif
+  return *p;
+}
+
+int main(void) {
+  if (f())
+    exit(0);
+  return 0;
+}

Propchange: compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory.cc
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc?rev=176248&view=auto
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc (added)
+++ compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc Thu Feb 28 05:25:54 2013
@@ -0,0 +1,33 @@
+// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
+// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+// Test that (no_sanitize_memory) functions propagate shadow.
+
+// Note that at -O0 there is no report, because 'x' in 'f' is spilled to the
+// stack, and then loaded back as a fully initialiazed value (due to
+// no_sanitize_memory attribute).
+
+#include <stdlib.h>
+#include <stdio.h>
+
+__attribute__((noinline))
+__attribute__((no_sanitize_memory))
+int f(int x) {
+  return x;
+}
+
+int main(void) {
+  int x;
+  int * volatile p = &x;
+  int y = f(*p);
+  // CHECK: WARNING: Use of uninitialized value
+  // CHECK: {{#0 0x.* in main .*no_sanitize_memory_prop.cc:}}[[@LINE+1]]
+  if (y)
+    exit(0);
+  return 0;
+}

Propchange: compiler-rt/trunk/lib/msan/lit_tests/no_sanitize_memory_prop.cc
------------------------------------------------------------------------------
    svn:eol-style = LF





More information about the llvm-commits mailing list