This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] target/37283: Fix -fno-unit-at-a-time and -fno-toplevel-reorder handling


There are two problems wrt -fno-unit-at-a-time and -fno-toplevel-reorder:

 1- Those flags influence the setting of -fsection-anchors;
    however, they were looked at before calling handle_options, thus
    having a null effect.

 2- The ARM backend sets flag_section_anchors to 1 if
    optimization is used (in OPTIMIZATION_OPTIONS), leading to an
    error if 1- is fixed alone and -fno-toplevel-reorder is used as
    -fno-toplevel-reorder and -fsection-anchors are mutually exclusive.

This prevents the compilation of crtstuff.c when building an
compiler targetting arm-elf.

    gcc/
	PR target/37283
	* opts.c (decode_options): Move processing of -fno-unit-at-a-time
	and -fno-toplevel-reorder after handle_options.
	* config/arm/arm.c (arm_optimization_options): Set
	flag_section_anchors to 2 instead of 1 to distinguish it from
	-fsection-anchors given explicitely on the command line.

Tested on i686-pc-linux-gnu, native and cross to arm-elf.
Ok for trunk?
---
 gcc/config/arm/arm.c |    6 ++++--
 gcc/opts.c           |   43 +++++++++++++++++++------------------------
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 888a242..328514e 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -19112,8 +19112,10 @@ arm_order_regs_for_local_alloc (void)
 void
 arm_optimization_options (int level, int size ATTRIBUTE_UNUSED)
 {
-  /* Enable section anchors by default at -O1 or higher.  */
-  flag_section_anchors = (level > 0 ? 1 : 0);
+  /* Enable section anchors by default at -O1 or higher.
+     Use 2 to distinguish from an explicit -fsection-anchors
+     given on the command line.  */
+  flag_section_anchors = (level > 0 ? 2 : 0);
 }
 
 #include "gt-arm.h"
diff --git a/gcc/opts.c b/gcc/opts.c
index fbe6756..cc320a2 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -866,18 +866,6 @@ decode_options (unsigned int argc, const char **argv)
 	}
     }
   
-  if (!flag_unit_at_a_time)
-    {
-      flag_section_anchors = 0;
-      flag_toplevel_reorder = 0;
-    }
-  if (!flag_toplevel_reorder)
-    {
-      if (flag_section_anchors == 1)
-        error ("Section anchors must be disabled when toplevel reorder is disabled.");
-      flag_section_anchors = 0;
-    }
-
 #ifdef IRA_COVER_CLASSES
   /* Use IRA if it is implemented for the target.  */
   flag_ira = 1;
@@ -886,18 +874,7 @@ decode_options (unsigned int argc, const char **argv)
   /* Originally we just set the variables if a particular optimization level,
      but with the advent of being able to change the optimization level for a
      function, we need to reset optimizations.  */
-  if (!optimize)
-    {
-      flag_merge_constants = 0;
-
-      /* We disable toplevel reordering at -O0 to disable transformations that
-         might be surprising to end users and to get -fno-toplevel-reorder
-	 tested, but we keep section anchors.  */
-      if (flag_toplevel_reorder == 2)
-        flag_toplevel_reorder = 0;
-    }
-  else
-    flag_merge_constants = 1;
+  flag_merge_constants = optimize;
 
   /* -O1 optimizations.  */
   opt1 = (optimize >= 1);
@@ -1058,6 +1035,24 @@ decode_options (unsigned int argc, const char **argv)
 
   handle_options (argc, argv, lang_mask);
 
+  /* -fno-unit-at-a-time and -fno-toplevel-reorder handling.  */
+  if (!flag_unit_at_a_time)
+    {
+      /* We disable toplevel reordering at -O0 to disable transformations that
+	 might be surprising to end users and to get -fno-toplevel-reorder
+	 tested, but we keep section anchors.  */
+      flag_section_anchors = 0;
+      flag_toplevel_reorder = 0;
+    }
+  else if (!optimize && flag_toplevel_reorder == 2)
+        flag_toplevel_reorder = 0;
+  else if (!flag_toplevel_reorder)
+    {
+      if (flag_section_anchors == 1)
+        error ("ection anchors must be disabled when toplevel reorder is disabled");
+      flag_section_anchors = 0;
+    }
+
   if (first_time_p)
     {
       if (flag_pie)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]