"Ronald S. Bultje" <[email protected]> writes:
> This will be useful to test more aggressively for failures to mark XMM
> registers as clobbered in Win64 builds, and prevent regressions thereof.
> ---
> configure | 13 ++++
> libavcodec/x86/Makefile | 1 +
> libavcodec/x86/w64xmmtest.c | 138
> +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 152 insertions(+), 0 deletions(-)
> create mode 100644 libavcodec/x86/w64xmmtest.c
>
> diff --git a/configure b/configure
> index 49f9af2..d79fc41 100755
> --- a/configure
> +++ b/configure
> @@ -116,6 +116,9 @@ Configuration options:
> disable buffer boundary checking in bitreaders
> (faster, but may crash)
> --enable-memalign-hack emulate memalign, interferes with memory debuggers
> + --enable-win64-xmm-clobber-test
> + check XMM registers for clobbering (Win64-only;
> + should be used only for debugging purposes)
> --disable-everything disable all components listed below
> --disable-encoder=NAME disable encoder NAME
> --enable-encoder=NAME enable encoder NAME
This should be in the "Developer options" section.
> @@ -991,6 +994,7 @@ CONFIG_LIST="
> vda
> vdpau
> version3
> + win64_xmm_clobber_test
> x11grab
> zlib
> "
> @@ -3064,6 +3068,15 @@ enabled extra_warnings && check_cflags -Winline
> check_ldflags -Wl,--warn-common
> check_ldflags
> -Wl,-rpath-link=libpostproc:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
> test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
> +enabled win64_xmm_clobber_test && \
> + check_ldflags -Wl,--wrap,avcodec_open2 \
> + -Wl,--wrap,avcodec_decode_audio4 \
> + -Wl,--wrap,avcodec_decode_video2 \
> + -Wl,--wrap,avcodec_decode_subtitle2 \
> + -Wl,--wrap,avcodec_encode_audio2 \
> + -Wl,--wrap,avcodec_encode_video \
> + -Wl,--wrap,avcodec_encode_subtitle || \
> + disable win64_xmm_clobber_test
Please add a blank line before this. Aligning the backslashes would
look nicer.
> echo "X{};" > $TMPV
> if test_ldflags -Wl,--version-script,$TMPV; then
> diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
> index 930ace7..1bdeae0 100644
> --- a/libavcodec/x86/Makefile
> +++ b/libavcodec/x86/Makefile
> @@ -74,3 +74,4 @@ OBJS-$(HAVE_MMX) += x86/dsputil_mmx.o
> \
> x86/mpegvideo_mmx.o \
> x86/simple_idct_mmx.o \
>
> +OBJS-$(CONFIG_WIN64_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
> diff --git a/libavcodec/x86/w64xmmtest.c b/libavcodec/x86/w64xmmtest.c
> new file mode 100644
> index 0000000..61e7461
> --- /dev/null
> +++ b/libavcodec/x86/w64xmmtest.c
> @@ -0,0 +1,138 @@
> +/*
> + * check XMM registers for clobbers on Win64
That comment would make more sense in the doxygen @file note below.
> + * Copyright (c) 2008 Ramiro Polla <[email protected]>
Really?
> + * This file is part of Libav.
> + *
> + * Libav is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * Libav 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
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +/**
> + * @file
> + */
> +
> +#include <stdlib.h>
> +#include <stdarg.h>
> +
> +#include "avcodec.h"
> +#include "dsputil.h"
> +
> +#define testxmmclobbers(func, ...) \
> + LOCAL_ALIGNED_16(uint8_t, xmm, [2][10*16]); \
Wrong syntax for LOCAL_ALIGNED_16. This only works because it expands
to DECLARE_ALIGNED on x86. You could also use a normal declaration and
unaligned load/store instructions. It's not like the speed matters.
> + int ret; \
> + __asm volatile( \
__asm__
> + "movaps %%xmm6 , 0x00(%0)\n\t" \
> + "movaps %%xmm7 , 0x10(%0)\n\t" \
> + "movaps %%xmm8 , 0x20(%0)\n\t" \
> + "movaps %%xmm9 , 0x30(%0)\n\t" \
> + "movaps %%xmm10, 0x40(%0)\n\t" \
> + "movaps %%xmm11, 0x50(%0)\n\t" \
> + "movaps %%xmm12, 0x60(%0)\n\t" \
> + "movaps %%xmm13, 0x70(%0)\n\t" \
> + "movaps %%xmm14, 0x80(%0)\n\t" \
> + "movaps %%xmm15, 0x90(%0)\n\t" \
> + ::"r"(xmm[0]) : "memory"); \
Space after ::, please.
> + ret = __real_avcodec_ ## func(__VA_ARGS__); \
> + __asm volatile( \
__asm__
> + "movaps %%xmm6 , 0x00(%0)\n\t" \
> + "movaps %%xmm7 , 0x10(%0)\n\t" \
> + "movaps %%xmm8 , 0x20(%0)\n\t" \
> + "movaps %%xmm9 , 0x30(%0)\n\t" \
> + "movaps %%xmm10, 0x40(%0)\n\t" \
> + "movaps %%xmm11, 0x50(%0)\n\t" \
> + "movaps %%xmm12, 0x60(%0)\n\t" \
> + "movaps %%xmm13, 0x70(%0)\n\t" \
> + "movaps %%xmm14, 0x80(%0)\n\t" \
> + "movaps %%xmm15, 0x90(%0)\n\t" \
> + ::"r"(xmm[1]) : "memory"); \
> + if (memcmp(xmm[0], xmm[1], 10*16)) { \
> + int i; \
> + av_log(avctx, AV_LOG_ERROR, \
> + "XMM REGS CLOBBERED IN %s!\n", \
> + __func__); \
This will print the function as __wrap_foo. If you don't like that, you
can't use __func__. Use "avcodec" #func to print the non-mangled name.
> + for (i = 0; i < 10*16; i++) \
> + if (xmm[0][i] != xmm[1][i]) \
> + av_log(avctx, AV_LOG_ERROR, \
> + "xmm[0][%x] = %02x, " \
> + "xmm[1][%x] = %02x\n", \
> + i, xmm[0][i], \
> + i, xmm[1][i]); \
The output of this would be much more readable if you printed one
register per line.
> + abort(); \
> + } \
> + return ret
--
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel