From patchwork Tue Nov 19 23:58:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1197693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514088-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nxsrWzCr"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="cp7/IIJX"; dkim-atps=neutral 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 47HjTJ310Fz9s7T for ; Wed, 20 Nov 2019 10:58:44 +1100 (AEDT) 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:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=JtO hAHQVGFr0rTbut47Snv+PxPW9RKF1Fwi5Cou0LZyxZqe7lU1nLdZ8+uC2eAS4gRV ClcuaRM+VdahuTtJiX7NFvluO08GIzS57zlXxmi61OqpofNN47zRsAuAQzSwdntb zA+YIdDlFoCbH32nc7CgQHNb/55YEo6k7U0aacMY= 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:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=NZQs35CNs DXYNPkb8IUOFJziAbM=; b=nxsrWzCr1QZeg/S0FFK+saIF858YAXG8w99sDPPXg LdRJSyj5rBn6KoM5MYS0HUQi3HDjLpXAQRiOs9fqD+x3L+/oAFD+HSUipdLaUZIM wSzqCop9CvjsCp3S5eyisH7C87iEBGwPM3ED/Ry/xlUhsnQ6xalptFot6nhsS+we PU= Received: (qmail 126214 invoked by alias); 19 Nov 2019 23:58:37 -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 126202 invoked by uid 89); 19 Nov 2019 23:58:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Nov 2019 23:58:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574207914; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jkCsLIcVW1VK5xqiKu1nF6rKCgKgVK9EvgevkgjOCWY=; b=cp7/IIJXdj1iJzAAi40VrgeBzlwVmmcPU/8lqLUHSOcDzqfqzAh2Yk73p+xb1vamWh7CPW hRLReBchSEIXQxm7Leg+LHxRGjBtK0Hy9iB+kpHKKfJzMoq8kLwSKWZHWOJyJ+r/rlxWBf Gta5xHHGoScdpTQqJkic1UerOgdYDto= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-X3nL_P7ZMpCwXuNEInSLmg-1; Tue, 19 Nov 2019 18:58:31 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 263BD18B5F9A; Tue, 19 Nov 2019 23:58:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-21.ams2.redhat.com [10.36.116.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1DA3503F5; Tue, 19 Nov 2019 23:58:29 +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 xAJNwRFV029848; Wed, 20 Nov 2019 00:58:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xAJNwRCm029847; Wed, 20 Nov 2019 00:58:27 +0100 Date: Wed, 20 Nov 2019 00:58:27 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE with __builtin_stack_save (PR c/90898) Message-ID: <20191119235827.GS4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! I agree that we shouldn't have made __builtin_stack_{save,restore} public, but I'd fear it is too late to remove it now (and replace by internal fn), I'd think some code might use it to control when e.g. alloca will be released. As the comment on insert_clobber* says, the addition of the clobbers is a best effort, we could end up not finding the right spot and not adding the CLOBBER in there even without user __builtin_* calls, so this patch just removes an unnecessary assertion and just will not find __builtin_stack_restore if something weird is seen, such as in the testcase storing of the __builtin_stack_save result into memory, or could be a cast or whatever else too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-19 Jakub Jelinek PR c/90898 * tree-ssa-ccp.c (insert_clobber_before_stack_restore): Remove assertion. (insert_clobbers_for_var): Fix a typo in function comment. * gcc.dg/pr90898.c: New test. Jakub --- gcc/tree-ssa-ccp.c.jj 2019-11-13 10:54:47.093020613 +0100 +++ gcc/tree-ssa-ccp.c 2019-11-19 19:13:35.332705130 +0100 @@ -2114,8 +2114,6 @@ insert_clobber_before_stack_restore (tre else if (gimple_assign_ssa_name_copy_p (stmt)) insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var, visited); - else - gcc_assert (is_gimple_debug (stmt)); } /* Advance the iterator to the previous non-debug gimple statement in the same @@ -2140,9 +2138,9 @@ gsi_prev_dom_bb_nondebug (gimple_stmt_it /* Find a BUILT_IN_STACK_SAVE dominating gsi_stmt (I), and insert a clobber of VAR before each matching BUILT_IN_STACK_RESTORE. - It is possible that BUILT_IN_STACK_SAVE cannot be find in a dominator when a - previous pass (such as DOM) duplicated it along multiple paths to a BB. In - that case the function gives up without inserting the clobbers. */ + It is possible that BUILT_IN_STACK_SAVE cannot be found in a dominator when + a previous pass (such as DOM) duplicated it along multiple paths to a BB. + In that case the function gives up without inserting the clobbers. */ static void insert_clobbers_for_var (gimple_stmt_iterator i, tree var) --- gcc/testsuite/gcc.dg/pr90898.c.jj 2019-11-19 19:18:02.277712801 +0100 +++ gcc/testsuite/gcc.dg/pr90898.c 2019-11-19 19:18:52.613959787 +0100 @@ -0,0 +1,16 @@ +/* PR c/90898 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void *p; +int bar (void); +void baz (int *); + +void +foo (void) +{ + p = __builtin_stack_save (); + int a[(bar (), 2)]; + baz (a); + __builtin_stack_restore (p); +}