diff options
author | Jan Hubicka <jh@suse.cz> | 2020-11-19 10:16:11 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2020-11-19 13:08:29 +0100 |
commit | d8cf89767492a41b0f76e0aa302dddee4e1b3434 (patch) | |
tree | 89170ad025fdac02e5267f0138e530a915d8c08f /gcc/fold-const.c | |
parent | 27842e2a1eb26a7eae80b8efd98fb8c8bd74a68e (diff) | |
download | gcc-d8cf89767492a41b0f76e0aa302dddee4e1b3434.zip gcc-d8cf89767492a41b0f76e0aa302dddee4e1b3434.tar.gz gcc-d8cf89767492a41b0f76e0aa302dddee4e1b3434.tar.bz2 |
Fix operand_equal_p hash and copare of ODR_TYPE_REF
* fold-const.c (operand_compare::operand_equal_p): More OBJ_TYPE_REF
matching to correct place; drop OEP_ADDRESS_OF for TOKEN, OBJECT and
class.
(operand_compare::hash_operand): Hash ODR type for OBJ_TYPE_REF.
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 31c48da..397805d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3346,24 +3346,6 @@ operand_compare::operand_equal_p (const_tree arg0, const_tree arg1, flags &= ~OEP_ADDRESS_OF; return OP_SAME (1) && OP_SAME (2); - /* Virtual table call. */ - case OBJ_TYPE_REF: - { - if (!operand_equal_p (OBJ_TYPE_REF_EXPR (arg0), - OBJ_TYPE_REF_EXPR (arg1), flags)) - return false; - if (tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg0)) - != tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg1))) - return false; - if (!operand_equal_p (OBJ_TYPE_REF_OBJECT (arg0), - OBJ_TYPE_REF_OBJECT (arg1), flags)) - return false; - if (!types_same_for_odr (obj_type_ref_class (arg0), - obj_type_ref_class (arg1))) - return false; - return true; - } - default: return false; } @@ -3442,6 +3424,23 @@ operand_compare::operand_equal_p (const_tree arg0, const_tree arg1, return OP_SAME (0); return false; + case OBJ_TYPE_REF: + /* Virtual table reference. */ + if (!operand_equal_p (OBJ_TYPE_REF_EXPR (arg0), + OBJ_TYPE_REF_EXPR (arg1), flags)) + return false; + flags &= ~OEP_ADDRESS_OF; + if (tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg0)) + != tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg1))) + return false; + if (!operand_equal_p (OBJ_TYPE_REF_OBJECT (arg0), + OBJ_TYPE_REF_OBJECT (arg1), flags)) + return false; + if (!types_same_for_odr (obj_type_ref_class (arg0), + obj_type_ref_class (arg1))) + return false; + return true; + default: return false; } @@ -3861,11 +3860,23 @@ operand_compare::hash_operand (const_tree t, inchash::hash &hstate, hash_operand (TARGET_EXPR_SLOT (t), hstate, flags); return; - /* Virtual table call. */ case OBJ_TYPE_REF: + /* Virtual table reference. */ inchash::add_expr (OBJ_TYPE_REF_EXPR (t), hstate, flags); + flags &= ~OEP_ADDRESS_OF; inchash::add_expr (OBJ_TYPE_REF_TOKEN (t), hstate, flags); inchash::add_expr (OBJ_TYPE_REF_OBJECT (t), hstate, flags); + if (tree c = obj_type_ref_class (t)) + { + c = TYPE_NAME (TYPE_MAIN_VARIANT (c)); + /* We compute mangled names only when free_lang_data is run. + In that case we can hash precisely. */ + if (TREE_CODE (c) == TYPE_NAME + && DECL_ASSEMBLER_NAME_SET_P (c)) + hstate.add_object + (IDENTIFIER_HASH_VALUE + (DECL_ASSEMBLER_NAME (c))); + } return; default: break; |