]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/89093 (C++ exception handling clobbers d8 VFP register)
authorRamana Radhakrishnan <ramana.radhakrishnan@arm.com>
Tue, 23 Apr 2019 10:03:41 +0000 (10:03 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 23 Apr 2019 10:03:41 +0000 (12:03 +0200)
PR target/89093
* config/arm/arm.c (aapcs_vfp_is_call_or_return_candidate): Diagnose
if used with general-regs-only.
(arm_conditional_register_usage): Don't add non-general regs if
general-regs-only.
(arm_valid_target_attribute_rec): Handle general-regs-only.
* config/arm/arm.h (TARGET_HARD_FLOAT): Return false if
general-regs-only.
(TARGET_HARD_FLOAT_SUB): Define.
(TARGET_SOFT_FLOAT): Define as negation of TARGET_HARD_FLOAT_SUB.
(TARGET_REALLY_IWMMXT): Add && !TARGET_GENERAL_REGS_ONLY.
(TARGET_REALLY_IWMMXT2): Likewise.
* config/arm/arm.opt: Add -mgeneral-regs-only.
* doc/extend.texi: Document ARM general-regs-only target.
* doc/invoke.texi: Document ARM -mgeneral-regs-only.
libgcc/
* config/arm/pr-support.c: Add #pragma GCC target("general-regs-only").
* config/arm/unwind-arm.c: Likewise.
* unwind-c.c (PERSONALITY_FUNCTION): Add general-regs-only target
attribute for ARM.
libobjc/
* exception.c (PERSONALITY_FUNCTION): Add general-regs-only target
attribute for ARM.
libphobos/
* libdruntime/gcc/deh.d: Import gcc.attribute.
(personality_fn_attributes): New enum.
(scanLSDA, CONTINUE_UNWINDING, gdc_personality, __gdc_personality):
Add @personality_fn_attributes.
libstdc++-v3/
* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Add
general-regs-only target attribute for ARM.

Co-Authored-By: Bernd Edlinger <bernd.edlinger@hotmail.de>
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r270504

16 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/arm.h
gcc/config/arm/arm.opt
gcc/doc/extend.texi
gcc/doc/invoke.texi
libgcc/ChangeLog
libgcc/config/arm/pr-support.c
libgcc/config/arm/unwind-arm.c
libgcc/unwind-c.c
libobjc/ChangeLog
libobjc/exception.c
libphobos/ChangeLog
libphobos/libdruntime/gcc/deh.d
libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/eh_personality.cc

index 3d0327543994a4466a8f4c5e285878f5baa7a107..185cf518746a16d0c965c1196654ec456efff456 100644 (file)
@@ -1,3 +1,23 @@
+2019-04-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/89093
+       * config/arm/arm.c (aapcs_vfp_is_call_or_return_candidate): Diagnose
+       if used with general-regs-only.
+       (arm_conditional_register_usage): Don't add non-general regs if
+       general-regs-only.
+       (arm_valid_target_attribute_rec): Handle general-regs-only.
+       * config/arm/arm.h (TARGET_HARD_FLOAT): Return false if
+       general-regs-only.
+       (TARGET_HARD_FLOAT_SUB): Define.
+       (TARGET_SOFT_FLOAT): Define as negation of TARGET_HARD_FLOAT_SUB.
+       (TARGET_REALLY_IWMMXT): Add && !TARGET_GENERAL_REGS_ONLY.
+       (TARGET_REALLY_IWMMXT2): Likewise.
+       * config/arm/arm.opt: Add -mgeneral-regs-only.
+       * doc/extend.texi: Document ARM general-regs-only target.
+       * doc/invoke.texi: Document ARM -mgeneral-regs-only.
+
 2019-04-23  Bin Cheng  <bin.cheng@linux.alibaba.com>
 
        PR tree-optimization/90078
index 731150d7c18f2f4168a292a3e4c6dc74ad415075..45abcd89963495e671104426148e0508810763b1 100644 (file)
@@ -6112,6 +6112,11 @@ aapcs_vfp_is_call_or_return_candidate (enum arm_pcs pcs_variant,
     return false;
 
   *base_mode = new_mode;
+
+  if (TARGET_GENERAL_REGS_ONLY)
+    error ("argument of type %qT not permitted with -mgeneral-regs-only",
+          type);
+
   return true;
 }
 
@@ -28404,7 +28409,7 @@ arm_conditional_register_usage (void)
        }
     }
 
