From 115340c79fdd40c3b8c809ef81a1deebec0a2500 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 7 Jul 2008 15:11:29 +0000 Subject: [PATCH] re PR target/36713 (r137252 breaks -O2 optimization on x86_64-unknown-linux-gnu) 2008-07-07 Richard Guenther PR tree-optimization/36713 * tree-flow-inline.h (is_call_used): New function. * tree-nrv.c (dest_safe_for_nrv_p): Use it. * tree-tailcall.c (suitable_for_tail_opt_p): Likewise. * tree-outof-ssa.c (create_temp): Set call-used flag if required. From-SVN: r137571 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-flow-inline.h | 10 +++++++++- gcc/tree-nrv.c | 2 +- gcc/tree-outof-ssa.c | 2 ++ gcc/tree-tailcall.c | 4 ++-- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2bf1fd6e510..41b494dee92 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2008-07-07 Richard Guenther + + PR tree-optimization/36713 + * tree-flow-inline.h (is_call_used): New function. + * tree-nrv.c (dest_safe_for_nrv_p): Use it. + * tree-tailcall.c (suitable_for_tail_opt_p): Likewise. + * tree-outof-ssa.c (create_temp): Set call-used flag if required. + 2008-07-07 Maxim Kuvyrkov * config/m68k/m68k.c (m68k_return_in_memory): Fix arguments types. diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index bff697db5ae..19a3002dfda 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -881,7 +881,15 @@ factoring_name_p (const_tree name) return TREE_CODE (SSA_NAME_VAR (name)) == MEMORY_PARTITION_TAG; } -/* Return true if VAR is a clobbered by function calls. */ +/* Return true if VAR is used by function calls. */ +static inline bool +is_call_used (const_tree var) +{ + return (var_ann (var)->call_clobbered + || bitmap_bit_p (gimple_call_used_vars (cfun), DECL_UID (var))); +} + +/* Return true if VAR is clobbered by function calls. */ static inline bool is_call_clobbered (const_tree var) { diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c index 13febcaf79b..cdf6c3fd9e6 100644 --- a/gcc/tree-nrv.c +++ b/gcc/tree-nrv.c @@ -265,7 +265,7 @@ dest_safe_for_nrv_p (tree dest) if (TREE_CODE (dest) == SSA_NAME) dest = SSA_NAME_VAR (dest); - if (is_call_clobbered (dest)) + if (is_call_used (dest)) return false; return true; diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 40c1d3f9c3b..21f362b9059 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -128,6 +128,8 @@ create_temp (tree t) set_symbol_mem_tag (tmp, symbol_mem_tag (t)); if (is_call_clobbered (t)) mark_call_clobbered (tmp, var_ann (t)->escape_mask); + if (bitmap_bit_p (gimple_call_used_vars (cfun), DECL_UID (t))) + bitmap_set_bit (gimple_call_used_vars (cfun), DECL_UID (tmp)); return tmp; } diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 09a2eafe119..92127b4b7af 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -138,14 +138,14 @@ suitable_for_tail_opt_p (void) if (cfun->stdarg) return false; - /* No local variable nor structure field should be call-clobbered. We + /* No local variable nor structure field should be call-used. We ignore any kind of memory tag, as these are not real variables. */ FOR_EACH_REFERENCED_VAR (var, rvi) { if (!is_global_var (var) && !MTAG_P (var) - && (gimple_aliases_computed_p (cfun) ? is_call_clobbered (var) + && (gimple_aliases_computed_p (cfun)? is_call_used (var) : TREE_ADDRESSABLE (var))) return false; } -- 2.30.2