]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add tests to check that memcheck does not give a false error for 'xor
authorJulian Seward <jseward@acm.org>
Tue, 16 Jan 2007 19:15:19 +0000 (19:15 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 16 Jan 2007 19:15:19 +0000 (19:15 +0000)
%reg,%reg' (in various forms) when %reg contains undefined data.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6524

memcheck/tests/amd64/Makefile.am
memcheck/tests/amd64/xor-undef-amd64.c [new file with mode: 0644]
memcheck/tests/amd64/xor-undef-amd64.stderr.exp [new file with mode: 0644]
memcheck/tests/amd64/xor-undef-amd64.stdout.exp [new file with mode: 0644]
memcheck/tests/amd64/xor-undef-amd64.vgtest [new file with mode: 0644]
memcheck/tests/x86/Makefile.am
memcheck/tests/x86/xor-undef-x86.c [new file with mode: 0644]
memcheck/tests/x86/xor-undef-x86.stderr.exp [new file with mode: 0644]
memcheck/tests/x86/xor-undef-x86.stdout.exp [new file with mode: 0644]
memcheck/tests/x86/xor-undef-x86.vgtest [new file with mode: 0644]

index b8452b12ff50ffdec53eca58b149f35a03edd8a1..b11dfc34da43701da6f2abb90d1bbb4ce23886de 100644 (file)
@@ -13,9 +13,12 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        bug132146.vgtest bug132146.stderr.exp bug132146.stdout.exp \
        fxsave-amd64.vgtest fxsave-amd64.stdout.exp fxsave-amd64.stderr.exp \
        more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \
-       sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest
+       sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest \
+       xor-undef-amd64.stderr.exp xor-undef-amd64.stdout.exp \
+       xor-undef-amd64.vgtest
 
-check_PROGRAMS = bt_everything bug132146 fxsave-amd64 more_x87_fp sse_memory
+check_PROGRAMS = bt_everything bug132146 fxsave-amd64 \
+               more_x87_fp sse_memory xor-undef-amd64
 
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
diff --git a/memcheck/tests/amd64/xor-undef-amd64.c b/memcheck/tests/amd64/xor-undef-amd64.c
new file mode 100644 (file)
index 0000000..4ff5699
--- /dev/null
@@ -0,0 +1,143 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define JZ_NEXT ".byte 0x74,0x00"  /* jz the-next-insn */
+
+int main ( void )
+{
+   char* junk = malloc(48);
+   assert(junk);
+
+
+   /* --- INTEGER --- */
+
+   printf("\nComplain int64\n");
+   __asm__ __volatile__(
+      "movq   0(%0), %%rax\n\t"
+      "movq   8(%0), %%r8\n\t"
+      "xorq   %%r8, %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "r8", "rax", "cc"
+   );
+
+   printf("\nNo complain int64\n");
+   __asm__ __volatile__(
+      "movq   0(%0), %%rax\n\t"
+      "movq   8(%0), %%r8\n\t"
+      "xorq   %%rax, %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "r8", "rax", "cc"
+   );
+
+
+   /* --- MMX --- */
+
+   printf("\nComplain mmx\n");
+   __asm__ __volatile__(
+      "emms\n\t"
+      "movq   0(%0), %%mm0\n\t"
+      "movq   8(%0), %%mm7\n\t"
+      "pxor   %%mm7, %%mm0\n\t"
+      "movq   %%mm0, 16(%0)\n\t"
+      "cmpq   $0,16(%0)\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "mm7", "mm0", "cc", "memory"
+   );
+
+   printf("\nNo complain mmx\n");
+   __asm__ __volatile__(
+      "emms\n\t"
+      "movq   0(%0), %%mm0\n\t"
+      "movq   8(%0), %%mm7\n\t"
+      "pxor   %%mm0, %%mm0\n\t"
+      "movq   %%mm0, 16(%0)\n\t"
+      "cmpq   $0,16(%0)\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "mm7", "mm0", "cc", "memory"
+   );
+
+
+   /* --- SSE1 --- */
+
+   printf("\nComplain sse xorps\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "xorps    %%xmm8, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse xorps\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "xorps    %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+
+   /* --- SSE2 --- */
+
+   printf("\nComplain sse2 pxor\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "pxor     %%xmm8, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse2 pxor\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "pxor     %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+
+   printf("\nComplain sse2 xorpd\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "xorpd    %%xmm8, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse2 xorpd\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm8\n\t"
+      "xorpd    %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movq 32(%0), %%rax\n\t"
+      "addq 40(%0), %%rax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
+   );
+
+
+   free(junk);
+   return 0;
+}
diff --git a/memcheck/tests/amd64/xor-undef-amd64.stderr.exp b/memcheck/tests/amd64/xor-undef-amd64.stderr.exp
new file mode 100644 (file)
index 0000000..b1da2e9
--- /dev/null
@@ -0,0 +1,21 @@
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-amd64.c:17)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-amd64.c:38)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-amd64.c:65)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-amd64.c:92)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-amd64.c:117)
+
+ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 1 allocs, 1 frees, 48 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/memcheck/tests/amd64/xor-undef-amd64.stdout.exp b/memcheck/tests/amd64/xor-undef-amd64.stdout.exp
new file mode 100644 (file)
index 0000000..3853762
--- /dev/null
@@ -0,0 +1,20 @@
+
+Complain int64
+
+No complain int64
+
+Complain mmx
+
+No complain mmx
+
+Complain sse xorps
+
+No complain sse xorps
+
+Complain sse2 pxor
+
+No complain sse2 pxor
+
+Complain sse2 xorpd
+
+No complain sse2 xorpd
diff --git a/memcheck/tests/amd64/xor-undef-amd64.vgtest b/memcheck/tests/amd64/xor-undef-amd64.vgtest
new file mode 100644 (file)
index 0000000..b0a9be1
--- /dev/null
@@ -0,0 +1 @@
+prog: xor-undef-amd64
index f132f7c6bf1027a84da5bee101ea959c7aad8f60..60d4427f059e411f8eb0f9a3ff58f31960c72403 100644 (file)
@@ -24,14 +24,16 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        sse2_memory.stderr.exp sse2_memory.stdout.exp sse2_memory.vgtest \
        tronical.stderr.exp tronical.vgtest \
        more_x86_fp.stderr.exp more_x86_fp.stdout.exp more_x86_fp.vgtest \
