From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115356 invoked by alias); 27 Jun 2017 05:47:54 -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 108459 invoked by uid 89); 27 Jun 2017 05:46:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=HTo:U*rguenther 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 ESMTP; Tue, 27 Jun 2017 05:46:38 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C54FA3345BF; Tue, 27 Jun 2017 05:46:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C54FA3345BF Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C54FA3345BF Received: from tucnak.zalov.cz (ovpn-116-143.ams2.redhat.com [10.36.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E82381C85; Tue, 27 Jun 2017 05:46:36 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v5R5kXnv012634; Tue, 27 Jun 2017 07:46:34 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v5R5kWIu012131; Tue, 27 Jun 2017 07:46:32 +0200 Date: Tue, 27 Jun 2017 05:47:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE during strstr gimple folding (PR middle-end/81207) Message-ID: <20170627054632.GM2123@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg01971.txt.bz2 Hi! replace_call_with_call_and_fold has code to copy over vdef/vuse from the old call to the new one, so that we don't have to update virtual ssa, but it is conditioned on gimple_vdef being non-NULL and SSA_NAME. If we have a pure function, gimple_vdef is NULL, yet we still want to copy over the vuse. Bootstrapped/regtested on x86_64-linux (i686-linux fails to bootstrap with/without this patch), ok for trunk? 2017-06-27 Jakub Jelinek PR middle-end/81207 * gimple-fold.c (replace_call_with_call_and_fold): Handle gimple_vuse copying separately from gimple_vdef copying. * gcc.c-torture/compile/pr81207.c: New test. --- gcc/gimple-fold.c.jj 2017-06-19 08:28:11.000000000 +0200 +++ gcc/gimple-fold.c 2017-06-26 17:09:34.735420583 +0200 @@ -607,9 +607,11 @@ replace_call_with_call_and_fold (gimple_ && TREE_CODE (gimple_vdef (stmt)) == SSA_NAME) { gimple_set_vdef (repl, gimple_vdef (stmt)); - gimple_set_vuse (repl, gimple_vuse (stmt)); SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl; } + if (gimple_vuse (stmt) + && TREE_CODE (gimple_vuse (stmt)) == SSA_NAME) + gimple_set_vuse (repl, gimple_vuse (stmt)); gsi_replace (gsi, repl, false); fold_stmt (gsi); } --- gcc/testsuite/gcc.c-torture/compile/pr81207.c.jj 2017-06-26 17:21:38.765918367 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr81207.c 2017-06-26 17:27:15.222966965 +0200 @@ -0,0 +1,13 @@ +/* PR middle-end/81207 */ + +static const char *b[2] = { "'", "" }; + +int +foo (const char *d) +{ + int e; + for (e = 0; b[e]; e++) + if (__builtin_strstr (d, b[e])) + return 1; + return 0; +} Jakub