aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/i386-sse.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-12-06 16:01:47 +0100
committerTom de Vries <tdevries@suse.de>2021-12-06 16:01:47 +0100
commitb082698c5cb9c076628476b132a140ca78e9c03b (patch)
tree73528b1aa825c443e5329e7ce3bf6c8ddf6c8dff /gdb/testsuite/gdb.arch/i386-sse.c
parent197a63068b10d50c01fbe024a45d47cd25a907e3 (diff)
downloadgdb-b082698c5cb9c076628476b132a140ca78e9c03b.zip
gdb-b082698c5cb9c076628476b132a140ca78e9c03b.tar.gz
gdb-b082698c5cb9c076628476b132a140ca78e9c03b.tar.bz2
[gdb/testsuite] Use precise align in gdb.arch/i386-{avx,sse}.exp
Test-cases gdb.arch/i386-{avx,sse}.exp use assembly instructions that require the memory operands to be aligned to a certain boundary, and the test-cases use C11's _Alignas to make that happen. The draw-back of using _Alignas is that while it does enforce a minimum alignment, the actual alignment may be bigger, which makes the following scenario possible: - copy say, gdb.arch/i386-avx.c as basis for a new test-case - run the test-case and observe a PASS - commit the new test-case in the supposition that the test-case is correct and well-tested - run later into a failure on a different test setup (which may be a setup where reproduction and investigation is more difficult and time-consuming), and find out that the specified alignment was incorrect and should have been updated to say, 64 bytes. The initial PASS occurred only because the actual alignment happened to be greater than required. The idea of having precise alignment as a means of having more predictable execution which allows flushing out bugs earlier, has been filed as PR gcc/103095. Add a new file lib/precise-aligned-alloc.c with functions precise_aligned_alloc and precise_aligned_dup, to support precise alignment. Use precise_aligned_dup in aforementioned test-cases to: - verify that the specified alignment is indeed sufficient, rather than too little but accidentally over-aligned. - prevent the same type of problems in any new test-cases based on these Tested on x86_64-linux, with both gcc and clang.
Diffstat (limited to 'gdb/testsuite/gdb.arch/i386-sse.c')
-rw-r--r--gdb/testsuite/gdb.arch/i386-sse.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.arch/i386-sse.c b/gdb/testsuite/gdb.arch/i386-sse.c
index 10bd4b6..e51f88b 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.c
+++ b/gdb/testsuite/gdb.arch/i386-sse.c
@@ -28,7 +28,7 @@ typedef struct {
} v4sf_t;
-v4sf_t data[] =
+v4sf_t data_orig[] =
{
{ { 0.0, 0.25, 0.50, 0.75 } },
{ { 1.0, 1.25, 1.50, 1.75 } },
@@ -65,9 +65,16 @@ have_sse (void)
return 0;
}
+#include "../lib/precise-aligned-alloc.c"
+
int
main (int argc, char **argv)
{
+ void *allocated_ptr;
+ v4sf_t *data
+ = precise_aligned_dup (ALIGN, sizeof (data_orig), &allocated_ptr,
+ data_orig);
+
if (have_sse ())
{
asm ("movaps 0(%0), %%xmm0\n\t"
@@ -127,5 +134,7 @@ main (int argc, char **argv)
puts ("Bye!"); /* second breakpoint here */
}
+ free (allocated_ptr);
+
return 0;
}