aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorChristian Bruel <christian.bruel@st.com>2016-01-27 14:03:45 +0100
committerChristian Bruel <chrbr@gcc.gnu.org>2016-01-27 14:03:45 +0100
commiteeb085f34166c7411a95913b3ff9c7dc0aad34f1 (patch)
tree894ce561eca6774f5039accc83c2303245a3c273 /gcc
parent4ecbadc72896ca5fa7a3cdeea84f4faafd3b0be3 (diff)
downloadgcc-eeb085f34166c7411a95913b3ff9c7dc0aad34f1.zip
gcc-eeb085f34166c7411a95913b3ff9c7dc0aad34f1.tar.gz
gcc-eeb085f34166c7411a95913b3ff9c7dc0aad34f1.tar.bz2
re PR target/69245 (ICE in extract_insn, at recog.c:2286 on arm-linux-gnueabihf)
2016-01-20 Christian Bruel <christian.bruel@st.com> PR target/69245 * config/arm/arm-c.c (arm_pragma_target_parse): Add comments. Move arm_reset_previous_fndecl and set_target_option_current_node in the conditional part. Call save_restore_target_globals. * config/arm/arm.c (arm_set_current_function): Refactor to better support #pragma target and attribute mix. Call save_restore_target_globals. * config/arm/arm-protos.h (save_restore_target_globals): New function. From-SVN: r232872
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/arm/arm-c.c15
-rw-r--r--gcc/config/arm/arm-protos.h1
-rw-r--r--gcc/config/arm/arm.c61
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/arm/pr69245.c26
6 files changed, 87 insertions, 32 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cffba02..76a2ccf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2016-01-20 Christian Bruel <christian.bruel@st.com>
+
+ PR target/69245
+ * config/arm/arm-c.c (arm_pragma_target_parse): Add comments.
+ Move arm_reset_previous_fndecl and set_target_option_current_node in
+ the conditional part. Call save_restore_target_globals.
+ * config/arm/arm.c (arm_set_current_function):
+ Refactor to better support #pragma target and attribute mix.
+ Call save_restore_target_globals.
+ * config/arm/arm-protos.h (save_restore_target_globals): New function.
+
2016-01-27 Martin Liska <mliska@suse.cz>
* hsa.c (hsa_summary_t::link_functions): Create IPA_REF_ADDR
diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index df84bef..195905f 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -221,9 +221,6 @@ arm_pragma_target_parse (tree args, tree pop_target)
}
}
- target_option_current_node = cur_tree;
- arm_reset_previous_fndecl ();
-
/* Figure out the previous mode. */
prev_opt = TREE_TARGET_OPTION (prev_tree);
cur_opt = TREE_TARGET_OPTION (cur_tree);
@@ -259,6 +256,18 @@ arm_pragma_target_parse (tree args, tree pop_target)
arm_cpu_builtins (parse_in);
cpp_opts->warn_unused_macros = saved_warn_unused_macros;
+
+ /* Make sure that target_reinit is called for next function, since
+ TREE_TARGET_OPTION might change with the #pragma even if there is
+ no target attribute attached to the function. */
+ arm_reset_previous_fndecl ();
+
+ /* If going to the default mode, we restore the initial states.
+ if cur_tree is a new target, states will be saved/restored on a per
+ function basis in arm_set_current_function. */
+ if (cur_tree == target_option_default_node)
+ save_restore_target_globals (cur_tree);
+
}
return true;
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 28f2263..8261ed8 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -332,6 +332,7 @@ extern bool arm_autoinc_modes_ok_p (machine_mode, enum arm_auto_incmodes);
extern void arm_emit_eabi_attribute (const char *, int, int);
extern void arm_reset_previous_fndecl (void);
+extern void save_restore_target_globals (tree);
/* Defined in gcc/common/config/arm-common.c. */
extern const char *arm_rewrite_selected_cpu (const char *name);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 9b03b05..d8a2745 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -3446,8 +3446,7 @@ arm_option_override (void)
/* Save the initial options in case the user does function specific
options. */
- target_option_default_node = target_option_current_node
- = build_target_option_node (&global_options);
+ target_option_default_node = build_target_option_node (&global_options);
/* Init initial mode for testing. */
thumb_flipper = TARGET_THUMB;
@@ -29750,6 +29749,25 @@ arm_is_constant_pool_ref (rtx x)
/* Remember the last target of arm_set_current_function. */
static GTY(()) tree arm_previous_fndecl;
+/* Restore or save the TREE_TARGET_GLOBALS from or to NEW_TREE. */
+
+void
+save_restore_target_globals (tree new_tree)
+{
+ /* If we have a previous state, use it. */
+ if (TREE_TARGET_GLOBALS (new_tree))
+ restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
+ else if (new_tree == target_option_default_node)
+ restore_target_globals (&default_target_globals);
+ else
+ {
+ /* Call target_reinit and save the state for TARGET_GLOBALS. */
+ TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
+ }
+
+ arm_option_params_internal ();
+}
+
/* Invalidate arm_previous_fndecl. */
void
arm_reset_previous_fndecl (void)
@@ -29772,38 +29790,23 @@ arm_set_current_function (tree fndecl)
tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
- arm_previous_fndecl = fndecl;
+ /* If current function has no attributes but previous one did,
+ use the default node." */
+ if (! new_tree && old_tree)
+ new_tree = target_option_default_node;
+
+ /* If nothing to do return. #pragma GCC reset or #pragma GCC pop to
+ the default have been handled by save_restore_target_globals from
+ arm_pragma_target_parse. */
if (old_tree == new_tree)
return;
- if (new_tree && new_tree != target_option_default_node)
- {
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
-
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
-
- else if (old_tree && old_tree != target_option_default_node)
- {
- new_tree = target_option_current_node;
+ arm_previous_fndecl = fndecl;
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else if (new_tree == target_option_default_node)
- restore_target_globals (&default_target_globals);
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
+ /* First set the target options. */
+ cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
- arm_option_params_internal ();
+ save_restore_target_globals (new_tree);
}
/* Implement TARGET_OPTION_PRINT. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index aa3d51b..8559a78 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-20 Christian Bruel <christian.bruel@st.com>
+
+ PR target/69245
+ * gcc.target/arm/pr69245.c: New test.
+
2016-01-27 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/69399
diff --git a/gcc/testsuite/gcc.target/arm/pr69245.c b/gcc/testsuite/gcc.target/arm/pr69245.c
new file mode 100644
index 0000000..bd50518
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr69245.c
@@ -0,0 +1,26 @@
+/* PR target/69245 */
+/* Test that pop_options restores the vfp fpu mode. */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-require-effective-target arm_fp_ok } */
+/* { dg-options "-O2" } */
+/* { dg-add-options arm_fp } */
+
+#pragma GCC target "fpu=vfp"
+
+#pragma GCC push_options
+#pragma GCC target "fpu=neon-vfpv4"
+int a, c, d;
+float b;
+static int fn1 ()
+{
+ return 0;
+}
+#pragma GCC pop_options
+
+void fn2 ()
+{
+ d = b * c + a;
+}
+
+/* { dg-final { scan-assembler-times "\.fpu vfp" 1 } } */