public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sje at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute
Date: Wed, 04 Mar 2015 18:38:00 -0000	[thread overview]
Message-ID: <bug-65315-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65315

            Bug ID: 65315
           Summary: incorrect alignment of local variable with aligned
                    attribute
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sje at gcc dot gnu.org

Created attachment 34953
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34953&action=edit
Test case

When GCC has multiple local variables with different aligned attributes on
them, it creates an aligned block of space aligned to the least aligned
variable instead of the most aligned variable.

In the attached program, when run on MIPS, GCC is creating a 32 byte aligned
block of memory for foo1, foo3, and foo4 and a 128 byte aligned memory block
for foo2.  foo3 and foo4 should have 128 byte aligned memory.

I thought the problem was in stack_var_cmp where it checks the alignment of
two variables and returns '(int) largeb - (int) largea' to sort the variables
based on their alignment but when I swapped the two arguments I got an ICE
in expand_stack_vars [gcc_assert (large_base != NULL);].

It also tried changing:

large_align = stack_vars[stack_vars_sorted[0]].alignb * BITS_PER_UNIT;

to

large_align = stack_vars[stack_vars_sorted[n-1]].alignb * BITS_PER_UNIT;

but that caused the same ICE.

It may be that we need a loop to check the alignment of each variable.


             reply	other threads:[~2015-03-04 18:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 18:38 sje at gcc dot gnu.org [this message]
2015-03-04 18:58 ` [Bug middle-end/65315] " sje at gcc dot gnu.org
2015-03-05 16:34 ` sje at gcc dot gnu.org
2015-10-21 23:43 ` sje at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65315-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).