From 869032b176d57ca8c8864a7818394106ca665d06 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 15 Apr 2019 10:09:08 +0000 Subject: re PR ipa/88936 (-fipa-pta breaks bash (incorrect optimisation of recursive static function)) 2019-04-15 Richard Biener PR ipa/88936 * tree.h (auto_var_p): Declare. * tree.c (auto_var_p): New function, split out from ... (auto_var_in_fn_p): ... here. * tree-ssa-structalias.c (struct variable_info): Add shadow_var_uid member. (new_var_info): Initialize it. (set_uids_in_ptset): Also set the shadow variable uid if required. (ipa_pta_execute): Postprocess points-to solutions assigning shadow variable uids for locals that may reach their containing function recursively. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Do not assert but instead check whether the points-to solution is a singleton. * gcc.dg/torture/pr88936-1.c: New testcase. * gcc.dg/torture/pr88936-2.c: Likewise. * gcc.dg/torture/pr88936-3.c: Likewise. From-SVN: r270366 --- gcc/tree-ssa-ccp.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'gcc/tree-ssa-ccp.c') diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 234d9ca..e6bcc21 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2170,23 +2170,26 @@ fold_builtin_alloca_with_align (gimple *stmt) if (size > threshold) return NULL_TREE; + /* We have to be able to move points-to info. We used to assert + that we can but IPA PTA might end up with two UIDs here + as it might need to handle more than one instance being + live at the same time. Instead of trying to detect this case + (using the first UID would be OK) just give up for now. */ + struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs); + unsigned uid = 0; + if (pi != NULL + && !pi->pt.anything + && !pt_solution_singleton_or_null_p (&pi->pt, &uid)) + return NULL_TREE; + /* Declare array. */ elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1); n_elem = size * 8 / BITS_PER_UNIT; array_type = build_array_type_nelts (elem_type, n_elem); var = create_tmp_var (array_type); SET_DECL_ALIGN (var, TREE_INT_CST_LOW (gimple_call_arg (stmt, 1))); - { - struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs); - if (pi != NULL && !pi->pt.anything) - { - bool singleton_p; - unsigned uid; - singleton_p = pt_solution_singleton_or_null_p (&pi->pt, &uid); - gcc_assert (singleton_p); - SET_DECL_PT_UID (var, uid); - } - } + if (uid != 0) + SET_DECL_PT_UID (var, uid); /* Fold alloca to the address of the array. */ return fold_convert (TREE_TYPE (lhs), build_fold_addr_expr (var)); -- cgit v1.1