From ab442df7fb453434d80a779844fe1a10c0c802ab Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Wed, 23 Jul 2008 10:28:06 +0000 Subject: Add ability to set target options (ix86 only) and optimization options on a function specific basis From-SVN: r138075 --- gcc/function.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'gcc/function.c') diff --git a/gcc/function.c b/gcc/function.c index 8e8b907..fa2a84d 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3731,13 +3731,30 @@ debug_find_var_in_block_tree (tree var, tree block) static bool in_dummy_function; -/* Invoke the target hook when setting cfun. */ +/* Invoke the target hook when setting cfun. Update the optimization options + if the function uses different options than the default. */ static void invoke_set_current_function_hook (tree fndecl) { if (!in_dummy_function) - targetm.set_current_function (fndecl); + { + tree opts = ((fndecl) + ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) + : optimization_default_node); + + if (!opts) + opts = optimization_default_node; + + /* Change optimization options if needed. */ + if (optimization_current_node != opts) + { + optimization_current_node = opts; + cl_optimization_restore (TREE_OPTIMIZATION (opts)); + } + + targetm.set_current_function (fndecl); + } } /* cfun should never be set directly; use this function. */ -- cgit v1.1