From patchwork Tue Nov 27 12:03:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 202196 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]) by ozlabs.org (Postfix) with SMTP id EA6EF2C008C for ; Tue, 27 Nov 2012 23:04:14 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1354622655; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=t/2i/JQg1GeAHm3l7jQmTPEwfCQ=; b=Tk8Ld+sDm0HSxKR HAYApoWaWmy85ZWlsRHDd6bDBBQu1DcCJ7+kqdnTjmIjvVCP5OJNy/1dwBEPLgV9 +PkzBudgloJ8jUNGRIoERzAkQCim72iAaINm2o95XQ9t8FsaAIiZilbfEzceUBlD zn2jZ/iTzrICbv4DX97X63J7+gsc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=x6c3rlsz3g2NEz0M8xIE3/wQnsmzzbZH/xwNxzDA2yK++GqtecV2Hk+HG2CF9I RURA8HGvkXZPKIdC5yH/FdxUnkfbe0fKP1OhyRVluKLicWAi1TX1uEPJ880Q5TYi Can1VJJXjn810Eg2F3iTP8pWNNQU8B1Fhj2qKHNDythfE=; Received: (qmail 10935 invoked by alias); 27 Nov 2012 12:04:08 -0000 Received: (qmail 10923 invoked by uid 22791); 27 Nov 2012 12:04:07 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Nov 2012 12:03:54 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qARC3pl2002295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Nov 2012 07:03:51 -0500 Received: from zalov.redhat.com (vpn1-7-145.ams2.redhat.com [10.36.7.145]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qARC3nMM023429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Nov 2012 07:03:50 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qARC3moN018975; Tue, 27 Nov 2012 13:03:48 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qARC3lbg018974; Tue, 27 Nov 2012 13:03:47 +0100 Date: Tue, 27 Nov 2012 13:03:47 +0100 From: Jakub Jelinek To: Hans-Peter Nilsson Cc: Eric Botcazou , gcc-patches@gcc.gnu.org, Alexandre Oliva Subject: Re: [RFA:] fix PR55030, wrong code from __builtin_setjmp_receiver Message-ID: <20121127120347.GU2315@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <13011180.NBQR3vZSIa@polaris> <2166177.TtGqA2rZBR@polaris> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Tue, Nov 27, 2012 at 06:44:23AM -0500, Hans-Peter Nilsson wrote: > > We apparently have a small conflict between the meaning of volatile asms with > > operands at the source level and volatile_insn_p. However, I think that the > > latter interpretation is the correct one: if your asm statements have effects > > that can be described, then you should use output constraints instead of > > volatile; otherwise, you should use volatile and the output constraints have > > essentially no meaning. I strongly disagree with this. Outputs and clobbers have significant meaning even on volatile asms, asm volatile doesn't mean all registers and all memory are supposed to be considered clobbered. For memory you have "memory" clobber for that, for registers it is users responsibility to describe exactly what changes, either in clobbers or in outputs. The difference between non-volatile and volatile asm is, as the documentation states: The `volatile' keyword indicates that the instruction has important side-effects. GCC will not delete a volatile `asm' if it is reachable. Volatile asm acts as an optimization barrier to some extent, but it really can't modify registers or memory that aren't described as modified in the asm pattern. The important side-effects are of some other kind than modifying registers or memory visible from the current function. Ditto for UNSPEC_VOLATILE. So, at least from var-tracking POV which doesn't attempt to perform any optimizations across any insn, just tries to track where values live, IMHO a volatile asm acts exactly the same as non-volatile, that is why I'm testing following patch right now. But the question is also what effects your patch can have e.g. on RTL DSE. 2012-11-26 Jakub Jelinek PR debug/36728 PR debug/55467 * cselib.c (cselib_process_insn): If cselib_preserve_constants, don't reset table and exit early on volatile insns and setjmp. Reset table afterwards on setjmp. * gcc.dg/guality/pr36728-1.c: Include "../nop.h", make sure the asm are non-empty and add dependency between the first and second asm. * gcc.dg/guality/pr36728-2.c: Likewise. * gcc.dg/guality/pr36728-3.c: New test. * gcc.dg/guality/pr36728-4.c: New test. Jakub --- gcc/cselib.c.jj 2012-11-26 10:14:26.000000000 +0100 +++ gcc/cselib.c 2012-11-26 20:01:10.488304558 +0100 @@ -2626,11 +2626,12 @@ cselib_process_insn (rtx insn) cselib_current_insn = insn; /* Forget everything at a CODE_LABEL, a volatile insn, or a setjmp. */ - if (LABEL_P (insn) - || (CALL_P (insn) - && find_reg_note (insn, REG_SETJMP, NULL)) - || (NONJUMP_INSN_P (insn) - && volatile_insn_p (PATTERN (insn)))) + if ((LABEL_P (insn) + || (CALL_P (insn) + && find_reg_note (insn, REG_SETJMP, NULL)) + || (NONJUMP_INSN_P (insn) + && volatile_insn_p (PATTERN (insn)))) + && !cselib_preserve_constants) { cselib_reset_table (next_uid); cselib_current_insn = NULL_RTX; @@ -2668,9 +2669,18 @@ cselib_process_insn (rtx insn) /* Look for any CLOBBERs in CALL_INSN_FUNCTION_USAGE, but only after we have processed the insn. */ if (CALL_P (insn)) - for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1)) - if (GET_CODE (XEXP (x, 0)) == CLOBBER) - cselib_invalidate_rtx (XEXP (XEXP (x, 0), 0)); + { + for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1)) + if (GET_CODE (XEXP (x, 0)) == CLOBBER) + cselib_invalidate_rtx (XEXP (XEXP (x, 0), 0)); + /* Flush evertything on setjmp. */ + if (cselib_preserve_constants + && find_reg_note (insn, REG_SETJMP, NULL)) + { + cselib_preserve_only_values (); + cselib_reset_table (next_uid); + } + } /* On setter of the hard frame pointer if frame_pointer_needed, invalidate stack_pointer_rtx, so that sp and {,h}fp based --- gcc/testsuite/gcc.dg/guality/pr36728-1.c.jj 2012-11-26 10:14:25.000000000 +0100 +++ gcc/testsuite/gcc.dg/guality/pr36728-1.c 2012-11-27 10:01:14.517080157 +0100 @@ -1,7 +1,11 @@ /* PR debug/36728 */ /* { dg-do run } */ /* { dg-options "-g" } */ -int a; + +#include "../nop.h" + +int a, b; + int __attribute__((noinline)) foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) { @@ -9,9 +13,9 @@ foo (int arg1, int arg2, int arg3, int a int __attribute__ ((aligned(32))) y; y = 2; - asm ("" : "=m" (y) : "m" (y)); + asm (NOP : "=m" (y), "=m" (b) : "m" (y)); x[0] = 25; - asm ("" : "=m" (x[0]), "=m" (a) : "m" (x[0])); + asm (NOP : "=m" (x[0]), "=m" (a) : "m" (x[0]), "m" (b)); return y; } @@ -21,23 +25,23 @@ foo (int arg1, int arg2, int arg3, int a and arg2. So it is expected that these values are unavailable in some of these tests. */ -/* { dg-final { gdb-test 12 "arg1" "1" { target { ! "s390*-*-*" } } } }*/ -/* { dg-final { gdb-test 12 "arg2" "2" { target { ! "s390*-*-*" } } } }*/ -/* { dg-final { gdb-test 12 "arg3" "3" } } */ -/* { dg-final { gdb-test 12 "arg4" "4" } } */ -/* { dg-final { gdb-test 12 "arg5" "5" } } */ -/* { dg-final { gdb-test 12 "arg6" "6" } } */ -/* { dg-final { gdb-test 12 "arg7" "30" } } */ -/* { dg-final { gdb-test 12 "y" "2" } } */ -/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } }*/ -/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } }*/ -/* { dg-final { gdb-test 14 "arg3" "3" } } */ -/* { dg-final { gdb-test 14 "arg4" "4" } } */ -/* { dg-final { gdb-test 14 "arg5" "5" } } */ -/* { dg-final { gdb-test 14 "arg6" "6" } } */ -/* { dg-final { gdb-test 14 "arg7" "30" } } */ -/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */ -/* { dg-final { gdb-test 14 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ +/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg3" "3" } } */ +/* { dg-final { gdb-test 18 "arg4" "4" } } */ +/* { dg-final { gdb-test 18 "arg5" "5" } } */ +/* { dg-final { gdb-test 18 "arg6" "6" } } */ +/* { dg-final { gdb-test 18 "arg7" "30" } } */ +/* { dg-final { gdb-test 18 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 18 "y" "2" } } */ int main () --- gcc/testsuite/gcc.dg/guality/pr36728-2.c.jj 2012-11-26 10:14:25.000000000 +0100 +++ gcc/testsuite/gcc.dg/guality/pr36728-2.c 2012-11-27 10:00:46.237254022 +0100 @@ -1,7 +1,11 @@ /* PR debug/36728 */ /* { dg-do run } */ /* { dg-options "-g" } */ -int a; + +#include "../nop.h" + +int a, b; + int __attribute__((noinline)) foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) { @@ -9,9 +13,9 @@ foo (int arg1, int arg2, int arg3, int a int __attribute__ ((aligned(32))) y; y = 2; - asm ("" : "=m" (y) : "m" (y)); + asm (NOP : "=m" (y), "=m" (b) : "m" (y)); x[0] = 25; - asm ("" : "=m" (x[0]), "=m" (a) : "m" (x[0])); + asm (NOP : "=m" (x[0]), "=m" (a) : "m" (x[0]), "m" (b)); return y; } @@ -21,23 +25,23 @@ foo (int arg1, int arg2, int arg3, int a and arg2. So it is expected that these values are unavailable in some of these tests. */ -/* { dg-final { gdb-test 12 "arg1" "1" { target { ! "s390*-*-*" } } } } */ -/* { dg-final { gdb-test 12 "arg2" "2" { target { ! "s390*-*-*" } } } } */ -/* { dg-final { gdb-test 12 "arg3" "3" } } */ -/* { dg-final { gdb-test 12 "arg4" "4" } } */ -/* { dg-final { gdb-test 12 "arg5" "5" } } */ -/* { dg-final { gdb-test 12 "arg6" "6" } } */ -/* { dg-final { gdb-test 12 "arg7" "30" } } */ -/* { dg-final { gdb-test 12 "y" "2" } } */ -/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } } */ -/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } } */ -/* { dg-final { gdb-test 14 "arg3" "3" } } */ -/* { dg-final { gdb-test 14 "arg4" "4" } } */ -/* { dg-final { gdb-test 14 "arg5" "5" } } */ -/* { dg-final { gdb-test 14 "arg6" "6" } } */ -/* { dg-final { gdb-test 14 "arg7" "30" } } */ -/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */ -/* { dg-final { gdb-test 14 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ +/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg3" "3" } } */ +/* { dg-final { gdb-test 18 "arg4" "4" } } */ +/* { dg-final { gdb-test 18 "arg5" "5" } } */ +/* { dg-final { gdb-test 18 "arg6" "6" } } */ +/* { dg-final { gdb-test 18 "arg7" "30" } } */ +/* { dg-final { gdb-test 18 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 18 "y" "2" } } */ int main () --- gcc/testsuite/gcc.dg/guality/pr36728-3.c.jj 2012-11-26 18:58:40.896599886 +0100 +++ gcc/testsuite/gcc.dg/guality/pr36728-3.c 2012-11-27 10:01:45.455892012 +0100 @@ -0,0 +1,51 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int __attribute__((noinline)) +foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) +{ + char *x = __builtin_alloca (arg7); + int __attribute__ ((aligned(32))) y; + + y = 2; + asm (NOP : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile (NOP : "=m" (x[0]) : "m" (x[0])); + return y; +} + +/* On s390(x) r2 and r3 are (depending on the optimization level) used + when adjusting the addresses in order to meet the alignment + requirements above. They usually hold the function arguments arg1 + and arg2. So it is expected that these values are unavailable in + some of these tests. */ + +/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg3" "3" } } */ +/* { dg-final { gdb-test 14 "arg4" "4" } } */ +/* { dg-final { gdb-test 14 "arg5" "5" } } */ +/* { dg-final { gdb-test 14 "arg6" "6" } } */ +/* { dg-final { gdb-test 14 "arg7" "30" } } */ +/* { dg-final { gdb-test 14 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm volatile ("" : "=r" (l) : "0" (l)); + foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +} --- gcc/testsuite/gcc.dg/guality/pr36728-4.c.jj 2012-11-26 18:58:44.624580656 +0100 +++ gcc/testsuite/gcc.dg/guality/pr36728-4.c 2012-11-26 14:56:12.000000000 +0100 @@ -0,0 +1,51 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int __attribute__((noinline)) +foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) +{ + char x[30]; + int __attribute__ ((aligned(32))) y; + + y = 2; + asm (NOP : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile (NOP : "=m" (x[0]) : "m" (x[0])); + return y; +} + +/* On s390(x) r2 and r3 are (depending on the optimization level) used + when adjusting the addresses in order to meet the alignment + requirements above. They usually hold the function arguments arg1 + and arg2. So it is expected that these values are unavailable in + some of these tests. */ + +/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg3" "3" } } */ +/* { dg-final { gdb-test 14 "arg4" "4" } } */ +/* { dg-final { gdb-test 14 "arg5" "5" } } */ +/* { dg-final { gdb-test 14 "arg6" "6" } } */ +/* { dg-final { gdb-test 14 "arg7" "30" } } */ +/* { dg-final { gdb-test 14 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm volatile ("" : "=r" (l) : "0" (l)); + foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +}