[Bug c++/69008] New: gcc emits unneeded memory access when passing trivial structs by value (ARM)
gcc at bobbyperu dot info
gcc-bugzilla@gcc.gnu.org
Mon Dec 21 23:08:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69008
Bug ID: 69008
Summary: gcc emits unneeded memory access when passing trivial
structs by value (ARM)
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc at bobbyperu dot info
Target Milestone: ---
gcc is emitting unneeded memory accesses in this code snippet.
Trivial structs up to 16 bytes are passed in r0-r3, no need for stack.
struct Trivial {
int i1;
int i2;
};
int foo(Trivial t)
{
return t.i1 + t.i2;
}
gcc on armv7:
$ g++ arm.cpp -O2 -mabi=aapcs -c -S && cat arm.s
sub sp, sp, #8
add r3, sp, #8
stmdb r3, {r0, r1}
ldmia sp, {r0, r3}
add r0, r0, r3
add sp, sp, #8
bx lr
clang:
$ clang++ arm.cpp -O2 -mabi=aapcs -c -S && cat arm.s
add r0, r0, r1
bx lr
More information about the Gcc-bugs
mailing list