aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-fnsummary.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-09-23 23:06:05 +0200
committerJan Hubicka <jh@suse.cz>2020-09-23 23:06:05 +0200
commite977dd5edbcc3a3b88c3bd7efa1026c845af7487 (patch)
tree6603e18a37391e417b8b2c1e3821f747bf039c3d /gcc/ipa-fnsummary.c
parente92779db3304bc96a6b861f87c5edde8dd4d4030 (diff)
downloadgcc-e977dd5edbcc3a3b88c3bd7efa1026c845af7487.zip
gcc-e977dd5edbcc3a3b88c3bd7efa1026c845af7487.tar.gz
gcc-e977dd5edbcc3a3b88c3bd7efa1026c845af7487.tar.bz2
Cleanup modref interfaces.
* ipa-fnsummary.c (refs_local_or_readonly_memory_p): New function. (points_to_local_or_readonly_memory_p): New function. * ipa-fnsummary.h (refs_local_or_readonly_memory_p): Declare. (points_to_local_or_readonly_memory_p): Declare. * ipa-modref.c (record_access_p): Use refs_local_or_readonly_memory_p. * ipa-pure-const.c (check_op): Likewise. * gcc.dg/tree-ssa/local-pure-const.c: Update template.
Diffstat (limited to 'gcc/ipa-fnsummary.c')
-rw-r--r--gcc/ipa-fnsummary.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index 86d01ad..bb703f6 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -2430,6 +2430,47 @@ fp_expression_p (gimple *stmt)
return false;
}
+/* Return true if T references memory location that is local
+ for the function (that means, dead after return) or read-only. */
+
+bool
+refs_local_or_readonly_memory_p (tree t)
+{
+ /* Non-escaping memory is fine. */
+ t = get_base_address (t);
+ if ((TREE_CODE (t) == MEM_REF
+ || TREE_CODE (t) == TARGET_MEM_REF))
+ return points_to_local_or_readonly_memory_p (TREE_OPERAND (t, 0));
+
+ /* Automatic variables are fine. */
+ if (DECL_P (t)
+ && auto_var_in_fn_p (t, current_function_decl))
+ return true;
+
+ /* Read-only variables are fine. */
+ if (DECL_P (t) && TREE_READONLY (t))
+ return true;
+
+ return false;
+}
+
+/* Return true if T is a pointer pointing to memory location that is local
+ for the function (that means, dead after return) or read-only. */
+
+bool
+points_to_local_or_readonly_memory_p (tree t)
+{
+ /* See if memory location is clearly invalid. */
+ if (integer_zerop (t))
+ return flag_delete_null_pointer_checks;
+ if (TREE_CODE (t) == SSA_NAME)
+ return !ptr_deref_may_alias_global_p (t);
+ if (TREE_CODE (t) == ADDR_EXPR)
+ return refs_local_or_readonly_memory_p (TREE_OPERAND (t, 0));
+ return false;
+}
+
+
/* Analyze function body for NODE.
EARLY indicates run from early optimization pipeline. */