public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute @ 2015-03-04 18:38 sje at gcc dot gnu.org 2015-03-04 18:58 ` [Bug middle-end/65315] " sje at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: sje at gcc dot gnu.org @ 2015-03-04 18:38 UTC (permalink / raw) To: gcc-bugs 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/65315] incorrect alignment of local variable with aligned attribute 2015-03-04 18:38 [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute sje at gcc dot gnu.org @ 2015-03-04 18:58 ` 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 2 siblings, 0 replies; 4+ messages in thread From: sje at gcc dot gnu.org @ 2015-03-04 18:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65315 --- Comment #1 from Steve Ellcey <sje at gcc dot gnu.org> --- It might be easier to see this bug if you apply this patch: diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 7dfe1f6..7beb00e 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -973,6 +973,8 @@ expand_stack_vars (bool (*pred) (size_t), struct sta ck_vars_data *data) i = stack_vars_sorted[si]; alignb = stack_vars[i].alignb; + gcc_assert (alignb*BITS_PER_UNIT <= large_align); + /* Stop when we get to the first decl with "small" alignment. */ if (alignb * BITS_PER_UNIT <= MAX_SUPPORTED_STACK_ALIGNMENT) break; This way you get an ICE instead of just incorrectly aligned vectors. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/65315] incorrect alignment of local variable with aligned attribute 2015-03-04 18:38 [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute sje at gcc dot gnu.org 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 2 siblings, 0 replies; 4+ messages in thread From: sje at gcc dot gnu.org @ 2015-03-05 16:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65315 --- Comment #3 from Steve Ellcey <sje at gcc dot gnu.org> --- Author: sje Date: Thu Mar 5 16:34:03 2015 New Revision: 221219 URL: https://gcc.gnu.org/viewcvs?rev=221219&root=gcc&view=rev Log: 2015-03-05 Steve Ellcey <sellcey@imgtec.com> PR middle-end/65315 * cfgexpand.c (expand_stack_vars): Update large_align to maximum needed alignment. Modified: trunk/gcc/ChangeLog trunk/gcc/cfgexpand.c ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/65315] incorrect alignment of local variable with aligned attribute 2015-03-04 18:38 [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute sje at gcc dot gnu.org 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 2 siblings, 0 replies; 4+ messages in thread From: sje at gcc dot gnu.org @ 2015-10-21 23:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65315 Steve Ellcey <sje at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |5.0 --- Comment #4 from Steve Ellcey <sje at gcc dot gnu.org> --- A patch for this was checked in before 5.0 branched. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-21 23:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-03-04 18:38 [Bug middle-end/65315] New: incorrect alignment of local variable with aligned attribute sje at gcc dot gnu.org 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
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).