From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5012 invoked by alias); 20 Dec 2012 15:04:01 -0000 Received: (qmail 4916 invoked by uid 48); 20 Dec 2012 15:03:26 -0000 From: "freddie_chopin at op dot pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55757] New: Suboptimal interrupt prologue/epilogue for ARMv7-M (Cortex-M3) Date: Thu, 20 Dec 2012 15:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: freddie_chopin at op dot pl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: 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/msg01984.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55757 Bug #: 55757 Summary: Suboptimal interrupt prologue/epilogue for ARMv7-M (Cortex-M3) Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: freddie_chopin@op.pl With a Cortex-M3 microcontroller (ARMv7-M) and an empty interrupt handler function: void DMA_IRQHandler(void) __attribute((interrupt)); void DMA_IRQHandler(void) { } Results in suboptimal prologue/epilogue: 000023b4 : void DMA_IRQHandler(void) __attribute((interrupt)); void DMA_IRQHandler(void) { 23b4: 4668 mov r0, sp 23b6: f020 0107 bic.w r1, r0, #7 23ba: 468d mov sp, r1 23bc: b501 push {r0, lr} } 23be: e8bd 4001 ldmia.w sp!, {r0, lr} 23c2: 4685 mov sp, r0 23c4: 4770 bx lr ... Without the __attribute__ the function is fine, just a single "bx lr". This behavior is incorrect not only because r0 and lr are unused, but also because on ARMv7-M these registers (r0-r3, lr, ip, sp, pc, psr) are saved by hardware, so there's no point in saving them again.