public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: tori@unhappy.mine.nu To: gcc-gnats@gcc.gnu.org Subject: target/6039: ARM interrupt attribute generats wrong code Date: Fri, 22 Mar 2002 07:56:00 -0000 [thread overview] Message-ID: <20020322154941.26583.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-03-22 15:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-03-22 7:56 tori [this message] 2002-04-18 9:03 mmitchel 2003-05-17 2:56 target/6039: [ARM] " Dara Hazeghi 2003-05-17 6:58 giovannibajo
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020322154941.26583.qmail@sources.redhat.com \ --to=tori@unhappy.mine.nu \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).