|
From: <sv...@va...> - 2009-10-09 00:53:11
|
Author: sewardj
Date: 2009-10-09 01:52:57 +0100 (Fri, 09 Oct 2009)
New Revision: 10901
Log:
Add tests for correct handling of sse2-based strlen routines, when
--allow-partial-load128s=yes is given.
Added:
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stderr.exp
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stdout.exp
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.vgtest
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stderr.exp
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stdout.exp
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.vgtest
branches/ICC111/memcheck/tests/amd64/strlen-sse2-64.c
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stderr.exp
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stdout.exp
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.vgtest
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stderr.exp
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stdout.exp
branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.vgtest
branches/ICC111/memcheck/tests/x86/strlen-sse2-32.c
Modified:
branches/ICC111/memcheck/tests/amd64/Makefile.am
branches/ICC111/memcheck/tests/x86/Makefile.am
Modified: branches/ICC111/memcheck/tests/amd64/Makefile.am
===================================================================
--- branches/ICC111/memcheck/tests/amd64/Makefile.am 2009-10-09 00:26:55 UTC (rev 10900)
+++ branches/ICC111/memcheck/tests/amd64/Makefile.am 2009-10-09 00:52:57 UTC (rev 10901)
@@ -19,6 +19,10 @@
more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \
pmovmskb64.stderr.exp pmovmskb64.stdout.exp pmovmskb64.vgtest \
sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest \
+ strlen-sse2-64-1.vgtest strlen-sse2-64-1.stdout.exp \
+ strlen-sse2-64-1.stderr.exp \
+ strlen-sse2-64-2.vgtest strlen-sse2-64-2.stdout.exp \
+ strlen-sse2-64-2.stderr.exp \
xor-undef-amd64.stderr.exp xor-undef-amd64.stdout.exp \
xor-undef-amd64.vgtest
@@ -28,6 +32,7 @@
bug132146 \
fxsave-amd64 \
pmovmskb64 \
+ strlen-sse2-64 \
xor-undef-amd64
# DDD: not sure if these ones should work on Darwin or not... if not, should
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stderr.exp
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stderr.exp (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stderr.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,7 @@
+Invalid read of size 8
+ at 0x........: __strlen_sse2 (in /home/sewardj/VgTRUNK/ic111/memcheck/tests/amd64/strlen-sse2-64)
+ by 0x........: (below main)
+ Address 0x........ is 0 bytes inside a block of size 4 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (strlen-sse2-64.c:50)
+
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stdout.exp
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stdout.exp (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.stdout.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+len is 2
+len is 10
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.vgtest
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.vgtest (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-1.vgtest 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+prog: strlen-sse2-64
+vgopts: -q
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stderr.exp
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stderr.exp (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stderr.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,6 @@
+QQQQ a = 0x........ mo = 100
+QQQQ a128 = 0x........ nab = 12
+QQQQ a = 0x........ mo = 101
+QQQQ a128 = 0x........ nab = 12
+QQQQ a = 0x........ mo = 101
+QQQQ a128 = 0x........ nab = 4
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stdout.exp
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stdout.exp (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.stdout.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+len is 2
+len is 10
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.vgtest
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.vgtest (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64-2.vgtest 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+prog: strlen-sse2-64
+vgopts: -q --partial-load128s-ok=yes
Added: branches/ICC111/memcheck/tests/amd64/strlen-sse2-64.c
===================================================================
--- branches/ICC111/memcheck/tests/amd64/strlen-sse2-64.c (rev 0)
+++ branches/ICC111/memcheck/tests/amd64/strlen-sse2-64.c 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,64 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* This is the version that is in glibc cvs */
+
+asm(
+".text" "\n\t"
+".globl __strlen_sse2\n\t"
+".type __strlen_sse2, @function\n\t"
+"__strlen_sse2:" "\n\t"
+"" "\n\t"
+" movq %rdi, %rcx" "\n\t"
+" movq %rdi, %r8" "\n\t"
+" andq $~15, %rdi" "\n\t"
+" pxor %xmm1, %xmm1" "\n\t"
+" orl $0xffffffff, %esi" "\n\t"
+" movdqa (%rdi), %xmm0" "\n\t"
+" subq %rdi, %rcx" "\n\t"
+" leaq 16(%rdi), %rdi" "\n\t"
+" pcmpeqb %xmm1, %xmm0" "\n\t"
+" shl %cl, %esi" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+" xorl %eax, %eax" "\n\t"
+" negq %r8" "\n\t"
+" andl %esi, %edx" "\n\t"
+" jnz 1f" "\n\t"
+"" "\n\t"
+"2: movdqa (%rdi), %xmm0" "\n\t"
+" leaq 16(%rdi), %rdi" "\n\t"
+" pcmpeqb %xmm1, %xmm0" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+" testl %edx, %edx" "\n\t"
+" jz 2b" "\n\t"
+"" "\n\t"
+"1: leaq -16(%rdi,%r8), %rdi" "\n\t"
+" bsfl %edx, %eax" "\n\t"
+" addq %rdi, %rax" "\n\t"
+" ret" "\n\t"
+"" "\n\t"
+".size __strlen_sse2, .-__strlen_sse2" "\n\t"
+".previous\n"
+);
+
+extern int __strlen_sse2 ( char* );
+
+int main ( void )
+{
+ int i;
+ char* str = malloc(4);
+ str[0] = str[1] = 'x';
+ str[2] = 0;
+ printf("len is %d\n", __strlen_sse2(str));
+ free(str);
+
+ str = malloc(12);
+ for (i = 0; i < 12-2; i++)
+ str[i] = 'y';
+ str[i] = 0;
+ printf("len is %d\n", __strlen_sse2(str));
+ free(str);
+
+ return 0;
+}
Modified: branches/ICC111/memcheck/tests/x86/Makefile.am
===================================================================
--- branches/ICC111/memcheck/tests/x86/Makefile.am 2009-10-09 00:26:55 UTC (rev 10900)
+++ branches/ICC111/memcheck/tests/x86/Makefile.am 2009-10-09 00:52:57 UTC (rev 10901)
@@ -23,6 +23,10 @@
more_x86_fp.stderr.exp more_x86_fp.stdout.exp more_x86_fp.vgtest \
pmovmskb32.stderr.exp pmovmskb32.stdout.exp pmovmskb32.vgtest \
fprem.stderr.exp fprem.stdout.exp fprem.vgtest \
+ strlen-sse2-32-1.vgtest strlen-sse2-32-1.stdout.exp \
+ strlen-sse2-32-1.stderr.exp \
+ strlen-sse2-32-2.vgtest strlen-sse2-32-2.stdout.exp \
+ strlen-sse2-32-2.stderr.exp \
xor-undef-x86.stderr.exp xor-undef-x86.stdout.exp \
xor-undef-x86.vgtest
@@ -39,6 +43,7 @@
pushfw_x86 \
pushpopmem \
sse_memory \
+ strlen-sse2-32 \
tronical \
xor-undef-x86
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stderr.exp
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stderr.exp (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stderr.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,14 @@
+Invalid read of size 8
+ at 0x........: __strlen_sse2 (in /home/sewardj/VgTRUNK/ic111/memcheck/tests/x86/strlen-sse2-32)
+ by 0x........: main (strlen-sse2-32.c:77)
+ Address 0x........ is 8 bytes before a block of size 4 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (strlen-sse2-32.c:74)
+
+Invalid read of size 8
+ at 0x........: __strlen_sse2 (in /home/sewardj/VgTRUNK/ic111/memcheck/tests/x86/strlen-sse2-32)
+ by 0x........: main (strlen-sse2-32.c:84)
+ Address 0x........ is 8 bytes inside a block of size 12 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (strlen-sse2-32.c:80)
+
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stdout.exp
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stdout.exp (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.stdout.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+len is 2
+len is 10
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.vgtest
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.vgtest (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-1.vgtest 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,3 @@
+prog: strlen-sse2-32
+vgopts: -q
+prereq: ../../../tests/x86_amd64_features x86-sse2
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stderr.exp
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stderr.exp (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stderr.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,6 @@
+QQQQ a = 0x........ mo = 100
+QQQQ a128 = 0x........ nab = 12
+QQQQ a = 0x........ mo = 101
+QQQQ a128 = 0x........ nab = 12
+QQQQ a = 0x........ mo = 101
+QQQQ a128 = 0x........ nab = 4
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stdout.exp
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stdout.exp (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.stdout.exp 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,2 @@
+len is 2
+len is 10
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.vgtest
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.vgtest (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32-2.vgtest 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,3 @@
+prog: strlen-sse2-32
+vgopts: -q --partial-load128s-ok=yes
+prereq: ../../../tests/x86_amd64_features x86-sse2
Added: branches/ICC111/memcheck/tests/x86/strlen-sse2-32.c
===================================================================
--- branches/ICC111/memcheck/tests/x86/strlen-sse2-32.c (rev 0)
+++ branches/ICC111/memcheck/tests/x86/strlen-sse2-32.c 2009-10-09 00:52:57 UTC (rev 10901)
@@ -0,0 +1,88 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+asm(
+".text" "\n\t"
+".globl __strlen_sse2\n\t"
+".type __strlen_sse2, @function\n\t"
+"__strlen_sse2: " "\n\t"
+ "\n\t"
+" pushl %ebp" "\n\t"
+" movl %esp, %ebp" "\n\t"
+" mov 8(%esp), %eax" "\n\t"
+" mov %eax, %ecx" "\n\t"
+" pxor %xmm0, %xmm0" "\n\t"
+" mov %eax, %esi" "\n\t"
+" and $15, %ecx" "\n\t"
+" jz 1f" "\n\t"
+"" "\n\t"
+" and $-16, %esi" "\n\t"
+"" "\n\t"
+" pcmpeqb (%esi), %xmm0" "\n\t"
+" lea 16(%eax), %esi" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+"" "\n\t"
+" shr %cl, %edx" "\n\t"
+" test %edx, %edx" "\n\t"
+" jnz 2f" "\n\t"
+" sub %ecx, %esi" "\n\t"
+" pxor %xmm0, %xmm0" "\n\t"
+"" "\n\t"
+"1:" "\n\t"
+" pcmpeqb (%esi), %xmm0" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+"" "\n\t"
+" add $16, %esi" "\n\t"
+" test %edx, %edx" "\n\t"
+" jnz 2f" "\n\t"
+"" "\n\t"
+" pcmpeqb (%esi), %xmm0" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+" add $16, %esi" "\n\t"
+" test %edx, %edx" "\n\t"
+" jnz 2f" "\n\t"
+"" "\n\t"
+" pcmpeqb (%esi), %xmm0" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+" add $16, %esi" "\n\t"
+" test %edx, %edx" "\n\t"
+" jnz 2f" "\n\t"
+"" "\n\t"
+" pcmpeqb (%esi), %xmm0" "\n\t"
+" pmovmskb %xmm0, %edx" "\n\t"
+" add $16, %esi" "\n\t"
+" test %edx, %edx" "\n\t"
+" jz 1b" "\n\t"
+"" "\n\t"
+"2:" "\n\t"
+" neg %eax" "\n\t"
+" lea -16(%eax, %esi), %eax" "\n\t"
+" bsf %edx, %ecx" "\n\t"
+" add %ecx, %eax" "\n\t"
+" leave" "\n\t"
+" ret" "\n\t"
+".size __strlen_sse2, .-__strlen_sse2" "\n\t"
+".previous\n"
+);
+
+extern int __strlen_sse2 ( char* );
+
+int main ( void )
+{
+ int i;
+ char* str = malloc(4);
+ str[0] = str[1] = 'x';
+ str[2] = 0;
+ printf("len is %d\n", __strlen_sse2(str));
+ free(str);
+
+ str = malloc(12);
+ for (i = 0; i < 12-2; i++)
+ str[i] = 'y';
+ str[i] = 0;
+ printf("len is %d\n", __strlen_sse2(str));
+ free(str);
+
+ return 0;
+}
|