diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-11-11 19:43:07 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2023-11-11 23:36:44 +0100 |
commit | e0787da263322fc18dfff55218b12129765f7bd3 (patch) | |
tree | e7eee96cda2bcdb9983d2b356ddd20ebb9fa1c4b /gcc | |
parent | 85b49ad863965408668627f10b5b1b106053f319 (diff) | |
download | gcc-e0787da263322fc18dfff55218b12129765f7bd3.zip gcc-e0787da263322fc18dfff55218b12129765f7bd3.tar.gz gcc-e0787da263322fc18dfff55218b12129765f7bd3.tar.bz2 |
Handle addresses of more constants in IPA-CP
IPA-CP can handle addresses of scalar constants (CONST_DECL) so this extends
that to addresses of constants in the pool (DECL_IN_CONSTANT_POOL). Again
this is helpful for so-called fat pointers in Ada, i.e. objects that are
semantically pointers but represented by structures made up of two pointers.
This also moves the unused function print_ipcp_constant_value from ipa-cp.cc
to ipa-prop.cc and renames it.
gcc/
* ipa-cp.cc (print_ipcp_constant_value): Move to...
(values_equal_for_ipcp_p): Deal with VAR_DECLs from the
constant pool.
* ipa-prop.cc (ipa_print_constant_value): ...here. Likewise.
(ipa_print_node_jump_functions_for_edge): Call the function
ipa_print_constant_value to print IPA_JF_CONST elements.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ipa-cp.cc | 28 | ||||
-rw-r--r-- | gcc/ipa-prop.cc | 29 |
2 files changed, 29 insertions, 28 deletions
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 788157e..34fae06 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -478,10 +478,15 @@ values_equal_for_ipcp_p (tree x, tree y) if (TREE_CODE (x) == ADDR_EXPR && TREE_CODE (y) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (x, 0)) == CONST_DECL - && TREE_CODE (TREE_OPERAND (y, 0)) == CONST_DECL) - return operand_equal_p (DECL_INITIAL (TREE_OPERAND (x, 0)), - DECL_INITIAL (TREE_OPERAND (y, 0)), 0); + && (TREE_CODE (TREE_OPERAND (x, 0)) == CONST_DECL + || (TREE_CODE (TREE_OPERAND (x, 0)) == VAR_DECL + && DECL_IN_CONSTANT_POOL (TREE_OPERAND (x, 0)))) + && (TREE_CODE (TREE_OPERAND (y, 0)) == CONST_DECL + || (TREE_CODE (TREE_OPERAND (y, 0)) == VAR_DECL + && DECL_IN_CONSTANT_POOL (TREE_OPERAND (y, 0))))) + return TREE_OPERAND (x, 0) == TREE_OPERAND (y, 0) + || operand_equal_p (DECL_INITIAL (TREE_OPERAND (x, 0)), + DECL_INITIAL (TREE_OPERAND (y, 0)), 0); else return operand_equal_p (x, y, 0); } @@ -489,21 +494,6 @@ values_equal_for_ipcp_p (tree x, tree y) /* Print V which is extracted from a value in a lattice to F. */ static void -print_ipcp_constant_value (FILE * f, tree v) -{ - if (TREE_CODE (v) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (v, 0)) == CONST_DECL) - { - fprintf (f, "& "); - print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (v, 0))); - } - else - print_generic_expr (f, v); -} - -/* Print V which is extracted from a value in a lattice to F. */ - -static void print_ipcp_constant_value (FILE * f, ipa_polymorphic_call_context v) { v.dump(f, false); diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 827bdb6..7de2b78 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -365,6 +365,24 @@ ipa_initialize_node_params (struct cgraph_node *node) ipa_populate_param_decls (node, *info->descriptors); } +/* Print VAL which is extracted from a jump function to F. */ + +static void +ipa_print_constant_value (FILE *f, tree val) +{ + print_generic_expr (f, val); + + /* This is in keeping with values_equal_for_ipcp_p. */ + if (TREE_CODE (val) == ADDR_EXPR + && (TREE_CODE (TREE_OPERAND (val, 0)) == CONST_DECL + || (TREE_CODE (TREE_OPERAND (val, 0)) == VAR_DECL + && DECL_IN_CONSTANT_POOL (TREE_OPERAND (val, 0))))) + { + fputs (" -> ", f); + print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (val, 0))); + } +} + /* Print the jump functions associated with call graph edge CS to file F. */ static void @@ -386,15 +404,8 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) fprintf (f, "UNKNOWN\n"); else if (type == IPA_JF_CONST) { - tree val = jump_func->value.constant.value; fprintf (f, "CONST: "); - print_generic_expr (f, val); - if (TREE_CODE (val) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (val, 0)) == CONST_DECL) - { - fprintf (f, " -> "); - print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (val, 0))); - } + ipa_print_constant_value (f, jump_func->value.constant.value); fprintf (f, "\n"); } else if (type == IPA_JF_PASS_THROUGH) @@ -468,7 +479,7 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) else if (item->jftype == IPA_JF_CONST) { fprintf (f, "CONST: "); - print_generic_expr (f, item->value.constant); + ipa_print_constant_value (f, item->value.constant); } else if (item->jftype == IPA_JF_UNKNOWN) fprintf (f, "UNKNOWN: " HOST_WIDE_INT_PRINT_DEC " bits", |