-  if (TARGET_REALLY_IWMMXT)
+  if (TARGET_REALLY_IWMMXT && !TARGET_GENERAL_REGS_ONLY)
     {
       regno = FIRST_IWMMXT_GR_REGNUM;
       /* The 2002/10/09 revision of the XScale ABI has wCG0
@@ -30878,6 +30883,9 @@ arm_valid_target_attribute_rec (tree args, struct gcc_options *opts)
       else if (!strcmp (q, "arm"))
        opts->x_target_flags &= ~MASK_THUMB;
 
+      else if (!strcmp (q, "general-regs-only"))
+       opts->x_target_flags |= MASK_GENERAL_REGS_ONLY;
+
       else if (!strncmp (q, "fpu=", 4))
        {
          int fpu_index;
index 7adafead0f20832467b873f53d298a2e1a25ab0a..4866e1e4b7dcab61ae51aeae9f12bd9014805a05 100644 (file)
@@ -122,12 +122,18 @@ extern tree arm_fp16_type_node;
 #define TARGET_32BIT_P(flags)  (TARGET_ARM_P (flags) || TARGET_THUMB2_P (flags))
 
 /* Run-time Target Specification.  */
-/* Use hardware floating point instructions. */
-#define TARGET_HARD_FLOAT      (arm_float_abi != ARM_FLOAT_ABI_SOFT    \
+/* Use hardware floating point instructions. -mgeneral-regs-only prevents
+the use of floating point instructions and registers but does not prevent
+emission of floating point pcs attributes.  */
+#define TARGET_HARD_FLOAT_SUB  (arm_float_abi != ARM_FLOAT_ABI_SOFT    \
                                 && bitmap_bit_p (arm_active_target.isa, \
                                                  isa_bit_vfpv2) \
                                 && TARGET_32BIT)
-#define TARGET_SOFT_FLOAT      (!TARGET_HARD_FLOAT)
+
+#define TARGET_HARD_FLOAT      (TARGET_HARD_FLOAT_SUB          \
+                                && !TARGET_GENERAL_REGS_ONLY)
+
+#define TARGET_SOFT_FLOAT      (!TARGET_HARD_FLOAT_SUB)
 /* User has permitted use of FP instructions, if they exist for this
    target.  */
 #define TARGET_MAYBE_HARD_FLOAT (arm_float_abi != ARM_FLOAT_ABI_SOFT)
@@ -135,8 +141,10 @@ extern tree arm_fp16_type_node;
 #define TARGET_HARD_FLOAT_ABI          (arm_float_abi == ARM_FLOAT_ABI_HARD)
 #define TARGET_IWMMXT                  (arm_arch_iwmmxt)
 #define TARGET_IWMMXT2                 (arm_arch_iwmmxt2)
-#define TARGET_REALLY_IWMMXT           (TARGET_IWMMXT && TARGET_32BIT)
-#define TARGET_REALLY_IWMMXT2          (TARGET_IWMMXT2 && TARGET_32BIT)
+#define TARGET_REALLY_IWMMXT           (TARGET_IWMMXT && TARGET_32BIT \
+                                        && !TARGET_GENERAL_REGS_ONLY)
+#define TARGET_REALLY_IWMMXT2          (TARGET_IWMMXT2 && TARGET_32BIT \
+                                        && !TARGET_GENERAL_REGS_ONLY)
 #define TARGET_IWMMXT_ABI (TARGET_32BIT && arm_abi == ARM_ABI_IWMMXT)
 #define TARGET_ARM                      (! TARGET_THUMB)
 #define TARGET_EITHER                  1 /* (TARGET_ARM | TARGET_THUMB) */
index 94c68753c247bdf175a5916cbec06fcf2f8e64d8..9067d491b9c5fd9e1552a912e57d127b7770b858 100644 (file)
@@ -302,3 +302,7 @@ When linking for big-endian targets, generate a legacy BE32 format image.
 mbranch-cost=
 Target RejectNegative Joined UInteger Var(arm_branch_cost) Init(-1)
 Cost to assume for a branch insn.
