Inlining previously ignored prange. This patch allows them to
be inlined just like the other ranges. Any function local address
referred to in the range will be removed making it safe. This replicates
the fixes we needed for IPA.
This also restores any information that may have inadvertently gotten lost
when it was carried in a ptr_info_def. (which was removed).
This includes
- the alignment (Now from the bitmask)
- the non-null property (now carried by the range).
- plus any other range refinements.
Bootstraps on x86_64-pc-linux-gnu with no regressions. OK?
Andrew
* tree-inline.cc (remap_ssa_name): Drop local addresses from a
prange, and inline pointers.
* tree-ssanames.cc (duplicate_ssa_name_range_info): Remove
function local addresses if requested.
* tree-ssanames.h (duplicate_ssa_name_range_info): Adjust prototype.
---
gcc/tree-inline.cc | 14 ++++++--------
gcc/tree-ssanames.cc | 12 ++++++++++--
gcc/tree-ssanames.h | 3 ++-
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 7d73d595907..184da086e65 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -241,6 +241,9 @@ remap_ssa_name (tree name, copy_body_data *id)
insert_decl_map (id, name, new_tree);
SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree)
= SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name);
+ /* Range info can be transferred, if local addresses are removed. */
+ if (SSA_NAME_RANGE_INFO (name))
+ duplicate_ssa_name_range_info (new_tree, name, true);
/* At least IPA points-to info can be directly transferred. */
if (id->src_cfun->gimple_df
&& id->src_cfun->gimple_df->ipa_pta
@@ -248,10 +251,6 @@ remap_ssa_name (tree name, copy_body_data *id)
&& (pt = ssa_name_pt_solution (name))
&& !pt->anything)
set_ssa_name_pt_solution (new_tree, *pt);
- /* So can range-info. */
- if (!POINTER_TYPE_P (TREE_TYPE (name))
- && SSA_NAME_RANGE_INFO (name))
- duplicate_ssa_name_range_info (new_tree, name);
return new_tree;
}
@@ -275,6 +274,9 @@ remap_ssa_name (tree name, copy_body_data *id)
insert_decl_map (id, name, new_tree);
SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree)
= SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name);
+ /* Range info can be transferred, if local addresses are removed. */
+ if (SSA_NAME_RANGE_INFO (name))
+ duplicate_ssa_name_range_info (new_tree, name, true);
/* At least IPA points-to info can be directly transferred. */
if (id->src_cfun->gimple_df
&& id->src_cfun->gimple_df->ipa_pta
@@ -282,10 +284,6 @@ remap_ssa_name (tree name, copy_body_data *id)
&& (pt = ssa_name_pt_solution (name))
&& !pt->anything)
set_ssa_name_pt_solution (new_tree, *pt);
- /* So can range-info. */
- if (!POINTER_TYPE_P (TREE_TYPE (name))
- && SSA_NAME_RANGE_INFO (name))
- duplicate_ssa_name_range_info (new_tree, name);
if (SSA_NAME_IS_DEFAULT_DEF (name))
{
/* By inlining function having uninitialized variable, we might
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index b97738834f1..0411d2a5a75 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -986,10 +986,14 @@ duplicate_ssa_name_pt_solution (tree dest, tree src)
duplicate_ssa_name_pt_solution (dest, pt);
}
-/* Copy any global range information from SRC to NAME. */
+/* Copy any global range information from SRC to NAME. If REMOVE_LOCAL_ADDR
+ is true, then any specified address that a prange may refer to is checked
+ to see if it's local to the function and removed if so.
+ The default is FALSE, which is the previous default behaviour and copies
+ the entire range as is. */
void
-duplicate_ssa_name_range_info (tree name, tree src)
+duplicate_ssa_name_range_info (tree name, tree src, bool remove_local_addr)
{
gcc_checking_assert (!SSA_NAME_RANGE_INFO (name));
@@ -998,6 +1002,10 @@ duplicate_ssa_name_range_info (tree name, tree src)
value_range src_range (TREE_TYPE (src));
range_info_get_range (src, src_range);
+
+ /* Remove any local addresses from the range if present. */
+ if (remove_local_addr && is_a<prange> (src_range))
+ as_a<prange> (src_range).clear_function_local_addr ();
range_info_set_range (name, src_range);
unsigned align, misalign;
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index 9798df7d04d..7f0b2f1f657 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -88,7 +88,8 @@ extern tree copy_ssa_name_fn (struct function *, tree, gimple
*);
extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
extern void duplicate_ssa_name_pt_solution (tree dest, const pt_solution *);
extern void duplicate_ssa_name_pt_solution (tree dest, tree src);
-extern void duplicate_ssa_name_range_info (tree dest, tree src);
+extern void duplicate_ssa_name_range_info (tree dest, tree src,
+ bool remove_local_addr = false);
extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
extern void reset_flow_sensitive_info (tree);
extern void reset_flow_sensitive_info_in_bb (basic_block);
--
2.56.0