Go to file
Christophe Lyon 3c3b422487 arm: Warn if IRQ handler is not compiled with -mgeneral-regs-only [PR target/94743]
The interrupt attribute does not guarantee that the FP registers are
saved, which can result in problems difficult to debug.

Saving the FP registers and status registers can be a large penalty,
so it's probably not desirable to do that all the time.

If the handler calls other functions, we'd likely need to save all of
them, for lack of knowledge of which registers they actually clobber.

This is even more obscure for the end-user when the compiler inserts
calls to helper functions such as memcpy (some multilibs do use FP
registers to speed it up).

In the PR, we discussed adding routines in libgcc to save the FP
context and saving only locally-clobbered FP registers, but this seems
to be too much work for the purpose, given that in general such
handlers try to avoid this kind of penalty.
I suspect we would also want new attributes to instruct the compiler
that saving the FP context is not needed.

In the mean time, emit a warning to suggest re-compiling with
-mgeneral-regs-only. Note that this can lead to errors if the code
uses floating-point and -mfloat-abi=hard, eg:
argument of type 'double' not permitted with -mgeneral-regs-only

This can be troublesome for the user, but at least this would make
him aware of the latent issue.

The patch adds several testcases:

- pr94734-1-hard.c checks that a warning is emitted when using
  -mfloat-abi=hard. Function IRQ_HDLR_Test can make implicit calls to
  runtime floating-point routines (or direct use of FP instructions),
  IRQ_HDLR_Test2 doesn't. We emit a warning in both cases, though.

- pr94734-1-softfp.c: same as above wih -mfloat-abi=softfp.

- pr94734-1-soft.c checks that no warning is emitted when using
  -mfloat-abi=soft when the same code as above.

- pr94734-2.c checks that no warning is emitted when using
  -mgeneral-regs-only.

- pr94734-3.c checks that no warning is emitted when using
  -mgeneral-regs-only even using float-point data.

2020-06-30  Christophe Lyon  <christophe.lyon@linaro.org>

	PR target/94743
	gcc/
	* config/arm/arm.c (arm_handle_isr_attribute): Warn if
	-mgeneral-regs-only is not used.

	gcc/testsuite/
	* gcc.misc-tests/arm-isr.c: Add -mgeneral-regs-only.
	* gcc.target/arm/empty_fiq_handler.c: Add -mgeneral-regs-only.
	* gcc.target/arm/interrupt-1.c: Add -mgeneral-regs-only.
	* gcc.target/arm/interrupt-2.c: Add -mgeneral-regs-only.
	* gcc.target/arm/pr70830.c: Add -mgeneral-regs-only.
	* gcc.target/arm/pr94743-1-hard.c: New test.
	* gcc.target/arm/pr94743-1-soft.c: New test.
	* gcc.target/arm/pr94743-1-softfp.c: New test.
	* gcc.target/arm/pr94743-2.c: New test.
	* gcc.target/arm/pr94743-3.c: New test.
2020-06-30 14:20:28 +00:00
config
contrib Daily bump. 2020-06-30 09:02:21 +00:00
fixincludes
gcc arm: Warn if IRQ handler is not compiled with -mgeneral-regs-only [PR target/94743] 2020-06-30 14:20:28 +00:00
gnattools
gotools
include Daily bump. 2020-06-27 00:16:24 +00:00
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp
libdecnumber
libffi
libgcc
libgfortran
libgo
libgomp Daily bump. 2020-06-28 00:16:21 +00:00
libhsail-rt
libiberty Daily bump. 2020-06-27 00:16:24 +00:00
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer
libssp
libstdc++-v3 Daily bump. 2020-06-30 09:02:21 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
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.