This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70755] [ARM] excessive struct alignment for globals
- From: "bruck.michael at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 23 Apr 2016 19:05:39 +0000
- Subject: [Bug c++/70755] [ARM] excessive struct alignment for globals
- Auto-submitted: auto-generated
- References: <bug-70755-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70755
--- Comment #2 from Michael Bruck <bruck.michael at googlemail dot com> ---
(In reply to Richard Earnshaw from comment #1)
> This is a deliberate design choice. By doing this we gain significant
> benefits from having aligned objects, which helps with data copying and
> other optimizations.
>
> Consider, for example, the object
>
> struct x
> {
> char a;
> char b;
> char c;
> char d;
> };
>
> struct x A, B;
>
> f()
> {
> B = A;
> }
>
> Since the objects are aligned then this function can be optimized to single
> 32-bit load and store operations that work very efficiently.
>
> As you've noticed, it is possible to force the alignment down to the
> architectural minimums by annotations, but for most users it makes little
> difference and the defaults are preferable.
"for most users"
Maybe I should have specified -mcortex-m0 on the command line to illustrate the
point. For most Cortex-M0 users with 16 kB this 300% memory waste is a bad
trade-off.
Can you implement a command line option to deactivate this behavior?
Your reply did not address b) and c), should I open a separate bug to discuss
these?