From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5299 invoked by alias); 20 Dec 2012 17:08:06 -0000 Received: (qmail 5186 invoked by uid 48); 20 Dec 2012 17:07:48 -0000 From: "freddie_chopin at op dot pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55757] Suboptimal interrupt prologue/epilogue for ARMv7-M (Cortex-M3) Date: Thu, 20 Dec 2012 17:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: freddie_chopin at op dot pl X-Bugzilla-Status: NEW X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg02019.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55757 --- Comment #3 from Freddie Chopin 2012-12-20 17:07:47 UTC --- Indeed that's a trivial case, but other - useful - cases also show strange behavior which I cannot clearly explain, so while we're at it I'd be grateful for some explanation... An interrupt handler function (void something(void)), but without attribute, doing something inside (posts a FreeRTOS semaphore, calls vPortYieldFromISR() if it's needed) actually saves a lot of registers on entry: 23b4: b507 push {r0, r1, r2, lr} >>From what I know r0-r3 as scratch registers don't need to be saved on entry, as it's the callers duty. There are also no parameters to be saved, as it's a void function... I observed the same behavior with some non-trivial functions from the lwIP TCP/IP stack - they are also save scratch registers on entry, even when they are void ...(void): 00005d00 : void dns_init() { 5d00: b537 push {r0, r1, r2, r4, r5, lr} Is that a bug or maybe I don't understand the calling conventions? <; BTW: > The reason two registers are pushed, rather than one is that this is also needed to > keep the stack aligned and pushing two registers uses less code than adjusting the stack in a separate insn. But for optimization level 1, 2 and 3 only one reg is pushed... Thx in advance!