From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30955 invoked by alias); 22 Mar 2002 15:56:06 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 30894 invoked by uid 71); 22 Mar 2002 15:56:02 -0000 Resent-Date: 22 Mar 2002 15:56:02 -0000 Resent-Message-ID: <20020322155602.30893.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, tori@unhappy.mine.nu Received:(qmail 26586 invoked by uid 61); 22 Mar 2002 15:49:41 -0000 Message-Id:<20020322154941.26583.qmail@sources.redhat.com> Date: Fri, 22 Mar 2002 07:56:00 -0000 From: tori@unhappy.mine.nu Reply-To: tori@unhappy.mine.nu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: target/6039: ARM interrupt attribute generats wrong code X-SW-Source: 2002-03/txt/msg00843.txt.bz2 List-Id: >Number: 6039 >Category: target >Synopsis: ARM interrupt attribute generats wrong code >Confidential: no >Severity: critical >Priority: high >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Mar 22 07:56:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tobias Ringstrom >Release: gcc-3.0.4 >Organization: >Environment: Crosscompiler for arm-elf (cygwin and Linux host) >Description: Compile the following code with arm-elf-gcc -S tmp.c: void foo(void) __attribute__((__interrupt__)); void bar(void); void foo() { int a=0, b=0, c=a+b; bar(); } gives you the following: @ Generated by gcc 3.0.4 for ARM/elf .file "tmp.c" .text .align 2 .global foo .type foo,function foo: @ Interrupt Service Routine. @ args = 0, pretend = 0, frame = 12 @ frame_needed = 1, current_function_anonymous_args = 0 mov ip, sp stmfd sp!, {r2, r3, fp, ip, lr, pc} sub fp, ip, #4 sub sp, sp, #12 mov r3, #0 str r3, [fp, #-16] str r3, [fp, #-20] ldr r2, [fp, #-16] ldr r3, [fp, #-20] add r3, r2, r3 str r3, [fp, #-24] bl bar ldmea fp, {r2, r3, fp, sp, lr} subs pc, lr, #4 .Lfe1: .size foo,.Lfe1-foo Major problem 1: The ip register is overwritten and not restored. Major problem 2: The local variables overlap the pushed registers. In this case variable a occupies the same space as the stored lr. Major problem 3: A function is called which has every right to alter r0 and r1, and still those registers are not saved/restored in the prologue/epilogue. Question: Why is the register pc stored? If this bug is not fixed for the next gcc-3.0.x, I strongly recommend that you disable the interrupt attribute since it is unusable in its current form. I have tried the later pre-3.1 CVS version as well, and the above bugs seem to be fixed there, but unfortunately there is another (actually much worse) showstopper there. I will generate ASM stubs for my ISRs for now, but it would be very nice to use the interrupt attribute in the future. /Tobias >How-To-Repeat: Compile the program in the Description above. Note that no optimization is neccessary. It may even hide the real problems. >Fix: >Release-Note: >Audit-Trail: >Unformatted: