From patchwork Tue Aug 19 11:10:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 381332 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2738B14007D for ; Tue, 19 Aug 2014 21:13:48 +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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=IwP1ifxuGkl2cT/5m0PUtCJFoCC0iWO7tXIyuH/MaEwVmtxMkg +hdunBcVeJAIy+1a+7rcqdQC5YBUyIIcTKw/9FQ7Tmv82PVOD6UUcxpnLkbKvY5+ bgmL5HbYJtzgdyTza9F9jCX2TEROCVpbw2pwReN9oAgqqLK2hQLUOHSjc= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=26huzCP+odJFRZavzDi6H78/nXU=; b=MPbH1NDn0ndrN8HSgm90 r5UsGSnJ1TYzU5a6jyim0aNmDoyCCdl1FGc8OnsySUenqGKbkkq7r96VDE/Cl+aL 8V7LmF3LmuM51xX+8mptXNgpETq4OeGiqwMf2hdrbn228DiWUaLMuq2JlX6FykJM 7Sk5g5WTamYc5zNW4tll84o= Received: (qmail 5187 invoked by alias); 19 Aug 2014 11:13:21 -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 5176 invoked by uid 89); 19 Aug 2014 11:13:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 19 Aug 2014 11:13:19 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BB3C3ABAE; Tue, 19 Aug 2014 11:13:16 +0000 (UTC) Date: Tue, 19 Aug 2014 13:10:01 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] Fix devirt to NULL Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This fixes Honzas previous commit to not build &integer_zero_node (what?). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2014-08-19 Richard Biener * gimple-fold.c (fold_gimple_assign): Properly build a null-pointer constant when devirtualizing addresses. Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c (revision 214135) +++ gcc/gimple-fold.c (working copy) @@ -319,14 +319,6 @@ fold_gimple_assign (gimple_stmt_iterator = possible_polymorphic_call_targets (rhs, stmt, &final); if (final && targets.length () <= 1 && dbg_cnt (devirt)) { - tree fndecl; - - if (targets.length () == 1) - fndecl = targets[0]->decl; - else - /* We can not use __builtin_unreachable here because it - can not have address taken. */ - fndecl = integer_zero_node; if (dump_enabled_p ()) { location_t loc = gimple_location_safe (stmt); @@ -335,11 +327,19 @@ fold_gimple_assign (gimple_stmt_iterator "reference to function %s\n", targets.length () == 1 ? targets[0]->name () - : "__builtin_unreachable"); + : "NULL"); + } + if (targets.length () == 1) + { + val = fold_convert (TREE_TYPE (val), + build_fold_addr_expr_loc + (loc, targets[0]->decl)); + STRIP_USELESS_TYPE_CONVERSION (val); } - val = fold_convert (TREE_TYPE (val), - build_fold_addr_expr_loc (loc, fndecl)); - STRIP_USELESS_TYPE_CONVERSION (val); + else + /* We can not use __builtin_unreachable here because it + can not have address taken. */ + val = build_int_cst (TREE_TYPE (val), 0); return val; } }