From 4023bc5647c3c76ff70ad7efb6db6f5db781016e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 7 Oct 2016 07:44:47 +0000 Subject: [PATCH] re PR tree-optimization/77879 (mpd gets miscompiled since r235622) 2016-10-07 Richard Biener PR tree-optimization/77879 * tree-ssa-structalias.c (handle_const_call): Properly handle NRV return slots. (handle_pure_call): Likewise. From-SVN: r240854 --- gcc/ChangeLog | 7 +++++++ gcc/tree-ssa-structalias.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0e8fcfd8a80..9125650a545 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-10-07 Richard Biener + + PR tree-optimization/77879 + * tree-ssa-structalias.c (handle_const_call): Properly handle + NRV return slots. + (handle_pure_call): Likewise. + 2016-10-06 Aaron Sawdey * config/rs6000/rs6000.c (rs6000_elf_asm_out_constructor) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index be892fd9472..a74f0834dfa 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -4063,15 +4063,34 @@ handle_const_call (gcall *stmt, vec *results) { struct constraint_expr rhsc; unsigned int k; + bool need_uses = false; /* Treat nested const functions the same as pure functions as far as the static chain is concerned. */ if (gimple_call_chain (stmt)) + { + varinfo_t uses = get_call_use_vi (stmt); + make_constraint_to (uses->id, gimple_call_chain (stmt)); + need_uses = true; + } + + /* And if we applied NRV the address of the return slot escapes as well. */ + if (gimple_call_return_slot_opt_p (stmt) + && gimple_call_lhs (stmt) != NULL_TREE + && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt)))) + { + varinfo_t uses = get_call_use_vi (stmt); + auto_vec tmpc; + get_constraint_for_address_of (gimple_call_lhs (stmt), &tmpc); + make_constraints_to (uses->id, tmpc); + need_uses = true; + } + + if (need_uses) { varinfo_t uses = get_call_use_vi (stmt); make_any_offset_constraints (uses); make_transitive_closure_constraints (uses); - make_constraint_to (uses->id, gimple_call_chain (stmt)); rhsc.var = uses->id; rhsc.offset = 0; rhsc.type = SCALAR; @@ -4140,6 +4159,22 @@ handle_pure_call (gcall *stmt, vec *results) make_constraint_to (uses->id, gimple_call_chain (stmt)); } + /* And if we applied NRV the address of the return slot. */ + if (gimple_call_return_slot_opt_p (stmt) + && gimple_call_lhs (stmt) != NULL_TREE + && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt)))) + { + if (!uses) + { + uses = get_call_use_vi (stmt); + make_any_offset_constraints (uses); + make_transitive_closure_constraints (uses); + } + auto_vec tmpc; + get_constraint_for_address_of (gimple_call_lhs (stmt), &tmpc); + make_constraints_to (uses->id, tmpc); + } + /* Pure functions may return call-used and nonlocal memory. */ if (uses) { -- 2.30.2