[PATCH, ARM] Don't pull in unwinder for 64-bit division routines
Julian Brown
julian@codesourcery.com
Fri Jul 20 10:15:00 GMT 2012
Hi,
This (old!) patch avoids uselessly pulling in the unwinder for 64-bit
division routines. I last posted it here:
http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01618.html
Other people have noticed the same issue, e.g.:
http://gcc.gnu.org/ml/gcc-help/2011-03/msg00187.html
Note that we take special care already for the case where
division-by-zero throws an exception: we tailcall the division-by-zero
handler at the head of the 64-bit division helper routines, so never
create a stack frame which needs to be unwound. On ARM, division by
zero can trapped by defining magic __aeabi_[il]div0 functions. See
here:
http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01661.html
Unfortunately, despite that, throwing an exception from the
division-by-zero handler functions doesn't appear to work at present --
either with or without the current patch. I'm not intending to tackle
that now (see attached program -- which exits with "terminate called
after throwing an instance of 'int'" for me). I'm no C++ expert, so I
might have done something dumb :-).
Anyway: this revised version of the patch removes the strange libgcc
Makefile-fragment changes, the equivalent of which have since been
incorporated into mainline GCC now anyway, so the patch is somewhat
more straightforward than it was previously.
The patch allows a trivial program using 64-bit division (on bare metal)
to shrink quite considerably:
$ arm-none-eabi-size div64
text data bss dec hex filename
13120 2404 276 15800 3db8 div64
$ arm-none-eabi-size div64-unpatched
text data bss dec hex filename
20064 2404 276 22744 58d8 div64-unpatched
OK to apply?
Thanks,
Julian
ChangeLog
libgcc/
* config.host (arm*-*-linux-*eabi, arm*-*-uclinux*eabi)
(arm*-*-eabi*, arm*-*-symbianelf*, arm*-*-rtemseabi*): Add
arm/t-divmod-ef to tmake_file.
* Makefile.in (LIB2_DIVMOD_EXCEPTION_FLAGS): Default to -fexceptions
-fnon-call-exceptions if not defined.
($(lib2-divmod-o), $(lib2-divmod-s-o)): Use above.
* config/arm/t-divmod-ef: New file.
gcc/testsuite/
* gcc.target/arm/div64-unwinding.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: div64.cc
Type: text/x-c++src
Size: 396 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120720/51401e31/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no-unwinder-for-long-division-fsf-3.diff
Type: text/x-patch
Size: 3574 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120720/51401e31/attachment-0001.bin>
More information about the Gcc-patches
mailing list