+
+mgeneral-regs-only
+Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Save
+Generate code which uses the core registers only (r0-r14).
index 0bb1fd23686a5ad972b375100c72019d0c34696d..91679e8b9bae9001645c735cf5078cc928f2b245 100644 (file)
@@ -4190,6 +4190,15 @@ into the @code{sjli} table needs to be passed as argument.
 These function attributes are supported for ARM targets:
 
 @table @code
+
+@item general-regs-only
+@cindex @code{general-regs-only} function attribute, ARM
+Indicates that no floating-point or Advanced SIMD registers should be
+used when generating code for this function.  If the function explicitly
+uses floating-point code, then the compiler gives an error.  This is
+the same behavior as that of the command-line option
+@option{-mgeneral-regs-only}.
+
 @item interrupt
 @cindex @code{interrupt} function attribute, ARM
 Use this attribute to indicate
index f4aa9e53de82d50b1d784fd8b1cefdc86f116bc5..29585cf15aacbec0ccded93c59cb76e20483bbab 100644 (file)
@@ -674,6 +674,7 @@ Objective-C and Objective-C++ Dialects}.
 -mabi=@var{name} @gol
 -mapcs-stack-check  -mno-apcs-stack-check @gol
 -mapcs-reentrant  -mno-apcs-reentrant @gol
+-mgeneral-regs-only @gol
 -msched-prolog  -mno-sched-prolog @gol
 -mlittle-endian  -mbig-endian @gol
 -mbe8  -mbe32 @gol
@@ -17068,6 +17069,12 @@ the hard-float and soft-float ABIs are not link-compatible; you must
 compile your entire program with the same ABI, and link with a
 compatible set of libraries.
 
+@item -mgeneral-regs-only
+@opindex mgeneral-regs-only
+Generate code which uses only the general-purpose registers.  This will prevent
+the compiler from using floating-point and Advanced SIMD registers but will not
+impose any restrictions on the assembler.
+
 @item -mlittle-endian
 @opindex mlittle-endian
 Generate code for a processor running in little-endian mode.  This is
index de8d56a2ee759caa6138c4aff822dbaf8a318291..30e4da4277eebc6f4315b9f84193dce298b9c29e 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/89093
+       * config/arm/pr-support.c: Add #pragma GCC target("general-regs-only").
+       * config/arm/unwind-arm.c: Likewise.
+       * unwind-c.c (PERSONALITY_FUNCTION): Add general-regs-only target
+       attribute for ARM.
+
 2019-04-15  Monk Chiang  <sh.chiang04@gmail.com>
 
        * config/nds32/linux-unwind.h (SIGRETURN): Remove.
index ed557394e9f7fb4f70d45681b0652d4b735f3adb..bcf9b288fe9b302243e2e7e881100b109fbd15e9 100644 (file)
@@ -21,6 +21,7 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#pragma GCC target ("general-regs-only")
 #include "unwind.h"
 
 /* We add a prototype for abort here to avoid creating a dependency on
index 00e183d325dd4624fe715d7c59a1711386a78aa9..9ba73e72a2a76b8048ee456b762dbac7c13ae337 100644 (file)
@@ -21,6 +21,7 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#pragma GCC target ("general-regs-only")
 #include "unwind.h"
 
 /* Misc constants.  */
index 3e55cda7f7b5320e9449ce4c89c5e6922ac418aa..859735a332505e9e63b39362b7c44b2136bb4080 100644 (file)
@@ -106,6 +106,7 @@ PERSONALITY_FUNCTION (_Unwind_State, struct _Unwind_Exception *,
                      struct _Unwind_Context *);
 
 _Unwind_Reason_Code
+__attribute__((target ("general-regs-only")))
 PERSONALITY_FUNCTION (_Unwind_State state,
                      struct _Unwind_Exception * ue_header,
                      struct _Unwind_Context * context)
index 90cf92331e9507c0d4eda1af48e9d0de325943be..48e21e5b21c087e8e29a4a17da493addbf00ca01 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/89093
+       * exception.c (PERSONALITY_FUNCTION): Add general-regs-only target
+       attribute for ARM.
+
 2019-03-06  Uroš Bizjak  <ubizjak@gmail.com>
 
        * encoding.c (DFmode): #undef before #define.
