From patchwork Mon Sep 5 12:31:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 113343 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 792B1B6F64 for ; Mon, 5 Sep 2011 22:32:43 +1000 (EST) Received: (qmail 25552 invoked by alias); 5 Sep 2011 12:32:41 -0000 Received: (qmail 25543 invoked by uid 22791); 5 Sep 2011 12:32:40 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_FAIL X-Spam-Check-By: sourceware.org Received: from smtp-vbr4.xs4all.nl (HELO smtp-vbr4.xs4all.nl) (194.109.24.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Sep 2011 12:32:24 +0000 Received: from [192.168.1.68] (teejay.xs4all.nl [213.84.119.160]) (authenticated bits=0) by smtp-vbr4.xs4all.nl (8.13.8/8.13.8) with ESMTP id p85CW7Y0027245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 Sep 2011 14:32:09 +0200 (CEST) (envelope-from vries@codesourcery.com) Message-ID: <4E64C124.4090507@codesourcery.com> Date: Mon, 05 Sep 2011 14:31:32 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13 MIME-Version: 1.0 To: Jakub Jelinek CC: Eric Botcazou , "gcc-patches@gcc.gnu.org" Subject: Re: rtl_verify_flow_info fix References: <4E64885E.7040406@codesourcery.com> <20110905085300.GZ2687@tyan-ft48-01.lab.bos.redhat.com> In-Reply-To: <20110905085300.GZ2687@tyan-ft48-01.lab.bos.redhat.com> 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 09/05/2011 10:53 AM, Jakub Jelinek wrote: > On Mon, Sep 05, 2011 at 10:29:18AM +0200, Tom de Vries wrote: >> Hi Eric, >> >> During testing the approved-for-commit middle-end patch for bug 43864 on ARM, I >> ran into a gcc.dg/torture/pr46068.c ICE. >> >> An asm jump is not recognized as an unconditional jump, so its followed by a >> fall-through block rather than a barrier. >> ... >> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 [] >> [] >> [ >> (label_ref:SI 16) >> ] pr46068.c:16) pr46068.c:6 -1 >> (nil) >> -> 16) >> ... >> >> ce3 then turns the asm jump into an asm return, still without a barrier after it: >> ... >> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 [] >> [] >> [ >> (return) >> ] pr46068.c:16) pr46068.c:6 -1 >> (nil) >> -> return) >> ... > > I'd say the above transformation shouldn't be valid, asm goto is given some > possible labels it can jump to, but what will be emitted when the operand is > RETURN? I think final.c does: > else if (letter == 'l') > output_asm_label (operands[opnum]); > here and when operands[opnum] isn't a label or deleted label, that function > will > output_operand_lossage ("'%%l' operand isn't a label"); > You don't get it only because this testcase uses empty inline asm string > and thus doesn't use any of the labels. Right, if I use something like "b %l0", I hit the error you describe. > > Jakub I managed to prevent the transformation using attached untested patch. Is this the proper way to fix this? Thanks, - Tom Index: gcc/recog.c =================================================================== --- gcc/recog.c (revision 178145) +++ gcc/recog.c (working copy) @@ -118,6 +118,46 @@ init_recog (void) } +/* Return true if labels in asm operands BODY are LABEL_REFs. */ + +static bool +asm_labels_ok (rtx body) +{ + rtx first, asmop = NULL; + int i; + + if (asm_noperands (body) <= 0) + return true; + + switch (GET_CODE (body)) + { + case ASM_OPERANDS: + asmop = body; + break; + + case SET: + asmop = SET_SRC (body); + break; + + case PARALLEL: + first = XVECEXP (body, 0, 0); + if (GET_CODE (first) != SET) + return true; + asmop = SET_SRC (first); + break; + default: + gcc_unreachable (); + break; + } + + gcc_assert (GET_CODE (asmop) == ASM_OPERANDS); + + for (i = 0; i < ASM_OPERANDS_LABEL_LENGTH (asmop); i++) + if (GET_CODE (ASM_OPERANDS_LABEL (asmop, i)) != LABEL_REF) + return false; + return true; +} + /* Check that X is an insn-body for an `asm' with operands and that the operands mentioned in it are legitimate. */ @@ -129,6 +169,9 @@ check_asm_operands (rtx x) const char **constraints; int i; + if (!asm_labels_ok (x)) + return 0; + /* Post-reload, be more strict with things. */ if (reload_completed) {