This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33519] New: Invalid code generated with a combination of thumb, AAPCS and -Os.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Sep 2007 16:29:04 -0000
- Subject: [Bug c/33519] New: Invalid code generated with a combination of thumb, AAPCS and -Os.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC generates odd code sequence..
Part of the source (full source in attachment):
usbd_status
usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
usb_device_request_t *req, void *data, u_int16_t flags, int *actlen,
u_int32_t timeout)
{
usbd_xfer_handle xfer;
usbd_status err;
xfer = usbd_alloc_xfer(dev);
...
objdump output:
00000000 <usbd_do_request_flags_pipe>:
0: b5f0 push {r4, r5, r6, r7, lr}
2: b089 sub sp, #36
4: 1c14 adds r4, r2, #0
6: 9a0f ldr r2, [sp, #60]
8: 1c1e adds r6, r3, #0
a: 605a str r2, [r3, #4] <-- writes using r3 (data)
c: 9b10 ldr r3, [sp, #64]
e: 9007 str r0, [sp, #28]
10: 609b str r3, [r3, #8]
12: ab0e add r3, sp, #56
14: 9106 str r1, [sp, #24]
16: 881f ldrh r7, [r3, #0]
18: f7ff fffe bl 0 <usbd_alloc_xfer>
And here's objdump output when compiled with the same options but gcc 4.2.1:
00000000 <usbd_do_request_flags_pipe>:
0: b5f0 push {r4, r5, r6, r7, lr}
2: b089 sub sp, #36
4: 1c1e adds r6, r3, #0
6: ab0e add r3, sp, #56
8: 9007 str r0, [sp, #28]
a: 9106 str r1, [sp, #24]
c: 1c14 adds r4, r2, #0
e: 881f ldrh r7, [r3, #0]
10: f7ff fffe bl 0 <usbd_alloc_xfer>
Environment:
System: Linux kivi 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686
GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: arm-unknown-elf
configured with: /s/devel/gcc-4.1.1/configure --target=arm-elf --with-gnu-as
--with-gcc --with-gnu-ld --enable-languages=c --disable-libstdc
--disable-hosted-libstdcxx --disable-libstdcxx --disable-libstdcxx-v3
--disable-libstdcxx_v3 --disable-nls --disable-shared --disable-threads
--disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch
--prefix=/emb/arm-elf-gcc-4.1.1 --program-prefix=arm-elf- --program-suffix=
--with-newlib -v --without-headers -v
How-To-Repeat:
Compile the test case like:
# arm-elf-gcc -Os -Wall -Werror -mcpu=arm920t -mlittle-endian -mthumb
-mabi=aapcs -c usbdi.c -o usbdi.o
------- Comment #1 from sami dot kantoluoto at embedtronics dot fi 2007-09-21 16:29 -------
Fix:
Work arounds: gcc 4.2.1, optimize for speed instead of size.
--
Summary: Invalid code generated with a combination of thumb,
AAPCS and -Os.
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sami dot kantoluoto at embedtronics dot fi
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33519