public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "heavy at smtp dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/42155] New: Optimizer generates bad code for ARM7 THUMB mode (local variable lost) Date: Mon, 23 Nov 2009 15:18:00 -0000 [thread overview] Message-ID: <bug-42155-18479@http.gcc.gnu.org/bugzilla/> (raw) Hello. I've found bug in GCC 4.4.1 for ARM7TDMI in THUMB mode. Test code: void foo(char *bar); char test() { char tmp; foo(&tmp); return tmp; } Compiled with: arm-elf-gcc -S -mcpu=arm7tdmi -O2 -mthumb test.c Then using -O2 or -O3 optimization, assembler code looks like: 1:test: 2: push {r4, lr} 3: sub sp, sp, #4 4: mov r4, sp 5: add r4, r4, #3 6: mov r0, r4 7: bl foo 8: add sp, sp, #4 9: ldrb r0, [r4] 10: @ sp needed for prologue 11: pop {r4, pc} So, if interrupt or task switching occurs between line 8 and line 9, local variable in stack (referenced by r4) will be garbaged by service routine, because stack rewinds before usage of local variable. This code works fine with -O1: 1:test: 2: push {r4, lr} 3: sub sp, sp, #4 4: mov r4, sp 5: add r4, r4, #3 6: mov r0, r4 7: bl foo 8: ldrb r0, [r4] 9: add sp, sp, #4 10: @ sp needed for prologue 11: pop {r4, pc} -- Summary: Optimizer generates bad code for ARM7 THUMB mode (local variable lost) Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: heavy at smtp dot ru GCC build triplet: arm-elf GCC host triplet: i486-linux-gnu GCC target triplet: arm-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42155
next reply other threads:[~2009-11-23 15:18 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-11-23 15:18 heavy at smtp dot ru [this message] 2009-11-23 16:42 ` [Bug rtl-optimization/42155] " pinskia at gcc dot gnu dot org
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=bug-42155-18479@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).