aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-structalias.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-10-07 07:44:47 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-10-07 07:44:47 +0000
commit4023bc5647c3c76ff70ad7efb6db6f5db781016e (patch)
tree4f255f1460fc2e8f5538ad89a58c8cbcfc891f40 /gcc/tree-ssa-structalias.c
parent729232db0b630ffb0a17dfcfa0850ff68ac35bbf (diff)
downloadgcc-4023bc5647c3c76ff70ad7efb6db6f5db781016e.zip
gcc-4023bc5647c3c76ff70ad7efb6db6f5db781016e.tar.gz
gcc-4023bc5647c3c76ff70ad7efb6db6f5db781016e.tar.bz2
re PR tree-optimization/77879 (mpd gets miscompiled since r235622)
2016-10-07 Richard Biener <rguenther@suse.de> PR tree-optimization/77879 * tree-ssa-structalias.c (handle_const_call): Properly handle NRV return slots. (handle_pure_call): Likewise. From-SVN: r240854
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r--gcc/tree-ssa-structalias.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index be892fd..a74f083 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -4063,15 +4063,34 @@ handle_const_call (gcall *stmt, vec<ce_s> *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<ce_s> 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<ce_s> *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<ce_s> 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)
{