From patchwork Fri Feb 28 02:42:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 25499 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A8042055D for ; Fri, 28 Feb 2014 02:42:51 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id 131sf631041ykp.1 for ; Thu, 27 Feb 2014 18:42:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:x-original-sender :x-original-authentication-results:content-type; bh=2ZvDiQhdJhLZigQbq0mFory+kCMyoTTI5f1/CLjAckU=; b=Uzamr4Cw2RqHGBhzJ+a6xeKt3zrRp4w+8GQJNIV2JY8rkB8VdZi/hGKsZAPsbIJIQ6 /0O2HBLS0yovgSciGjh4E0ZLP2kb3+lUCGgTAL8heT7Gxdgl7AkwXkxzYkqHqLvYt6dz kInYgA1DD0UWIuUkuvcdaTsymIMUTBPBeMC95E74l5w9ziSAIu17usU5aC78wX343euO LUsqEOLMoV+wWAQmYLO1JJTSoDP/oI2bXd7xUaP5gBpq8SB1THF5Uyc3BLQ6m5wC7Xrp x//PXHdhc7p7JBwiP8TmP3KGVbYe/UwH4Dvui4URFTwH3rFt/pw48p0khHGZmvyNDMz1 /AWg== X-Gm-Message-State: ALoCoQlQ2+baH6aEJAyAff/KR4CbMhAb/qMaD3Zh4v/rvqHqLwFVcg+5uNMD4QMWfraSrJ4Juj/8 X-Received: by 10.52.29.16 with SMTP id f16mr6434556vdh.8.1393555371245; Thu, 27 Feb 2014 18:42:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.113 with SMTP id p104ls904927qga.41.gmail; Thu, 27 Feb 2014 18:42:51 -0800 (PST) X-Received: by 10.58.118.233 with SMTP id kp9mr295956veb.52.1393555371157; Thu, 27 Feb 2014 18:42:51 -0800 (PST) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id cl8si496924vcb.76.2014.02.27.18.42.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Feb 2014 18:42:50 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id oy12so117040veb.20 for ; Thu, 27 Feb 2014 18:42:50 -0800 (PST) X-Received: by 10.220.88.204 with SMTP id b12mr267541vcm.3.1393555370763; Thu, 27 Feb 2014 18:42:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp21889vcs; Thu, 27 Feb 2014 18:42:50 -0800 (PST) X-Received: by 10.66.155.133 with SMTP id vw5mr527240pab.124.1393555369463; Thu, 27 Feb 2014 18:42:49 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id wq4si275101pbc.47.2014.02.27.18.42.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Feb 2014 18:42:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-362510-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 2408 invoked by alias); 28 Feb 2014 02:42:34 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 2372 invoked by uid 89); 28 Feb 2014 02:42:30 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2014 02:42:28 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 28 Feb 2014 02:42:25 +0000 Received: from SHAWIN205 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 28 Feb 2014 02:42:28 +0000 From: "Joey Ye" To: "Ramana Radhakrishnan" Cc: References: In-Reply-To: Subject: RE: [patch] [arm] Fix PR60169 - thumb1 far jump Date: Fri, 28 Feb 2014 10:42:26 +0800 Message-ID: <001e01cf342e$b8e04840$2aa0d8c0$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114022802422600101 X-Original-Sender: joey.ye@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Ping. OK for trunk and 4.8? > -----Original Message----- > From: Joey Ye [mailto:joey.ye@arm.com] > Sent: 21 February 2014 19:32 > To: gcc-patches@gcc.gnu.org > Subject: [patch] [arm] Fix PR60169 - thumb1 far jump > > Patch http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01229.html introduced > this ICE: > > 1. thumb1 estimate if far_jump is used based on function insn size 2. During > reload, after stack layout finalized, it does reload_as_needed. It however > increases insn size that changes estimation result of far_jump, which in > return need to save lr and change stack layout again. While there is not > chance to change, GCC crashes. > > Solution: > Do not change estimation result of far_jump if reload_in_progress or > reload_completed is true. > > Not likely need to fix lra according to Vlad: > http://gcc.gnu.org/ml/gcc/2014-02/msg00355.html > > ChangeLog: > * config/arm/arm.c (thumb_far_jump_used_p): Don't change > if reload in progress or completed. > > * gcc.target/arm/thumb1-far-jump-3.c: New case. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index b562986..2cf362c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -26255,6 +26255,11 @@ thumb_far_jump_used_p (void) return 0; } + /* We should not change far_jump_used during or after reload, as there is + no chance to change stack frame layout. */ + if (reload_in_progress || reload_completed) + return 0; + /* Check to see if the function contains a branch insn with the far jump attribute set. */ for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) diff --git a/gcc/testsuite/gcc.target/arm/thumb1-far-jump-3.c b/gcc/testsuite/gcc.target/arm/thumb1-far-jump-3.c new file mode 100644 index 0000000..90559ba --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/thumb1-far-jump-3.c @@ -0,0 +1,108 @@ +/* Catch reload ICE on target thumb1 with far jump optimization. + * It is also a valid case for non-thumb1 target. */ + +/* Add -mno-lra option as it is only reproducable with reload. It will + be removed after reload is completely removed. */ +/* { dg-options "-mno-lra -fomit-frame-pointer" } */ +/* { dg-do compile } */ + +#define C 2 +#define A 4 +#define RGB (C | A) +#define GRAY (A) + +typedef unsigned long uint_32; +typedef unsigned char byte; +typedef byte * bytep; + +typedef struct ss +{ + uint_32 w; + uint_32 r; + byte c; + byte b; + byte p; +} info; + +typedef info * infop; + +void +foo(infop info, bytep row) +{ + uint_32 iw = info->w; + if (info->c == RGB) + { + if (info->b == 8) + { + bytep sp = row + info->r; + bytep dp = sp; + byte save; + uint_32 i; + + for (i = 0; i < iw; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + + else + { + bytep sp = row + info->r; + bytep dp = sp; + byte save[2]; + uint_32 i; + + for (i = 0; i < iw; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } + else if (info->c == GRAY) + { + if (info->b == 8) + { + bytep sp = row + info->r; + bytep dp = sp; + byte save; + uint_32 i; + + for (i = 0; i < iw; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + else + { + bytep sp = row + info->r; + bytep dp = sp; + byte save[2]; + uint_32 i; + + for (i = 0; i < iw; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } +}