Bug 25428 - arm-elf-gcc generating wrong code with -O flag at functions with __attribute__ ((interrupt ("IRQ")))
Summary: arm-elf-gcc generating wrong code with -O flag at functions with __attribute_...
Status: RESOLVED DUPLICATE of bug 16634
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-15 14:57 UTC by th.r.klein
Modified: 2006-08-08 23:05 UTC (History)
3 users (show)

See Also:
Host: i386-freebds-elf
Target: arm-unknown-elf
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
except.i (200 bytes, text/plain)
2005-12-15 14:59 UTC, th.r.klein
Details
working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c (442 bytes, text/plain)
2005-12-15 15:03 UTC, th.r.klein
Details
not working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c (419 bytes, text/plain)
2005-12-15 15:04 UTC, th.r.klein
Details
still working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c (442 bytes, text/plain)
2005-12-15 15:07 UTC, th.r.klein
Details
now working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c (421 bytes, text/plain)
2005-12-15 15:08 UTC, th.r.klein
Details
possible patch (used diff -Bbwu) (1006 bytes, patch)
2005-12-15 15:10 UTC, th.r.klein
Details | Diff
working: arm-elf-gcc -save-temps -mthumb-interwork -mapcs-frame -O -march=armv4t -Wall -c except.c (455 bytes, text/plain)
2005-12-16 11:34 UTC, th.r.klein
Details
working: arm-elf-gcc -save-temps -mthumb-interwork -mno-apcs-frame -O -march=armv4t -Wall -c except.c (421 bytes, text/plain)
2005-12-16 11:35 UTC, th.r.klein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description th.r.klein 2005-12-15 14:57:18 UTC
If a little bit more complex interrupt function is required the compiler genrates wrong code (olny with -O flag set).

Compiler generats:
	sub	lr, lr, #4
	stmfd	sp!, {r.., lr}
	.
	.
	.
	ldmfd	sp!, {r.., lr}
	subs	pc, lr, #4

Here the LR is decremented one time too mutch.
Ether first or the second "sub" is wrong.
It should be:
	sub	lr, lr, #4
	stmfd	sp!, {r.., lr}
	.
	.
	.
	ldmfd	sp!, {r.., lr}^

(the last '^' is important)

P.S. Since I can't add any attachments now. I'll try this after 'commit'.
Comment 1 th.r.klein 2005-12-15 14:59:59 UTC
Created attachment 10497 [details]
except.i
Comment 2 th.r.klein 2005-12-15 15:03:24 UTC
Created attachment 10498 [details]
working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c
Comment 3 th.r.klein 2005-12-15 15:04:48 UTC
Created attachment 10499 [details]
not working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c
Comment 4 th.r.klein 2005-12-15 15:07:04 UTC
Created attachment 10500 [details]
still working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c
Comment 5 th.r.klein 2005-12-15 15:08:27 UTC
Created attachment 10501 [details]
now working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c
Comment 6 th.r.klein 2005-12-15 15:10:15 UTC
Created attachment 10502 [details]
possible patch (used diff -Bbwu)
Comment 7 th.r.klein 2005-12-16 11:31:31 UTC
To me it looks like, that this patch also fixes Bug #16634
But I might be wrong, here.
Comment 8 th.r.klein 2005-12-16 11:34:36 UTC
Created attachment 10513 [details]
working: arm-elf-gcc -save-temps -mthumb-interwork -mapcs-frame -O -march=armv4t -Wall -c except.c
Comment 9 th.r.klein 2005-12-16 11:35:36 UTC
Created attachment 10514 [details]
working: arm-elf-gcc -save-temps -mthumb-interwork -mno-apcs-frame -O -march=armv4t -Wall -c except.c
Comment 10 th.r.klein 2006-03-05 13:38:03 UTC
Ping to remember

Fails on Version 3.2.3; 3.4.5; 4.0.2; 4.1.0; 4.2.0 (snapshot).
Earlier versions with additonal other buggs. So useless to test.

Bugfix still exists and working but ignorded at GCC side;

Why ?????????????
Comment 11 Paul Brook 2006-08-08 23:05:11 UTC
Assembly in initial comment is bogus. Should be ldmfd {..., pc}^. ldmrd {... lr}^ does somethething completely different.

*** This bug has been marked as a duplicate of 16634 ***