This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/9] operand_equal_p: add support for OBJ_TYPE_REF.


gcc/ChangeLog:

2019-07-24  Martin Liska  <mliska@suse.cz>

	* fold-const.c (operand_equal_p): Support OBJ_TYPE_REF.
	* tree.c (add_expr): Hash parts of OBJ_TYPE_REF.
---
 gcc/fold-const.c | 21 +++++++++++++++++++++
 gcc/tree.c       |  9 +++++++++
 2 files changed, 30 insertions(+)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 52414f7729e..4bcde22ada7 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3323,6 +3323,27 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
 	  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 (virtual_method_call_p (arg0))
+	      {
+		if (tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg0))
+		    != tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg1)))
+		  return false;
+		if (!types_same_for_odr (obj_type_ref_class (arg0),
+					 obj_type_ref_class (arg1)))
+		  return false;
+		if (!operand_equal_p (OBJ_TYPE_REF_OBJECT (arg0),
+				      OBJ_TYPE_REF_OBJECT (arg1), flags))
+		  return false;
+	      }
+	    return true;
+	  }
+
 	default:
 	  return false;
 	}
diff --git a/gcc/tree.c b/gcc/tree.c
index 91ebc9eddc4..2207f644fed 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -8011,6 +8011,15 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags)
 	      inchash::add_expr (TARGET_EXPR_SLOT (t), hstate, flags);
 	      return;
 
+	    /* Virtual table call.  */
+	    case OBJ_TYPE_REF:
+	      inchash::add_expr (OBJ_TYPE_REF_EXPR (t), hstate, flags);
+	      if (virtual_method_call_p (t))
+		{
+		  inchash::add_expr (OBJ_TYPE_REF_TOKEN (t), hstate, flags);
+		  inchash::add_expr (OBJ_TYPE_REF_OBJECT (t), hstate, flags);
+		}
+	      return;
 	    default:
 	      break;
 	    }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]