Go to file
Jakub Jelinek a91e5d8897 i386: Make xmm16-xmm31 call used even in ms ABI [PR65782]
On Tue, Feb 04, 2020 at 11:16:06AM +0100, Uros Bizjak wrote:
> I guess that Comment #9 patch form the PR should be trivially correct,
> but althouhg it looks obvious, I don't want to propose the patch since
> I have no means of testing it.

I don't have means of testing it either.
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2019
is quite explicit that [xyz]mm16-31 are call clobbered and only xmm6-15 (low
128-bits only) are call preserved.

We are talking e.g. about
/* { dg-options "-O2 -mabi=ms -mavx512vl" } */

typedef double V __attribute__((vector_size (16)));
void foo (void);
V bar (void);
void baz (V);
void
qux (void)
{
  V c;
  {
    register V a __asm ("xmm18");
    V b = bar ();
    asm ("" : "=x" (a) : "0" (b));
    c = a;
  }
  foo ();
  {
    register V d __asm ("xmm18");
    V e;
    d = c;
    asm ("" : "=x" (e) : "0" (d));
    baz (e);
  }
}
where according to the MSDN doc gcc incorrectly holds the c value
in xmm18 register across the foo call; if foo is compiled by some Microsoft
compiler (or LLVM), then it could clobber %xmm18.
If all xmm18 occurrences are changed to say xmm15, then it is valid to hold
the 128-bit value across the foo call (though, surprisingly, LLVM saves it
into stack anyway).

The other parts are I guess mainly about SEH.  Consider e.g.
void
foo (void)
{
  register double x __asm ("xmm14");
  register double y __asm ("xmm18");
  asm ("" : "=x" (x));
  asm ("" : "=v" (y));
  x += y;
  y += x;
  asm ("" : : "x" (x));
  asm ("" : : "v" (y));
}
looking at cross-compiler output, with -O2 -mavx512f this emits
	.file	"abcdeq.c"
	.text
	.align 16
	.globl	foo
	.def	foo;	.scl	2;	.type	32;	.endef
	.seh_proc	foo
foo:
	subq	$40, %rsp
	.seh_stackalloc	40
	vmovaps %xmm14,	(%rsp)
	.seh_savexmm	%xmm14, 0
	vmovaps %xmm18,	16(%rsp)
	.seh_savexmm	%xmm18, 16
	.seh_endprologue
	vaddsd	%xmm18, %xmm14, %xmm14
	vaddsd	%xmm18, %xmm14, %xmm18
	vmovaps	(%rsp), %xmm14
	vmovaps	16(%rsp), %xmm18
	addq	$40, %rsp
	ret
	.seh_endproc
	.ident	"GCC: (GNU) 10.0.1 20200207 (experimental)"
Does whatever assembler mingw64 uses even assemble this (I mean the
.seh_savexmm %xmm16, 16 could be problematic)?
I can find e.g.
https://stackoverflow.com/questions/43152633/invalid-register-for-seh-savexmm-in-cygwin/43210527
which then links to
https://gcc.gnu.org/PR65782

2020-02-08  Uroš Bizjak  <ubizjak@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR target/65782
	* config/i386/i386.h (CALL_USED_REGISTERS): Make
	xmm16-xmm31 call-used even in 64-bit ms-abi.

	* gcc.target/i386/pr65782.c: New test.

Co-authored-by: Uroš Bizjak <ubizjak@gmail.com>
2020-02-13 21:46:13 +01:00
config Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
contrib test_summary: Do not escape "=". 2019-08-16 14:03:09 +02:00
fixincludes backport: re PR libgomp/93066 (libgomp/target.c:525:46: error: expected expression before ')' token) 2020-01-01 17:01:46 +00:00
gcc i386: Make xmm16-xmm31 call used even in ms ABI [PR65782] 2020-02-13 21:46:13 +01:00
gnattools Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
gotools Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
include Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
INSTALL
intl Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libada Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libatomic Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libbacktrace Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libcc1 Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libcpp backport: re PR preprocessor/92296 (internal compiler error: Segmentation fault #pragma push_macro("__LINE__")) 2019-11-08 19:59:14 +01:00
libdecnumber Fix libdecnumber handling of non-canonical BID significands (PR middle-end/91226). 2020-01-13 18:45:04 +00:00
libffi Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libgcc i386: Properly pop restore token in signal frame 2020-02-10 08:10:49 -08:00
libgfortran Bug 93234 - INQUIRE on pre-assigned files of ROUND and SIGN properties fails 2020-01-21 15:35:42 -08:00
libgo re PR go/91621 (libgo/mksysinfo.sh: please avoid test ==) 2019-09-10 20:32:42 +00:00
libgomp openmp: Fix handling of non-addressable shared scalars in parallel nested inside of target [PR93515] 2020-02-13 21:45:15 +01:00
libhsail-rt Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libiberty Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libitm Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libobjc Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
liboffloadmic Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libphobos [LIBPHOBOS] Fix multi-lib RUNTESTFLAGS handling 2019-10-30 12:51:15 +01:00
libquadmath backport: quadmath.h (M_Eq, [...]): Use two more decimal places. 2019-10-21 13:34:04 +02:00
libsanitizer backport: re PR sanitizer/92154 (new glibc breaks arm bootstrap due to libsanitizer) 2019-12-20 17:58:35 +01:00
libssp Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
libstdc++-v3 libstdc++: Simplify makefile rule for largefile-config.h (PR91947) 2020-01-24 11:18:43 +00:00
libvtv Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
lto-plugin Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
maintainer-scripts Update gcc_release to mainline version. 2020-01-13 15:58:45 +00:00
zlib Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
ChangeLog Update ChangeLog and version files for release 2019-08-12 09:38:49 +02:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in Add D front-end, libphobos library, and D2 testsuite. 2018-10-28 19:51:47 +00:00
config.guess Update config.guess, config.sub (PR target/88535) 2019-01-03 11:28:27 +00:00
config.rpath
config.sub Update config.guess, config.sub (PR target/88535) 2019-01-03 11:28:27 +00:00
configure PR d/87799 Fix D build on windows hosts 2019-04-14 09:52:22 +00:00
configure.ac PR d/87799 Fix D build on windows hosts 2019-04-14 09:52:22 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh libtool.m4: Sort output of 'find' to enable deterministic builds. 2018-07-05 13:13:45 -06:00
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Add myself to MAINTAINERS 2019-04-22 16:05:36 +00:00
Makefile.def Add D front-end, libphobos library, and D2 testsuite. 2018-10-28 19:51:47 +00:00
Makefile.in Come up with bootstrap-lto-lean config. 2019-04-09 08:49:14 +00:00
Makefile.tpl Come up with bootstrap-lto-lean config. 2019-04-09 08:49:14 +00:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
README
symlink-tree
test-driver Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.