From patchwork Tue Mar 18 12:38:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 331401 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 A85552C0089 for ; Tue, 18 Mar 2014 23:38:33 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=L62fz9Iw6zR84t0CrB7dhubPeJm3L5Ms6QHEkJ+JmwaGjG awM8grucnV9+SlzWs8aq9jlnio2ih7YiDzbYxoQSle+dq3zVhkzNg2BGLVOjvQ4/ DX5pF4PgxVdvMixrTJ6zgTawvcrYcoyHRJMH68jJzfRiA4JubQmaqPkKGNqjU= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=GixYS+Imn4/Vkdkz43RAJPdFh3M=; b=USsjKevx1LZnHNxbdxTw 1Gz78no8QMQNF87FypKjhv7TF/x/rJyomwucobSUIktySkpnXfsNi/xg8lKKjRTI uBz5kMI2Vrv+E693QvvGo+gfRztXWvaTiNkr18224eoNMu1+dZXqA3FQdZzas+Ky zI/7TmQQva/63fpKNsbrSRM= Received: (qmail 10593 invoked by alias); 18 Mar 2014 12:38:25 -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 10582 invoked by uid 89); 18 Mar 2014 12:38:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 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, 18 Mar 2014 12:38:23 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2E80575023 for ; Tue, 18 Mar 2014 12:38:20 +0000 (UTC) Message-ID: <53283E3B.4050700@suse.cz> Date: Tue, 18 Mar 2014 13:38:19 +0100 From: =?windows-1252?Q?Martin_Li=9Aka?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix gimple-fold X-IsSubscribed: yes Hello, I found ICE in Chromium compiled with LTO. There's a call that is proved by ipa-devirt as __builtin_unreachable; same decision is done by gimple-fold and this call is replaced by GIMPLE_CALL and GIMPLE_ASSIGN (in this order). After that condition for cgraph_update_edges_for_call_stmt_node is not satisfied and corresponding cgraph_edge is not updated. Thus a verifier reports a wrong edge. Bootstrapped and tested on a x86_64 machine. Changelog: 2014-03-18 Martin Liska * cgraph.c (cgraph_update_edges_for_call_stmt_node): added case when gimple call statement is updated. * gimple-fold.c (gimple_fold_call): changed order for GIMPLE_ASSIGN and GIMPLE_CALL, where gsi iterator still points to GIMPLE CALL. OK for trunk? Thank you, Martin diff --git a/gcc/cgraph.c b/gcc/cgraph.c index a15b6bc..cd68894 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1519,7 +1519,11 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, { if (callee->decl == new_call || callee->former_clone_of == new_call) - return; + { + cgraph_set_call_stmt (cgraph_edge (node, old_stmt), + new_stmt); + return; + } callee = callee->clone_of; } } diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index eafdb2d..a033fbc 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1153,8 +1153,14 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) { tree var = create_tmp_var (TREE_TYPE (lhs), NULL); tree def = get_or_create_ssa_default_def (cfun, var); - gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); - update_call_from_tree (gsi, def); + + /* To satisfy condition for + cgraph_update_edges_for_call_stmt_node, + we need to preserve GIMPLE_CALL statement + at position of GSI iterator. */ + gimple_stmt_iterator oldgsi = *gsi; + gsi_insert_before (gsi, new_stmt, GSI_NEW_STMT); + update_call_from_tree (&oldgsi, def); } else gsi_replace (gsi, new_stmt, true);