aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-04-15 10:09:08 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-04-15 10:09:08 +0000
commit869032b176d57ca8c8864a7818394106ca665d06 (patch)
tree091ea0a9c663a03956c774a6a3a164628d4e9f04 /gcc/tree-ssa-ccp.c
parent79a18702006d53bc378affcd5dd6c8df7883b58f (diff)
downloadgcc-869032b176d57ca8c8864a7818394106ca665d06.zip
gcc-869032b176d57ca8c8864a7818394106ca665d06.tar.gz
gcc-869032b176d57ca8c8864a7818394106ca665d06.tar.bz2
re PR ipa/88936 (-fipa-pta breaks bash (incorrect optimisation of recursive static function))
2019-04-15 Richard Biener <rguenther@suse.de> 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
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c25
1 files changed, 14 insertions, 11 deletions
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));