index b96630c75eea447223d1ffe0af238f16b4bf97f5..3c078c041269d769f07ff637680d41976f9fa830 100644 (file)
@@ -220,6 +220,7 @@ get_ttype_entry (struct lsda_header_info *info, _Unwind_Word i)
   while (0)
 
 _Unwind_Reason_Code
+__attribute__((target ("general-regs-only")))
 PERSONALITY_FUNCTION (_Unwind_State state,
                      struct _Unwind_Exception *ue_header,
                      struct _Unwind_Context *context)
index 4f158776e233a37600ee96065a77c7a93417b9b8..74c9c88730d2b9b30caa8aff00dc049ff666c6d0 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/89093
+       * libdruntime/gcc/deh.d: Import gcc.attribute.
+       (personality_fn_attributes): New enum.
+       (scanLSDA, CONTINUE_UNWINDING, gdc_personality, __gdc_personality):
+       Add @personality_fn_attributes.
+
 2019-04-20  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        PR d/89293
index c04dc21263b9d77006fe0c74a21ed143ce204222..ee301b2a3ba1b57639f58f633a202d3bd049161b 100644 (file)
@@ -28,6 +28,7 @@ import gcc.unwind;
 import gcc.unwind.pe;
 import gcc.builtins;
 import gcc.config;
+import gcc.attribute;
 
 extern(C)
 {
@@ -519,10 +520,19 @@ extern(C) void _d_throw(Throwable object)
     terminate("unwind error", __LINE__);
 }
 
+static if (GNU_ARM_EABI_Unwinder)
+{
+    enum personality_fn_attributes = attribute("target", ("general-regs-only"));
+}
+else
+{
+    enum personality_fn_attributes = "";
+}
 
 /**
  * Read and extract information from the LSDA (.gcc_except_table section).
  */
+@personality_fn_attributes
 _Unwind_Reason_Code scanLSDA(const(ubyte)* lsda, _Unwind_Exception_Class exceptionClass,
                              _Unwind_Action actions, _Unwind_Exception* unwindHeader,
                              _Unwind_Context* context, _Unwind_Word cfa,
@@ -772,6 +782,7 @@ int actionTableLookup(_Unwind_Action actions, _Unwind_Exception* unwindHeader,
  * Called when the personality function has found neither a cleanup or handler.
  * To support ARM EABI personality routines, that must also unwind the stack.
  */
+@personality_fn_attributes
 _Unwind_Reason_Code CONTINUE_UNWINDING(_Unwind_Exception* unwindHeader, _Unwind_Context* context)
 {
     static if (GNU_ARM_EABI_Unwinder)
@@ -814,6 +825,7 @@ else
 static if (GNU_ARM_EABI_Unwinder)
 {
     pragma(mangle, PERSONALITY_FUNCTION)
+    @personality_fn_attributes
     extern(C) _Unwind_Reason_Code gdc_personality(_Unwind_State state,
                                                   _Unwind_Exception* unwindHeader,
                                                   _Unwind_Context* context)
@@ -873,6 +885,7 @@ else
     }
 }
 
+@personality_fn_attributes
 private _Unwind_Reason_Code __gdc_personality(_Unwind_Action actions,
                                               _Unwind_Exception_Class exceptionClass,
                                               _Unwind_Exception* unwindHeader,
index 2533fe81f6cf9e101552e984e1577fcc9fa2ec8f..e222cb30de9bf4f4f9cee91bd501c6fa0648f543 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/89093
+       * libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Add
+       general-regs-only target attribute for ARM.
+
 2019-04-23  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/87431
index d1cc62257426c1c1d26e82749bced64c524d645f..35e4e461d69d35093647e1afe828d0359976badb 100644 (file)
@@ -343,6 +343,7 @@ extern "C"
 #endif
 _Unwind_Reason_Code
 #ifdef __ARM_EABI_UNWINDER__
+__attribute__((target ("general-regs-only")))
 PERSONALITY_FUNCTION (_Unwind_State state,
                      struct _Unwind_Exception* ue_header,
                      struct _Unwind_Context* context)