From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25039 invoked by alias); 4 Jun 2016 13:36:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25018 invoked by uid 89); 4 Jun 2016 13:36:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=16229 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 04 Jun 2016 13:36:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1A308E66B; Sat, 4 Jun 2016 13:36:18 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u54DaG4m031161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 4 Jun 2016 09:36:18 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u54DaFjB002156; Sat, 4 Jun 2016 15:36:15 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u54DaDpH002155; Sat, 4 Jun 2016 15:36:13 +0200 Date: Sat, 04 Jun 2016 13:36:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE with gimple clobber (PR tree-optimization/71405) Message-ID: <20160604133613.GS7387@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00324.txt.bz2 Hi! On this testcase execute_update_addresses_taken creates VIEW_CONVERT_EXPR of a {CLOBBER}, which is of course invalid. Instead, this patch just creates {CLOBBER} of the right type and let's the following ssa update transform that to replacing uses with default def or whatever else is appropriate. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-06-04 Jakub Jelinek PR tree-optimization/71405 * tree-ssa.c (execute_update_addresses_taken): For clobber with incompatible type, build a new clobber with the right type instead of building a VIEW_CONVERT_EXPR around it. * g++.dg/torture/pr71405.C: New test. --- gcc/tree-ssa.c.jj 2016-05-24 10:56:01.000000000 +0200 +++ gcc/tree-ssa.c 2016-06-04 11:59:36.561302230 +0200 @@ -1622,9 +1622,16 @@ execute_update_addresses_taken (void) if (gimple_assign_lhs (stmt) != lhs && !useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) - rhs = fold_build1 (VIEW_CONVERT_EXPR, - TREE_TYPE (lhs), rhs); - + { + if (gimple_clobber_p (stmt)) + { + rhs = build_constructor (TREE_TYPE (lhs), NULL); + TREE_THIS_VOLATILE (rhs) = 1; + } + else + rhs = fold_build1 (VIEW_CONVERT_EXPR, + TREE_TYPE (lhs), rhs); + } if (gimple_assign_lhs (stmt) != lhs) gimple_assign_set_lhs (stmt, lhs); --- gcc/testsuite/g++.dg/torture/pr71405.C.jj 2016-06-04 12:10:33.694768153 +0200 +++ gcc/testsuite/g++.dg/torture/pr71405.C 2016-06-04 12:09:28.000000000 +0200 @@ -0,0 +1,22 @@ +// PR tree-optimization/71405 +// { dg-do compile } + +struct C +{ + C () {} + int i; +}; + +void * +operator new (__SIZE_TYPE__ x, void *y) +{ + return y; +} + +int +main () +{ + int a; + new (&a) C; + return a; +} Jakub