From patchwork Tue Sep 10 13:53:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 273879 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4B1532C027A for ; Tue, 10 Sep 2013 23:54:07 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=rkjKDbrAoPYxxtxQCOZevs/tttS6xRRfAkKUf/ykLS+nI3DsW1YhC 4GZdPZPl6lPFjKuktkb5BRBNcZ68FyBApqTR7dDaj38WDJ87eohS2HnnZULDQXvF n7ocl2qZAVRRcd6FIU6Qsh9lfthBMsxzV54ddI6f669OcWY+Nah5CI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=tgXUZqpRmDH/M3gt8opHkDlcpf4=; b=KfsLU3ifAJew/mevJ0aO 2NF5i8skjitYbORAUq6rE0EdfWxBoAc/8puKq+OHJXRDA7bL8M60MzN1wL/Aqeuy E5aMJOcV2KtyFOwifCbRf+hlLOArt8ESlfS93/l48cNlW4L4ue3AaoB8s3boTBOg G3HWMhdDhvoS0z7DO2uCM7s= Received: (qmail 26087 invoked by alias); 10 Sep 2013 13:54:01 -0000 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 Received: (qmail 26074 invoked by uid 89); 10 Sep 2013 13:54:01 -0000 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 10 Sep 2013 13:54:01 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id AFA4A543C02; Tue, 10 Sep 2013 15:53:57 +0200 (CEST) Date: Tue, 10 Sep 2013 15:53:57 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix overactive devirtualization to external functions Message-ID: <20130910135357.GB18625@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, fold_ctor_reference expects VAR or FUNCTION_DECL as FROM_DECL parameter. gimple_get_virt_method_for_binfo instead passes expression (pointer_plus_expr (addr_expr vtable_decl) (integer_cst XXX)) This bug makes can_refere_from_current_unit_p to mistakely think that the references are safe because they come from code. Fixed thus, Bootstrapped/regtested x86_64-linux. Honza * gimple-fold.c (gimple_get_virt_method_for_binfo): Pass real VAR_DECL of vtable rather than full expression. Index: gimple-fold.c =================================================================== --- gimple-fold.c (revision 202445) +++ gimple-fold.c (working copy) @@ -3135,7 +3135,7 @@ gimple_get_virt_method_for_binfo (HOST_W size = tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (v))), 1); offset += token * size; fn = fold_ctor_reference (TREE_TYPE (TREE_TYPE (v)), init, - offset, size, vtable); + offset, size, v); if (!fn || integer_zerop (fn)) return NULL_TREE; gcc_assert (TREE_CODE (fn) == ADDR_EXPR