gdb/testsuite/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 13 Jun 2012 21:31:06 +0000 (21:31 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 13 Jun 2012 21:31:06 +0000 (21:31 +0000)
PR tdep/14222
* gdb.arch/i386-sse-stack-align.S: New file.
* gdb.arch/i386-sse-stack-align.c: New file.
* gdb.arch/i386-sse-stack-align.exp: New file.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/i386-sse-stack-align.S [new file with mode: 0644]
gdb/testsuite/gdb.arch/i386-sse-stack-align.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/i386-sse-stack-align.exp [new file with mode: 0644]

index 511e0c6..a80019e 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       PR tdep/14222
+       * gdb.arch/i386-sse-stack-align.S: New file.
+       * gdb.arch/i386-sse-stack-align.c: New file.
+       * gdb.arch/i386-sse-stack-align.exp: New file.
+
 2012-06-13  Keith Seitz  <keiths@redhat.com>
 
        PR breakpoints/13798 and mi/11541
diff --git a/gdb/testsuite/gdb.arch/i386-sse-stack-align.S b/gdb/testsuite/gdb.arch/i386-sse-stack-align.S
new file mode 100644 (file)
index 0000000..18cffdc
--- /dev/null
@@ -0,0 +1,214 @@
+/* Copyright 2012 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/*
+   gcc -S -o gdb.arch/i386-sse-stack-align.{S,c} -Wall -m32 -msse
+ */
+
+       .file   "i386-sse-stack-align.c"
+       .text
+       .type   foo, @function
+foo:
+.LFB0:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $40, %esp
+       movaps  %xmm0, -24(%ebp)
+       movaps  %xmm1, -40(%ebp)
+       movaps  -24(%ebp), %xmm0
+       movaps  -40(%ebp), %xmm1
+       mulps   %xmm1, %xmm0
+       addps   -24(%ebp), %xmm0
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE0:
+       .size   foo, .-foo
+       .type   f, @function
+f:
+.LFB1:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $40, %esp
+       movaps  .LC0, %xmm0
+       movaps  %xmm0, -24(%ebp)
+       movaps  -24(%ebp), %xmm1
+       movaps  -24(%ebp), %xmm0
+       call    foo
+       movaps  %xmm0, -40(%ebp)
+       leal    -40(%ebp), %eax
+       movss   (%eax), %xmm0
+       cvttss2si       %xmm0, %eax
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE1:
+       .size   f, .-f
+       .type   g0, @function
+g0:
+.LFB2:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $8, %esp
+       call    f
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE2:
+       .size   g0, .-g0
+       .type   g1, @function
+g1:
+.LFB3:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $8, %esp
+       call    f
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE3:
+       .size   g1, .-g1
+       .type   g2, @function
+g2:
+.LFB4:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $8, %esp
+       call    f
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE4:
+       .size   g2, .-g2
+       .type   g3, @function
+g3:
+.LFB5:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $8, %esp
+       call    f
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE5:
+       .size   g3, .-g3
+       .type   g4, @function
+g4:
+.LFB6:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       subl    $8, %esp
+       call    f
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       ret
+       .cfi_endproc
+.LFE6:
+       .size   g4, .-g4
+       .globl  main
+       .type   main, @function
+main:
+.LFB7:
+       .cfi_startproc
+       pushl   %ebp
+       .cfi_def_cfa_offset 8
+       .cfi_offset 5, -8
+       movl    %esp, %ebp
+       .cfi_def_cfa_register 5
+       pushl   %ebx
+       andl    $-16, %esp
+       subl    $16, %esp
+       .cfi_offset 3, -12
+       call    g0
+       movl    %eax, %ebx
+       movl    $1, (%esp)
+       call    g1
+       addl    %eax, %ebx
+       movl    $2, 4(%esp)
+       movl    $1, (%esp)
+       call    g2
+       addl    %eax, %ebx
+       movl    $3, 8(%esp)
+       movl    $2, 4(%esp)
+       movl    $1, (%esp)
+       call    g3
+       addl    %eax, %ebx
+       movl    $4, 12(%esp)
+       movl    $3, 8(%esp)
+       movl    $2, 4(%esp)
+       movl    $1, (%esp)
+       call    g4
+       addl    %ebx, %eax
+       movl    -4(%ebp), %ebx
+       leave
+       .cfi_restore 5
+       .cfi_def_cfa 4, 4
+       .cfi_restore 3
+       ret
+       .cfi_endproc
+.LFE7:
+       .size   main, .-main
+       .section        .rodata
+       .align 16
+.LC0:
+       .long   1065353216
+       .long   1073741824
+       .long   1077936128
+       .long   1082130432
+       .ident  "GCC: (GNU) 4.6.4 20120612 (prerelease)"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/i386-sse-stack-align.c b/gdb/testsuite/gdb.arch/i386-sse-stack-align.c
new file mode 100644 (file)
index 0000000..b9daa9b
--- /dev/null
@@ -0,0 +1,70 @@
+/* Copyright 2012 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+typedef float V __attribute__((vector_size(16)));
+
+static V
+foo (V a, V b)
+{
+  return a + b * a;
+}
+
+static __attribute__((noinline, noclone)) int
+f (void)
+{
+  volatile V a = { 1, 2, 3, 4 };
+  volatile V b;
+
+  b = foo (a, a);
+  return b[0];
+}
+
+static __attribute__((noinline, noclone)) int
+g0 (void)
+{
+  return f ();
+}
+
+static __attribute__((noinline, noclone)) int
+g1 (int p1)
+{
+  return f ();
+}
+
+static __attribute__((noinline, noclone)) int
+g2 (int p1, int p2)
+{
+  return f ();
+}
+
+static __attribute__((noinline, noclone)) int
+g3 (int p1, int p2, int p3)
+{
+  return f ();
+}
+
+static __attribute__((noinline, noclone)) int
+g4 (int p1, int p2, int p3, int p4)
+{
+  return f ();
+}
+
+int
+main (void)
+{
+  return g0 () + g1 (1) + g2 (1, 2) + g3 (1, 2, 3) + g4 (1, 2, 3, 4);
+}
diff --git a/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp b/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp
new file mode 100644 (file)
index 0000000..5a04c74
--- /dev/null
@@ -0,0 +1,60 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if ![is_x86_like_target] {
+    verbose "Skipping x86 SSE stack alignment tests."
+    return
+}
+
+set testfile "i386-sse-stack-align"
+set srcfile ${testfile}.S
+set csrcfile ${testfile}.c
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+set opts {}
+
+if [info exists COMPILE] {
+    set srcfile ${csrcfile}
+    lappend opts debug optimize=-O2 additional_flags=-msse
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
+    unsupported "cannot compile ${srcfile}"
+    return -1
+}
+
+clean_restart $executable
+
+if ![runto_main] then {
+    return -1
+}
+
+set args ""
+foreach i {0 1 2 3 4} {
+    set test "print g$i ($args)"
+    gdb_test_multiple $test $test {
+       -re " = 2\r\n$gdb_prompt $" {
+           pass $test
+       }
+       -re "Program received signal SIGSEGV, Segmentation fault\\..*\r\n$gdb_prompt $" {
+           fail $test
+       }
+    }
+
+    if {$args != ""} {
+       set args "$args, "
+    }
+    set args "$args[expr $i + 1]"
+}