From patchwork Mon Jan 12 20:26:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 428117 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 15B091400F1 for ; Tue, 13 Jan 2015 07:26:19 +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; q=dns; s=default; b=BF6rn2G5ykNqrWa6aUnW0GyEodQh0 p+ebJnfIGWZYmVOE1Zk+X1cxV+moE1XVsEB3RUuX745yqX47FwK+ssPxadB2/JeD bGUUgnOR+OXobJAvQDHRhrW64B6PYJoMYvhJbS3mrzuM06dFzPaEZ7Vs68J3UVmD nX5uZPUwrrbRQ8= 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; s=default; bh=z5UN+DBncdB1wH5O+cv4WYZuAQ8=; b=EH0 4imL/MlrjaU036cmojqlXVihpsl0grDfgPGtUUn/OoFHtsVCpxGkaC9QYInobP3W VsWwtGHd8mHCghYGhceyyLYhJHh7o4DtYmhCej9Dder1y4CFhuqFCAF53H2M2Du8 2uF+fsYJHSfDttde9QYtH3mig/9VLW7Gj6SfXOsk= Received: (qmail 5923 invoked by alias); 12 Jan 2015 20:26:13 -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 5910 invoked by uid 89); 12 Jan 2015 20:26:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Mon, 12 Jan 2015 20:26:10 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0CKQ9kY011261 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Jan 2015 15:26:09 -0500 Received: from tucnak.zalov.cz (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0CKQ7Fu026470 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 12 Jan 2015 15:26:09 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t0CKQ6sN012651; Mon, 12 Jan 2015 21:26:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t0CKQ5v7012650; Mon, 12 Jan 2015 21:26:05 +0100 Date: Mon, 12 Jan 2015 21:26:04 +0100 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -mstack-arg-probe (PR target/64513) Message-ID: <20150112202604.GT1405@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! For -mstack-arg-probe we push %rax and/or %r10 in the prologue, and mark that insn as RTX_FRAME_RELATED_P. But that means that the dwarf2 pass also considers that the %rax/%r10 registers, which are call used, to be saved in the unwind info, but they are never restored, which makes the dwarf2 pass ICE on it. Fixed by letting the dwarf2 pass know just that those instructions decrease stack pointer. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-01-12 Jakub Jelinek PR target/64513 * config/i386/i386.c (ix86_expand_prologue): Add REG_FRAME_RELATED_EXPR to %rax and %r10 pushes. * gcc.target/i386/pr64513.c: New test. Jakub --- gcc/config/i386/i386.c.jj 2015-01-09 22:00:02.000000000 +0100 +++ gcc/config/i386/i386.c 2015-01-12 17:13:21.342463547 +0100 @@ -11559,6 +11559,10 @@ ix86_expand_prologue (void) if (sp_is_cfa_reg) m->fs.cfa_offset += UNITS_PER_WORD; RTX_FRAME_RELATED_P (insn) = 1; + add_reg_note (insn, REG_FRAME_RELATED_EXPR, + gen_rtx_SET (VOIDmode, stack_pointer_rtx, + plus_constant (Pmode, stack_pointer_rtx, + -UNITS_PER_WORD))); } } @@ -11572,6 +11576,10 @@ ix86_expand_prologue (void) if (sp_is_cfa_reg) m->fs.cfa_offset += UNITS_PER_WORD; RTX_FRAME_RELATED_P (insn) = 1; + add_reg_note (insn, REG_FRAME_RELATED_EXPR, + gen_rtx_SET (VOIDmode, stack_pointer_rtx, + plus_constant (Pmode, stack_pointer_rtx, + -UNITS_PER_WORD))); } } --- gcc/testsuite/gcc.target/i386/pr64513.c.jj 2015-01-12 17:20:12.052330807 +0100 +++ gcc/testsuite/gcc.target/i386/pr64513.c 2015-01-12 17:20:02.000000000 +0100 @@ -0,0 +1,17 @@ +/* PR target/64513 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mstack-arg-probe" } */ + +struct A {}; +struct B { struct A y; }; +int foo (struct A); + +int +bar (int x) +{ + struct B b; + int c; + while (x--) + c = foo (b.y); + return c; +}