From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7052 invoked by alias); 18 Oct 2019 09:00:47 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 6960 invoked by uid 89); 18 Oct 2019 09:00:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy= X-HELO: mail.inka.de Received: from quechua.inka.de (HELO mail.inka.de) (193.197.184.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 09:00:14 +0000 Received: from raven.inka.de (uucp@[127.0.0.1]) by mail.inka.de with uucp (rmailwrap 0.5) id 1iLO7F-0006SZ-89; Fri, 18 Oct 2019 11:00:09 +0200 Received: by raven.inka.de (Postfix, from userid 1000) id C7537120272; Fri, 18 Oct 2019 10:53:14 +0200 (CEST) Date: Fri, 18 Oct 2019 09:00:00 -0000 From: Josef Wolf To: gcc-help@gcc.gnu.org Subject: Re: Crash when cross compiling for ARM with GCC-8-2-0 and -ftree-loop-distribute-patterns Message-ID: <20191018085314.GE11171@raven.inka.de> Mail-Followup-To: Josef Wolf , gcc-help@gcc.gnu.org References: <20191016131759.GA11171@raven.inka.de> <5b75d9aa-9f33-2ec6-ff46-713b113b3539@gmail.com> <20191017113157.GC11171@raven.inka.de> <20191017140423.GD11171@raven.inka.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00072.txt.bz2 Thanks for your help, Richard! On Thu, Oct 17, 2019 at 03:55:31PM +0100, Richard Earnshaw (lists) wrote: > On 17/10/2019 15:04, Josef Wolf wrote: > >On Thu, Oct 17, 2019 at 02:37:11PM +0200, Matthias Pfaller wrote: > >>Why is the stack pointer so low at this point of execution? Using > >>0x20018000-0x20017d20 == 0x2e0 bytes of stack seems a little excessive > >>for just one call. > > > >Ah!... Looks like you've spotted the problem! Actually, the SP is decremented > >on every cycle of the loop: > > > > (gdb) disass > > Dump of assembler code for function memset: > > 0x08001008 <+0>: push {r4, lr} > > 0x0800100a <+2>: mov r4, r0 > > 0x0800100c <+4>: cbz r2, 0x8001014 > > => 0x0800100e <+6>: uxtb r1, r1 > > 0x08001010 <+8>: bl 0x8001008 > > 0x08001014 <+12>: mov r0, r4 > > 0x08001016 <+14>: pop {r4, pc} > > End of assembler dump. > > > >This looks REALLY suspicous to me. Every cycle of the loop in memset() is > >pushing something onto the stack?!? > > > >Without the -ftree-loop-distribute-patterns option, the memset() function > >looks entirely different: > > > > cbz r2, > > add r2, r0 > > subs r2, #1 > > uxtb r1, r1 > > subs r3, r0, #1 > > <+10>: strb.w r1, [r3, #1]! > > cmp r3, r2 > > bne.n > > <+18>: bx lr > > The compiler has spotted that you've written something that acts like memset > and optimized it into a function call to memset. So now you're recursing to > oblivion. Try adding -fno-builtin-memset to your compile options. This sounds reasonable, and I was actually thinking it would solve the problem. Unfortunately, -fno-built-memset doesn't have any effect. The same code is generated. -- Josef Wolf jw@raven.inka.de