Empty struct optimisations - how should they be done?
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
New
|
Undecided
|
Unassigned |
Bug Description
Empty structs as parameters are useful as "tag" types for function overloading in C++. But they are handled quite inefficiently from gcc for the ARM - they are passed as though they were 32-bit parameters that had to be set to 0. clang for ARM skips them - empty struct parameters don't take any registers or code, and thus give optimal code.
However, as far as I can see, the EABI for the ARM requires that these are passed as though they were 32-bit values (though there is no need for any particular value). This is, of course, massively inefficient compared to the way clang treats them. But the two compilers generate code that is incompatible.
So is clang wrong? Is gcc wrong? Can the EABI be changed to remove the unnecessary unvalued parameter passing? If both solutions are allowed, can the EABI be clarified to show this?
If gcc is following the EABI here, and is required to generate inefficient code, is it possible to add a compiler switch letting users choose to generate non-standard but higher quality code?
I have already filed this as a gcc issue, where there is some useful discussion and sample code, but I hope the ARM port developers here can clarify matters.