From patchwork Mon May 12 10:17:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 347948 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 5A090140077 for ; Mon, 12 May 2014 20:17:30 +1000 (EST) 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:mime-version:content-type; q=dns; s=default; b=yIN6uuv1ONkxiXaY3R1ZaCx+2OHzDSTgl8EjOBd7ceimiYzjf3 l/fL/t7ZAuhenJxMhRdvc61GJ13q/AV3Tf2BZGnh05niT7kuoX7m3gv+foRF+Qju klMp3O/6/byAsIPvmibYjmVGqPU/MJK0LfILp58poNpC92iyEHADgICeo= 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:mime-version:content-type; s= default; bh=Wksa8FZqLNJ/Lle+hIp0NBmZjvo=; b=ljC2UlTukZQ5L3NCcqGo VTftW3zJ3wzIEtD5dsYyEqa+U7SW3MpNQxdTS9CY3Dj0WkbfvREimfkYSDTUAOUM 6uki2+ZHMjwM8Zgc0l/X6ksdX6vposC0CfCOsCS888iNeO30OjHkbUzdWIyWIgQX 3ojsvbG+gT2KGhN/f6gEYpU= Received: (qmail 30331 invoked by alias); 12 May 2014 10:17:22 -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 30300 invoked by uid 89); 12 May 2014 10:17:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: SJOEDG01.corp.atmel.com Received: from nasmtp02.atmel.com (HELO SJOEDG01.corp.atmel.com) (204.2.163.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 May 2014 10:17:20 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by sjoedg01.corp.atmel.com (10.64.253.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 12 May 2014 03:17:57 -0700 Received: from PENCHT01.corp.atmel.com (10.168.5.161) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 12 May 2014 18:17:20 +0800 Received: from atmel.com (10.168.5.13) by cas-ap.atmel.com (10.168.5.161) with Microsoft SMTP Server (TLS) id 14.2.342.3; Mon, 12 May 2014 18:17:15 +0800 Date: Mon, 12 May 2014 15:47:14 +0530 From: Senthil Kumar Selvaraj To: CC: , Subject: [Patch, avr] Fix PR60991 Message-ID: <20140512101714.GB1830@atmel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This trivial patch fixes PR60991 by correcting the constant used to restore Y in one of the assembler template variants used in avr_out_store_psi. I've also added a testcase (modified from the original poster's code). If ok, could someone commit please? I don't have commit access. It would be great if this was also committed to 4.9 and 4.8 branches as well. Regards Senthil gcc/ChangeLog 2014-05-12 Senthil Kumar Selvaraj PR target/60991 * config/avr/avr.c (avr_out_store_psi): Use correct constant to restore Y. gcc/testsuite/ChangeLog 2014-05-12 Senthil Kumar Selvaraj PR target/60991 * gcc.target/avr/pr60991.c: New testcase. diff --git gcc/config/avr/avr.c gcc/config/avr/avr.c index 536fe68..fc6c9f6 100644 --- gcc/config/avr/avr.c +++ gcc/config/avr/avr.c @@ -3999,7 +3999,7 @@ avr_out_store_psi (rtx insn, rtx *op, int *plen) "std Y+61,%A1" CR_TAB "std Y+62,%B1" CR_TAB "std Y+63,%C1" CR_TAB - "sbiw r28,%o0-60", op, plen, -5); + "sbiw r28,%o0-61", op, plen, -5); return avr_asm_len ("subi r28,lo8(-%o0)" CR_TAB "sbci r29,hi8(-%o0)" CR_TAB diff --git gcc/testsuite/gcc.target/avr/pr60991.c gcc/testsuite/gcc.target/avr/pr60991.c new file mode 100644 index 0000000..a09f42a --- /dev/null +++ gcc/testsuite/gcc.target/avr/pr60991.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +/* This testcase (simplified from the original bug report) exposes + PR60991. The code generated for writing the __int24 value corrupts + the frame pointer if the offset is <= 63 + MAX_LD_OFFSET */ + +#include + +int main(void) +{ + volatile char junk[62]; + junk[0] = 5; + volatile __int24 staticConfig = 0; + + if (junk[0] != 5) + abort(); + + exit(0); + return 0; +}