-       fprem.stderr.exp fprem.stdout.exp fprem.vgtest
+       fprem.stderr.exp fprem.stdout.exp fprem.vgtest \
+       xor-undef-x86.stderr.exp xor-undef-x86.stdout.exp \
+       xor-undef-x86.vgtest
 
 check_PROGRAMS = \
        bug133694 \
        espindola2 \
        scalar_exit_group scalar_fork scalar_supp scalar_vfork \
        fpeflags pushfpopf pushpopmem scalar sse_memory tronical \
-       more_x86_fp fprem
+       more_x86_fp fprem xor-undef-x86
 
 AM_CPPFLAGS  = -I$(top_srcdir)/include
 AM_CFLAGS    = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \
diff --git a/memcheck/tests/x86/xor-undef-x86.c b/memcheck/tests/x86/xor-undef-x86.c
new file mode 100644 (file)
index 0000000..5831626
--- /dev/null
@@ -0,0 +1,157 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define JZ_NEXT ".byte 0x74,0x00"  /* jz the-next-insn */
+
+int main ( void )
+{
+   char* junk = malloc(48);
+   assert(junk);
+
+
+   /* --- INTEGER --- */
+
+   printf("\nComplain int32\n");
+   __asm__ __volatile__(
+      "movl   0(%0), %%eax\n\t"
+      "movl   8(%0), %%edi\n\t"
+      "xorl   %%edi, %%eax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "edi", "eax", "cc"
+   );
+
+   printf("\nNo complain int32\n");
+   __asm__ __volatile__(
+      "movl   0(%0), %%eax\n\t"
+      "movl   8(%0), %%edi\n\t"
+      "xorl   %%eax, %%eax\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "edi", "eax", "cc"
+   );
+
+
+   /* --- MMX --- */
+
+   printf("\nComplain mmx\n");
+   __asm__ __volatile__(
+      "emms\n\t"
+      "movq   0(%0), %%mm0\n\t"
+      "movq   8(%0), %%mm7\n\t"
+      "pxor   %%mm7, %%mm0\n\t"
+      "movq   %%mm0, 16(%0)\n\t"
+      "movl   16(%0), %%esi\n\t"
+      "addl   20(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "mm7", "mm0", "cc", "memory"
+   );
+
+   printf("\nNo complain mmx\n");
+   __asm__ __volatile__(
+      "emms\n\t"
+      "movq   0(%0), %%mm0\n\t"
+      "movq   8(%0), %%mm7\n\t"
+      "pxor   %%mm0, %%mm0\n\t"
+      "movq   %%mm0, 16(%0)\n\t"
+      "movl   16(%0), %%esi\n\t"
+      "addl   20(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "mm7", "mm0", "cc", "memory"
+   );
+
+
+   /* --- SSE1 --- */
+
+   printf("\nComplain sse xorps\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "xorps    %%xmm7, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse xorps\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "xorps    %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+
+   /* --- SSE2 --- */
+
+   printf("\nComplain sse2 pxor\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "pxor     %%xmm7, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse2 pxor\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "pxor     %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+
+   printf("\nComplain sse2 xorpd\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "xorpd    %%xmm7, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+   printf("\nNo complain sse2 xorpd\n");
+   __asm__ __volatile__(
+      "movups   0(%0),  %%xmm0\n\t"
+      "movups   16(%0), %%xmm7\n\t"
+      "xorpd    %%xmm0, %%xmm0\n\t"
+      "movups   %%xmm0, 32(%0)\n\t"
+      "movl 32(%0), %%esi\n\t"
+      "addl 36(%0), %%esi\n\t"
+      "addl 40(%0), %%esi\n\t"
+      "addl 44(%0), %%esi\n\t"
+      JZ_NEXT
+      : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
+   );
+
+
+   free(junk);
+   return 0;
+}
diff --git a/memcheck/tests/x86/xor-undef-x86.stderr.exp b/memcheck/tests/x86/xor-undef-x86.stderr.exp
new file mode 100644 (file)
index 0000000..4d5c56c
--- /dev/null
@@ -0,0 +1,21 @@
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-x86.c:17)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-x86.c:38)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-x86.c:67)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-x86.c:98)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: main (xor-undef-x86.c:127)
+
+ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 1 allocs, 1 frees, 48 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/memcheck/tests/x86/xor-undef-x86.stdout.exp b/memcheck/tests/x86/xor-undef-x86.stdout.exp
new file mode 100644 (file)
index 0000000..882d4b4
--- /dev/null
@@ -0,0 +1,20 @@
+
+Complain int32
+
+No complain int32
+
+Complain mmx
+
+No complain mmx
+
+Complain sse xorps
+
+No complain sse xorps
+
+Complain sse2 pxor
+
+No complain sse2 pxor
+
+Complain sse2 xorpd
+
+No complain sse2 xorpd
diff --git a/memcheck/tests/x86/xor-undef-x86.vgtest b/memcheck/tests/x86/xor-undef-x86.vgtest
new file mode 100644 (file)
index 0000000..daa648b
--- /dev/null
@@ -0,0 +1,2 @@
+prog: xor-undef-x86
+prereq: ../../../tests/cputest x86-sse