From patchwork Fri Feb 21 11:32:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 25100 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 460D020143 for ; Fri, 21 Feb 2014 11:32:44 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf3467576yha.11 for ; Fri, 21 Feb 2014 03:32:44 -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:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:content-type; bh=o7hsNcTb6lUgzoJSwDv/9gWQlcq9uLwgzDdW7GZWMPg=; b=jLGCXJm+rzo+MHekpC7TdhneEcDymJyK+T0N4LnwIDslJ1Ux7pfUc2D+3cZb1vVQo8 djKtfBh93XM8j2eIFS/3gHCoLM9x4LFNWina8uyAVkXrtvpwYB4QtmLn5l0pEYrFnfZ0 AACmaENxKaBlbigH6K+56hdWzvip/4nr0Gj3fk5ND4WoZHNrzVYq89QRVw7taoal8ZD8 MDfBinjMBX9qKW0tjyFRo2EbLVz796piXGHDQtmxGw22V4DqD8zaMvmSteUeFDrM8x6m FTyUnPMdPHrVY3ieEOVpNdqZ2FLnZ6WmcbDWVz1IqkiLtDp4X4H8hI8iuqV/1Q9c+d7j 1xaQ== X-Gm-Message-State: ALoCoQko1p4cTkQufzgDod4ZIL1pPnaOa5src4q0mJhZY6mkZ0GFhOWhMVI+SSv0aZTGheRtAPez X-Received: by 10.236.190.199 with SMTP id e47mr2723726yhn.53.1392982363989; Fri, 21 Feb 2014 03:32:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.244 with SMTP id w107ls990507qge.26.gmail; Fri, 21 Feb 2014 03:32:43 -0800 (PST) X-Received: by 10.220.84.193 with SMTP id k1mr4424299vcl.64.1392982363840; Fri, 21 Feb 2014 03:32:43 -0800 (PST) Received: from mail-vc0-x22d.google.com (mail-vc0-x22d.google.com [2607:f8b0:400c:c03::22d]) by mx.google.com with ESMTPS id yx7si2870166vcb.50.2014.02.21.03.32.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Feb 2014 03:32:43 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::22d 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:c03::22d; Received: by mail-vc0-f173.google.com with SMTP id ld13so3092151vcb.4 for ; Fri, 21 Feb 2014 03:32:43 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr4539673vcb.16.1392982363549; Fri, 21 Feb 2014 03:32:43 -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.174.196 with SMTP id u4csp26941vcz; Fri, 21 Feb 2014 03:32:42 -0800 (PST) X-Received: by 10.66.193.202 with SMTP id hq10mr8504325pac.57.1392982362352; Fri, 21 Feb 2014 03:32:42 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id pj6si980171pbb.246.2014.02.21.03.32.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Feb 2014 03:32:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-362177-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 2990 invoked by alias); 21 Feb 2014 11:32:30 -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 2981 invoked by uid 89); 21 Feb 2014 11:32:29 -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, 21 Feb 2014 11:32:28 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 21 Feb 2014 11:32:24 +0000 Received: from SHAWIN205 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 21 Feb 2014 11:32:24 +0000 From: "Joey Ye" To: Subject: [patch] [arm] Fix PR60169 - thumb1 far jump Date: Fri, 21 Feb 2014 19:32:22 +0800 Message-ID: <000401cf2ef8$979e8830$c6db9890$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114022111322406101 X-Original-Sender: joey.ye@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::22d 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 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]; + } + } + } +}