diff mbox

Use TYPE_MAIN_VARIANT in get_binfo_at_offset

Message ID 20101223163221.GB3121@alvy.suse.cz
State New
Headers show

Commit Message

Martin Jambor Dec. 23, 2010, 4:32 p.m. UTC
Hi,

devirtualization currently does not work for const and other type
variants because get_binfo_at_offset compares pointer trees directly.
The patch below changes that and makes the function compare
TREE_MAIN_VARIANTS instead.  And it introduces the correct macro to
access the BINFO type too.

With this patch PR 46823 re-emerges because it was hidden by the wrong
comparison.  I know about that and the bug must be dealt with

Comments

Jason Merrill Dec. 24, 2010, 9:27 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

differently.

Bootstrapped and tested on x86_64-linux without any issues.

OK for trunk?

Thanks,

Martin


2010-12-22  Martin Jambor  <mjambor@suse.cz>

	* tree.c (get_binfo_at_offset): Use BINFO_TYPE instead of TREE_TYPE,
	compare TYPE_MAIN_VARIANTs of types.

Index: icln/gcc/tree.c
===================================================================
--- icln.orig/gcc/tree.c
+++ icln/gcc/tree.c
@@ -10939,7 +10939,7 @@  lhd_gcc_personality (void)
 tree
 get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type)
 {
-  tree type = TREE_TYPE (binfo);
+  tree type = BINFO_TYPE (binfo);
 
   while (true)
     {
@@ -10947,7 +10947,7 @@  get_binfo_at_offset (tree binfo, HOST_WI
       tree fld;
       int i;
 
-      if (type == expected_type)
+      if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (expected_type))
 	  return binfo;
       if (offset < 0)
 	return NULL_TREE;