diff options
Diffstat (limited to 'gcc/function.c')
-rw-r--r-- | gcc/function.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/function.c b/gcc/function.c index 8e8b907f917..fa2a84d804f 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. */ |