From patchwork Thu Jun 23 11:00:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 639587 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 3rZz623L3Pz9t0X for ; Thu, 23 Jun 2016 21:00:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CHXWUA4F; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=l7xWNGATOdlkDU86O XE4MadKn5RD/DX3/idqklkfLphXiXKUobFj4Mw58A9Esxe8UcFSdPHUHbhnALomP sCoW9eY9H5rpq1UtFdk/SxM08EhuAhjfz3hLKro62yIY4xmE+gsseTIC7tQx3WfH lqRWfAlBaMhhs1CID9xs43aop4= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=2h1o3jwjxc+GjizazjsYss6 FwsA=; b=CHXWUA4FJprof/C9YHnkuVRy8XAyt7kZVuF7RFd1WIlfeiLEcKKV7R0 U7dUNKnr5P6XlcxBAOI3u5eLjrhJYnyAXbU/R1MN1lB6/goL5ZYxZ5rRDpTksV8z bZkhqro94BenKcqYO723+UECzwPQN6EgKP71CgeiDDJJJPbn31ck= Received: (qmail 60963 invoked by alias); 23 Jun 2016 11:00:40 -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 60479 invoked by uid 89); 23 Jun 2016 11:00:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*RU:sk:mail.hi, H*r:sk:mail.hi, Hx-spam-relays-external:sk:mail.hi, straddling X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.161) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 23 Jun 2016 11:00:23 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwR/bcHRirORRW3yMcVao= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (mail.hightec-rt.com [213.135.1.215]) by smtp.strato.de (RZmta 38.6 DYNA|AUTH) with ESMTPSA id I0b883s5NB0D1Yg (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 23 Jun 2016 13:00:13 +0200 (CEST) Subject: Re: [patch, avr]: ad PR71151: Make test cases pass on smaller targets. To: Mike Stump References: <82BCC3B6-2C3A-423E-B8BC-9CB21272E036@comcast.net> Cc: GCC Patches , Senthil Kumar Selvaraj , Denis Chertykov From: Georg-Johann Lay Message-ID: <58012f82-0297-69e5-a322-e38452e3f643@gjlay.de> Date: Thu, 23 Jun 2016 13:00:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <82BCC3B6-2C3A-423E-B8BC-9CB21272E036@comcast.net> X-IsSubscribed: yes On 22.06.2016 19:06, Mike Stump wrote: > On Jun 22, 2016, at 7:21 AM, Georg-Johann Lay wrote: >> >> Some tests for PR71151 assume that the target MCU has a 3-byte PC. The >> tests are failing because the simulator (avrtest) rejects to load the >> respective executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128 >> which has only flash of 128KiB and only a 2-byte PC. >> >> Hence the tests have to be skipped if the target MCU has no 3-byte PC, >> hence a new dg-require-effective-target proc supporting "avr_3byte_pc". >> >> I added the new proc right after the last check_effective_target_arm_*** >> so that the test is in ASCII collating order. >> >> Ok for trunk and v6? > > No. Please see target-utils.exp and ensure that the tools generate a > stylized message and then add support for that to target-utils.exp. If you > are using binutils, the text should go into a memory segment that will fill Binutils don't produce a message so there is nothing to scan for. Hacking binutils is beyond my scope. > when it is too large. When it does, then binutils will generate one of the > messages already handled, then you're done. avrtest behaves just as if the program under test would call abort. There are at least 2 other AVR simulators; dunno how they would handle the situation. I don't see how an a-posteriori test could be independent of simulator, independent of board descriptions and all that stuff. The tests in question don't fail because the program is too big as a result of some mussed optimization; some code is deliberately placed across a 64KiB or 128KiB boundary or beyond 128KiB. All this is known a priori. Hence dropping the original patch and proposing a new one that doesn't need extensions to lib. The new tests just won't put any code at places where we know in advance some simulator might barf. As the compiler has no idea of exact flash size, the relevant flash property is deduced from ISA properties. Is this one ok? Johann gcc/testsuite/ PR target/71151 * gcc.target/avr/pr71151-common.h (foo): Use macro SECTION_NAME instead of ".foo" for its section name. * gcc.target/avr/pr71151-2.c (SECTION_NAME): Define appropriately depending on MCU's flash size. * gcc.target/avr/pr71151-3.c (SECTION_NAME): Dito. * gcc.target/avr/pr71151-4.c (SECTION_NAME): Dito. * gcc.target/avr/pr71151-5.c (SECTION_NAME): Dito. * gcc.target/avr/pr71151-6.c (SECTION_NAME): Dito. * gcc.target/avr/pr71151-7.c (SECTION_NAME): Dito. * gcc.target/avr/pr71151-8.c (SECTION_NAME): Dito. Index: gcc.target/avr/pr71151-2.c =================================================================== --- gcc.target/avr/pr71151-2.c (revision 237587) +++ gcc.target/avr/pr71151-2.c (working copy) @@ -5,6 +5,8 @@ flash address for loading jump table entry, 2 byte entry, after removing the special section placement hook. */ +#define SECTION_NAME ".foo" + #include "exit-abort.h" #include "pr71151-common.h" Index: gcc.target/avr/pr71151-3.c =================================================================== --- gcc.target/avr/pr71151-3.c (revision 237587) +++ gcc.target/avr/pr71151-3.c (working copy) @@ -1,10 +1,17 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -mno-relax -fdata-sections -Wl,--section-start=.foo=0x10000" } */ +#ifdef __AVR_HAVE_ELPM__ /* Make sure jumptables work properly if placed above 64 KB and below 128 KB, i.e. 3 byte flash address for loading jump table entry and 2 byte jump table entry, with relaxation disabled, after removing the special section placement hook. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort + for, e.g. ATmega64. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" Index: gcc.target/avr/pr71151-4.c =================================================================== --- gcc.target/avr/pr71151-4.c (revision 237587) +++ gcc.target/avr/pr71151-4.c (working copy) @@ -1,10 +1,17 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x10000" } */ +#ifdef __AVR_HAVE_ELPM__ /* Make sure jumptables work properly if placed above 64 KB and below 128 KB, i.e. 3 byte flash address for loading jump table entry and 2 byte jump table entry, with relaxation enabled, after removing the special section placement hook. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort + for, e.g. ATmega64. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" Index: gcc.target/avr/pr71151-5.c =================================================================== --- gcc.target/avr/pr71151-5.c (revision 237587) +++ gcc.target/avr/pr71151-5.c (working copy) @@ -1,20 +1,23 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x20000" } */ +#ifdef __AVR_3_BYTE_PC__ /* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte flash address for loading jump table entry and a jump table entry that is a stub, with relaxation disabled, after removing the special section placement hook. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort + for, e.g. ATmega128. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" int main() { - /* Not meant for devices with flash <= 128K */ -#if defined (__AVR_2_BYTE_PC__) - exit(0); -#else foo(5); if (y != 37) abort(); @@ -26,5 +29,4 @@ int main() foo(7); if (y != 98) abort(); -#endif } Index: gcc.target/avr/pr71151-6.c =================================================================== --- gcc.target/avr/pr71151-6.c (revision 237587) +++ gcc.target/avr/pr71151-6.c (working copy) @@ -1,20 +1,23 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x20000" } */ +#ifdef __AVR_3_BYTE_PC__ /* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte flash address for loading jump table entry and a jump table entry that is a stub, with relaxation enabled, after removing the special section placement hook. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort + for, e.g. ATmega128. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" int main() { - /* Not meant for devices with flash <= 128K */ -#if defined (__AVR_2_BYTE_PC__) - exit(0); -#else foo(5); if (y != 37) abort(); @@ -26,5 +29,4 @@ int main() foo(7); if (y != 98) abort(); -#endif } Index: gcc.target/avr/pr71151-7.c =================================================================== --- gcc.target/avr/pr71151-7.c (revision 237587) +++ gcc.target/avr/pr71151-7.c (working copy) @@ -1,18 +1,21 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x1fffa" } */ +#ifdef __AVR_3_BYTE_PC__ /* Make sure jumptables work properly if placed straddling 128 KB i.e some entries below 128 KB and some above it, with relaxation disabled. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort + for, e.g. ATmega128. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" int main() { - /* Not meant for devices with flash <= 128K */ -#if defined (__AVR_2_BYTE_PC__) - exit(0); -#else foo(5); if (y != 37) abort(); @@ -24,5 +27,4 @@ int main() foo(7); if (y != 98) abort(); -#endif } Index: gcc.target/avr/pr71151-8.c =================================================================== --- gcc.target/avr/pr71151-8.c (revision 237587) +++ gcc.target/avr/pr71151-8.c (working copy) @@ -1,18 +1,20 @@ /* { dg-do run } */ /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x1fffa" } */ +#ifdef __AVR_3_BYTE_PC__ /* Make sure jumptables work properly if placed straddling 128 KB i.e some entries below 128 KB and some above it, with relaxation disabled. */ +#define SECTION_NAME ".foo" +#else +/* No special jump table placement so that avrtest won't abort. */ +#define SECTION_NAME ".text.foo" +#endif #include "exit-abort.h" #include "pr71151-common.h" int main() { - /* Not meant for devices with flash <= 128K */ -#if defined (__AVR_2_BYTE_PC__) - exit(0); -#else foo(5); if (y != 37) abort(); @@ -24,5 +26,4 @@ int main() foo(7); if (y != 98) abort(); -#endif } Index: gcc.target/avr/pr71151-common.h =================================================================== --- gcc.target/avr/pr71151-common.h (revision 237587) +++ gcc.target/avr/pr71151-common.h (working copy) @@ -1,7 +1,7 @@ volatile char y; volatile char g; -__attribute__((section(".foo"))) +__attribute__((section(SECTION_NAME))) void foo(char x) { switch (x)