c/2396: ARM/thumb 5th function argument access problem
ted@arraycomm.com
ted@arraycomm.com
Mon Mar 26 16:26:00 GMT 2001
>Number: 2396
>Category: c
>Synopsis: ARM/thumb 5th function argument access problem
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 26 16:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Ted Merrill, ArrayComm, Inc.
>Release: 2.95.2
>Organization:
>Environment:
solaris 2 host, ARM/thumb (thumb-coff) target
>Description:
gcc 2.95.2 for ARM/thumb (thumb-coff) target, solaris host.
When using default optimization (-O), leaf functions
with moderate complexity and more than four word-size
arguments are coded such that the fifth and successive
arguments are accessed at the wrong place in the stack
(specifically, 4 bytes too high).
The problem goes away if optimization is turned off
entirely or if -fno-omit-frame-pointer is used.
This problem also appears in 2.7-armT-980223 which we
obtained a few years ago (but we didn't used to use
so many arguments to functions).
>How-To-Repeat:
Compile with -O and -S .... and note how the argument
"a4" is accessed.
int f;
int bar( int a0, int a1, int a2, int a3, int a4 ) {
// Bug: the following gets accessed at [sp,#4] instead of [sp,#0]
return ( f ? a4 : 0 );
}
// For reference, here is something that calls bar
int foo(void) {
return bar(0,1,2,3,4);
}
The generated code accesses "a4" as
ldr r1, [sp, #4]
however, it was passed as [sp] and the stack pointer
is not modified in this optimized leaf function.
>Fix:
(unknown)
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test15.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test15.c"
aW50IGY7CmludCBiYXIoIGludCBhMCwgaW50IGExLCBpbnQgYTIsIGludCBhMywgaW50IGE0ICkg
ewogICAgLy8gQnVnOiB0aGUgZm9sbG93aW5nIGdldHMgYWNjZXNzZWQgYXQgW3NwLCM0XSBpbnN0
ZWFkIG9mIFtzcCwjMF0KICAgIHJldHVybiAoIGYgPyBhNCA6IDAgKTsKfQovLyBGb3IgcmVmZXJl
bmNlLCBoZXJlIGlzIHNvbWV0aGluZyB0aGF0IGNhbGxzIGJhcgppbnQgZm9vKHZvaWQpIHsKICAg
IHJldHVybiBiYXIoMCwxLDIsMyw0KTsKfQo=
More information about the Gcc-bugs
mailing list