aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssanames.cc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-07-14 15:14:59 -0700
committerAndrew Pinski <apinski@marvell.com>2023-07-19 09:17:02 -0700
commita86d5eca6a11c25da4aff436f53589950641675f (patch)
treed7f649c59afcca23e5fe2b6e6c66c2b6a6527586 /gcc/tree-ssanames.cc
parentbf20b770d9aabb15faf2644b5e3106249cb175f3 (diff)
downloadgcc-a86d5eca6a11c25da4aff436f53589950641675f.zip
gcc-a86d5eca6a11c25da4aff436f53589950641675f.tar.gz
gcc-a86d5eca6a11c25da4aff436f53589950641675f.tar.bz2
Add flow_sensitive_info_storage and use it in gimple-fold.
This adds flow_sensitive_info_storage and uses it in maybe_fold_comparisons_from_match_pd as mentioned in https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621817.html . Since using it in maybe_fold_comparisons_from_match_pd was easy and allowed me to test the storage earlier, I did it. This also hides better how the flow sensitive information is stored and only a single place needs to be updated if that ever changes (again). OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * gimple-fold.cc (fosa_unwind): Replace `vrange_storage *` with flow_sensitive_info_storage. (follow_outer_ssa_edges): Update how to save off the flow sensitive info. (maybe_fold_comparisons_from_match_pd): Update restoring of flow sensitive info. * tree-ssanames.cc (flow_sensitive_info_storage::save): New method. (flow_sensitive_info_storage::restore): New method. (flow_sensitive_info_storage::save_and_clear): New method. (flow_sensitive_info_storage::clear_storage): New method. * tree-ssanames.h (class flow_sensitive_info_storage): New class.
Diffstat (limited to 'gcc/tree-ssanames.cc')
-rw-r--r--gcc/tree-ssanames.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index f543943..23387b9 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -931,3 +931,75 @@ make_pass_release_ssa_names (gcc::context *ctxt)
{
return new pass_release_ssa_names (ctxt);
}
+
+/* Save and restore of flow sensitive information. */
+
+/* Save off the flow sensitive info from NAME. */
+
+void
+flow_sensitive_info_storage::save (tree name)
+{
+ gcc_assert (state == 0);
+ if (!POINTER_TYPE_P (TREE_TYPE (name)))
+ {
+ range_info = SSA_NAME_RANGE_INFO (name);
+ state = 1;
+ return;
+ }
+ state = -1;
+ auto ptr_info = SSA_NAME_PTR_INFO (name);
+ if (ptr_info)
+ {
+ align = ptr_info->align;
+ misalign = ptr_info->misalign;
+ null = SSA_NAME_PTR_INFO (name)->pt.null;
+ }
+ else
+ {
+ align = 0;
+ misalign = 0;
+ null = true;
+ }
+}
+
+/* Restore the flow sensitive info from NAME. */
+
+void
+flow_sensitive_info_storage::restore (tree name)
+{
+ gcc_assert (state != 0);
+ if (!POINTER_TYPE_P (TREE_TYPE (name)))
+ {
+ gcc_assert (state == 1);
+ SSA_NAME_RANGE_INFO (name) = range_info;
+ return;
+ }
+ gcc_assert (state == -1);
+ auto ptr_info = SSA_NAME_PTR_INFO (name);
+ /* If there was no flow sensitive info on the pointer
+ just return, there is nothing to restore to. */
+ if (!ptr_info)
+ return;
+ if (align != 0)
+ set_ptr_info_alignment (ptr_info, align, misalign);
+ else
+ mark_ptr_info_alignment_unknown (ptr_info);
+ SSA_NAME_PTR_INFO (name)->pt.null = null;
+}
+
+/* Save off the flow sensitive info from NAME.
+ And reset the flow sensitive info of NAME. */
+
+void
+flow_sensitive_info_storage::save_and_clear (tree name)
+{
+ save (name);
+ reset_flow_sensitive_info (name);
+}
+
+/* Clear the storage. */
+void
+flow_sensitive_info_storage::clear_storage (void)
+{
+ state = 0;
+}