diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-11 17:41:52 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-11 17:41:52 +0000 |
commit | 504d3463155888e30ae12775390b578c7723a827 (patch) | |
tree | 2934106e3d3e6eaac5aa3e9c20bb96aa1aaada5f /gcc/tree.c | |
parent | eece3694d24497188aef662b7e87a5733ed1a79c (diff) | |
download | gcc-504d3463155888e30ae12775390b578c7723a827.tar.gz |
PR tree-opt/16383
* tree-ssa-ccp.c (fold_stmt_r): Split out...
* tree.c (fields_compatible_p, find_compatible_field): ... new.
* tree.h (fields_compatible_p, find_compatible_field): Declare.
* tree-sra.c (sra_hash_tree): Hash fields by offset.
(sra_elt_eq): Use fields_compatible_p.
(generate_one_element_ref): Use find_compatible_field.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84524 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 033c851ea74..30ddcc895a5 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -5693,4 +5693,49 @@ needs_to_live_in_memory (tree t) || decl_function_context (t) != current_function_decl); } +/* There are situations in which a language considers record types + compatible which have different field lists. Decide if two fields + are compatible. It is assumed that the parent records are compatible. */ + +bool +fields_compatible_p (tree f1, tree f2) +{ + if (!operand_equal_p (DECL_FIELD_BIT_OFFSET (f1), + DECL_FIELD_BIT_OFFSET (f2), OEP_ONLY_CONST)) + return false; + + if (!operand_equal_p (DECL_FIELD_OFFSET (f1), + DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST)) + return false; + + if (!lang_hooks.types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2))) + return false; + + return true; +} + +/* Locate within RECORD a field that is compatible with ORIG_FIELD. */ + +tree +find_compatible_field (tree record, tree orig_field) +{ + tree f; + + for (f = TYPE_FIELDS (record); f ; f = TREE_CHAIN (f)) + if (TREE_CODE (f) == FIELD_DECL + && fields_compatible_p (f, orig_field)) + return f; + + /* ??? Why isn't this on the main fields list? */ + f = TYPE_VFIELD (record); + if (f && TREE_CODE (f) == FIELD_DECL + && fields_compatible_p (f, orig_field)) + return f; + + /* ??? We should abort here, but Java appears to do Bad Things + with inherited fields. */ + return orig_field; +} + + #include "gt-tree.h" |