From patchwork Thu Dec 23 16:32:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 76524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 98081B70A7 for ; Fri, 24 Dec 2010 03:31:38 +1100 (EST) Received: (qmail 13645 invoked by alias); 23 Dec 2010 16:31:36 -0000 Received: (qmail 13637 invoked by uid 22791); 23 Dec 2010 16:31:35 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Dec 2010 16:31:26 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 0C80A94746; Thu, 23 Dec 2010 17:31:24 +0100 (CET) Date: Thu, 23 Dec 2010 17:32:21 +0100 From: Martin Jambor To: GCC Patches Cc: Jason Merrill Subject: [PATCH] Use TYPE_MAIN_VARIANT in get_binfo_at_offset Message-ID: <20101223163221.GB3121@alvy.suse.cz> Mail-Followup-To: GCC Patches , Jason Merrill MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 differently. Bootstrapped and tested on x86_64-linux without any issues. OK for trunk? Thanks, Martin 2010-12-22 Martin Jambor * 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;