public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-01 23:04 ` pinskia at gcc dot gnu.org
  2013-02-15  0:52 ` brooks at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-01 23:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2010-10/msg00060.htm
                   |                            |l

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-01 23:03:15 UTC ---
Fixed fully with http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00060.html .


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
  2010-10-01 23:04 ` [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement pinskia at gcc dot gnu.org
@ 2013-02-15  0:52 ` brooks at gcc dot gnu.org
  2013-02-15  1:07 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: brooks at gcc dot gnu.org @ 2013-02-15  0:52 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Brooks Moses <brooks at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brooks at gcc dot gnu.org

--- Comment #20 from Brooks Moses <brooks at gcc dot gnu.org> 2013-02-15 00:51:30 UTC ---
Andrew, if this was "fixed fully" with that patch, why is it still open?


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
  2010-10-01 23:04 ` [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement pinskia at gcc dot gnu.org
  2013-02-15  0:52 ` brooks at gcc dot gnu.org
@ 2013-02-15  1:07 ` pinskia at gcc dot gnu.org
  2013-02-15  1:12 ` brooks at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-15  1:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0

--- Comment #21 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-15 01:06:40 UTC ---
(In reply to comment #20)
> Andrew, if this was "fixed fully" with that patch, why is it still open?

Because I pointed to that patch before it was applied.  It was applied 8 days
after I pointed to it and nobody has got around to closing the bug as being
fixed.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-02-15  1:07 ` pinskia at gcc dot gnu.org
@ 2013-02-15  1:12 ` brooks at gcc dot gnu.org
  2014-02-05  8:40 ` kugel at rockbox dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: brooks at gcc dot gnu.org @ 2013-02-15  1:12 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Brooks Moses <brooks at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|FIXED                       |
   Target Milestone|4.6.0                       |---

--- Comment #22 from Brooks Moses <brooks at gcc dot gnu.org> 2013-02-15 01:11:29 UTC ---
(In reply to comment #21)

Makes sense.  Thanks for having a look!  :)


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-02-15  1:12 ` brooks at gcc dot gnu.org
@ 2014-02-05  8:40 ` kugel at rockbox dot org
  2014-02-05  8:54 ` kugel at rockbox dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: kugel at rockbox dot org @ 2014-02-05  8:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Thomas Martitz <kugel at rockbox dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kugel at rockbox dot org

--- Comment #23 from Thomas Martitz <kugel at rockbox dot org> ---
Which release is the first to ship and was it backported? I experience this bug
in an old 4.4.6 armeabi gcc.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2014-02-05  8:40 ` kugel at rockbox dot org
@ 2014-02-05  8:54 ` kugel at rockbox dot org
  2014-02-16 10:03 ` jackie.rosen at hushmail dot com
  2021-12-23  5:57 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 23+ messages in thread
From: kugel at rockbox dot org @ 2014-02-05  8:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

--- Comment #24 from Thomas Martitz <kugel at rockbox dot org> ---
Alright, looking at the revision history it appears to me that the GCC 4.6
series ship the fix and it was not backported to 4.4 (although 4.4.7 was
released months after this patch hit svn trunk) or 4.5.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2014-02-05  8:54 ` kugel at rockbox dot org
@ 2014-02-16 10:03 ` jackie.rosen at hushmail dot com
  2021-12-23  5:57 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 23+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 10:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #25 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Marked for reference. Resolved as fixed @bugzilla.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2014-02-16 10:03 ` jackie.rosen at hushmail dot com
@ 2021-12-23  5:57 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-23  5:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |4.6.0
         Resolution|---                         |FIXED

--- Comment #26 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed as mentioned.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2009-04-16  9:22 ` nospamname at web dot de
@ 2009-08-20  8:49 ` lessen42+gcc at gmail dot com
  14 siblings, 0 replies; 23+ messages in thread
From: lessen42+gcc at gmail dot com @ 2009-08-20  8:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from lessen42+gcc at gmail dot com  2009-08-20 08:49 -------
This still doesn't work on ARM either (tested with 4.4.0). The EABI only
mandates the stack be 8 byte aligned, and gcc silently clips any alignment
request above 8 bytes to 8 (so even if the stack were 16-byte aligned by
accident the variables still wouldn't be.)

Even a simple sp -= sp & (align-1) for every function with variables needing
more alignment would be faster than unaligned NEON loads/stores.


-- 

lessen42+gcc at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lessen42+gcc at gmail dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2009-03-05 14:03 ` hjl dot tools at gmail dot com
@ 2009-04-16  9:22 ` nospamname at web dot de
  2009-08-20  8:49 ` lessen42+gcc at gmail dot com
  14 siblings, 0 replies; 23+ messages in thread
From: nospamname at web dot de @ 2009-04-16  9:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from nospamname at web dot de  2009-04-16 09:22 -------
I get same align problem on 68k amigaos Target.the rport and fix is old.

its a middle end bug and i see the fix is not in the source i download (4.3.3)
i can test this patch if you like, or have you something more new ?  

Here is mail i get last in gcc ML

http://gcc.gnu.org/ml/gcc/2009-04/msg00395.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2008-07-31  1:07 ` pinskia at gcc dot gnu dot org
@ 2009-03-05 14:03 ` hjl dot tools at gmail dot com
  2009-04-16  9:22 ` nospamname at web dot de
  2009-08-20  8:49 ` lessen42+gcc at gmail dot com
  14 siblings, 0 replies; 23+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-05 14:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from hjl dot tools at gmail dot com  2009-03-05 14:02 -------
*** Bug 39373 has been marked as a duplicate of this bug. ***


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |balrogg at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2008-07-31  1:05 ` hjl dot tools at gmail dot com
@ 2008-07-31  1:07 ` pinskia at gcc dot gnu dot org
  2009-03-05 14:03 ` hjl dot tools at gmail dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-31  1:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from pinskia at gcc dot gnu dot org  2008-07-31 01:05 -------
Subject: Re:  attribute((aligned)) doesn't work for variables on the stack for
greater than required alignement

> This should work with gcc 4.4 revision 138335.

Only on x86 and not on any other target ...

-- Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2008-01-03 18:01 ` pinskia at gcc dot gnu dot org
@ 2008-07-31  1:05 ` hjl dot tools at gmail dot com
  2008-07-31  1:07 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-07-31  1:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from hjl dot tools at gmail dot com  2008-07-31 01:04 -------
(In reply to comment #0)
> Running the program below compiled with "-mpreferred-stack-boundary=2"
> gets a "segmentation fault" because the variable "tmp"
> is not properly aligned on a 16-byte boundary (required for
> movaps), violating the aligned(16) request in the attribute.
> 
> void f()
> {
>   unsigned long tmp[4] __attribute__((aligned(16)));
>   asm("movaps %%xmm0, (%0)" : : "r" (tmp) : "memory");
> }
> 
> int main()
> {
>   f();
> }

This should work with gcc 4.4 revision 138335.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2007-10-04  0:02 ` hjl at lucon dot org
@ 2008-01-03 18:01 ` pinskia at gcc dot gnu dot org
  2008-07-31  1:05 ` hjl dot tools at gmail dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-03 18:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from pinskia at gcc dot gnu dot org  2008-01-03 17:47 -------
I am getting tried of pinging this patch, I guess if nobody wants to comment
that is up to them.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|pinskia at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2007-10-03 22:41 ` pinskia at gcc dot gnu dot org
@ 2007-10-04  0:02 ` hjl at lucon dot org
  2008-01-03 18:01 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: hjl at lucon dot org @ 2007-10-04  0:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from hjl at lucon dot org  2007-10-04 00:01 -------
(In reply to comment #11)

> This only helps x86 really.  If you look at my patch, it already implements
> (correctly) handling large cases like 128byte alignment (which people use with
> the Cell).  What you are proposing will cause more stack to be used than
> actually required and more complex for the normal case.  If you look at my
> patch, you will see it handles 1-4 issues nicely without any problems (because
> the stack itself is not realigned).  Oh on PPC, the stack pointer has to be
> correct so you cannot use frame pointer to be the old stack pointer.

Does your patch handle register spill which needs a larger alignment? What
is the impact of your approach on performance when stack alignment is needed
for local variable as well as register spill?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2007-10-03 22:27 ` hjl at lucon dot org
@ 2007-10-03 22:41 ` pinskia at gcc dot gnu dot org
  2007-10-04  0:02 ` hjl at lucon dot org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-10-03 22:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pinskia at gcc dot gnu dot org  2007-10-03 22:40 -------
(In reply to comment #7)
> It saves stack pointer in frame pointer. Can we implement it for suitable
> cases/backends and properly handle

This only helps x86 really.  If you look at my patch, it already implements
(correctly) handling large cases like 128byte alignment (which people use with
the Cell).  What you are proposing will cause more stack to be used than
actually required and more complex for the normal case.  If you look at my
patch, you will see it handles 1-4 issues nicely without any problems (because
the stack itself is not realigned).  Oh on PPC, the stack pointer has to be
correct so you cannot use frame pointer to be the old stack pointer.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2007-10-03 22:17 ` hjl at lucon dot org
@ 2007-10-03 22:27 ` hjl at lucon dot org
  2007-10-03 22:41 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: hjl at lucon dot org @ 2007-10-03 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from hjl at lucon dot org  2007-10-03 22:27 -------
For backend with frame pointer and working -fomit-frame-pointer -g, can
we

1. Make -fomit-frame-pointer per function, instead of per file.
2. Enable -fomit-frame-pointer for functions which need stack alignment.
3. Mark frame-pointer as reserved and use frame pointer to save stack
pointer.

and make sure that

1. tail call optimization.
2. stack unwind.
3. nested functions.
4. inline functions

work properly?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2007-10-03 22:08 ` pinskia at gcc dot gnu dot org
@ 2007-10-03 22:17 ` hjl at lucon dot org
  2007-10-03 22:27 ` hjl at lucon dot org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: hjl at lucon dot org @ 2007-10-03 22:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from hjl at lucon dot org  2007-10-03 22:17 -------
(In reply to comment #8)
> Subject: Re:  attribute((aligned)) doesn't work for variables on the stack for
> greater than required alignement
> 
> On 3 Oct 2007 22:04:28 -0000, hjl at lucon dot org
> <gcc-bugzilla@gcc.gnu.org> wrote:
> >
> >
> > ------- Comment #7 from hjl at lucon dot org  2007-10-03 22:04 -------
> > What is the performance impact of
> >
> > http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01167.html
> 
> The performance impact is non if the variables don't need aligned.
> Otherwise you get a small penality at the very begining for the
> alignment of the variable itself.  Really this is only to be used with
> big alignments like 128byte alignment (for using with a DMA system
> like in the Cell).
> 

What is the performance if the stack alignment adjustment is required in
all functions with floating point variables on stack?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2007-10-03 22:04 ` hjl at lucon dot org
@ 2007-10-03 22:08 ` pinskia at gcc dot gnu dot org
  2007-10-03 22:17 ` hjl at lucon dot org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-10-03 22:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-10-03 22:07 -------
Subject: Re:  attribute((aligned)) doesn't work for variables on the stack for
greater than required alignement

On 3 Oct 2007 22:04:28 -0000, hjl at lucon dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #7 from hjl at lucon dot org  2007-10-03 22:04 -------
> What is the performance impact of
>
> http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01167.html

The performance impact is non if the variables don't need aligned.
Otherwise you get a small penality at the very begining for the
alignment of the variable itself.  Really this is only to be used with
big alignments like 128byte alignment (for using with a DMA system
like in the Cell).

-- Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-01-13  1:58 ` pinskia at gcc dot gnu dot org
@ 2007-10-03 22:04 ` hjl at lucon dot org
  2007-10-03 22:08 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: hjl at lucon dot org @ 2007-10-03 22:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl at lucon dot org  2007-10-03 22:04 -------
What is the performance impact of

http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01167.html

Intel compiler has a very efficient way to align the stack:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28074

It saves stack pointer in frame pointer. Can we implement it for suitable
cases/backends and properly handle

1. tail call optimization.
2. stack unwind.
3. nested functions.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
  2006-03-18 23:43 ` sabre at nondot dot org
  2006-09-06  7:14 ` thomas at reactsoft dot com
@ 2007-01-13  1:58 ` pinskia at gcc dot gnu dot org
  2007-10-03 22:04 ` hjl at lucon dot org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-13  1:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-01-13 01:58 -------
I am implementing something for this.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
  2006-03-18 23:43 ` sabre at nondot dot org
@ 2006-09-06  7:14 ` thomas at reactsoft dot com
  2007-01-13  1:58 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: thomas at reactsoft dot com @ 2006-09-06  7:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from thomas at reactsoft dot com  2006-09-06 07:14 -------
(In reply to comment #3)
> Actually this is just a missed diagnostic.  The compiler cannot align the stack
> variables where the alignment is greater than stack alignment that the compiler
> can give for the stack.

The least GCC could and should do then is warn about it...

If the code is not very complex, the alignment appears to work, though. But as
soon as the code becomes complex, GCC screwes the alignment and even
accesses variables that don't even exist (I'll go into detail later).

Basically code like this is affected (this is *NOT* a test case, I'm going to
post a test case as soon as I get it to work):

typedef struct _somestruct {
    int a;
};

static void checkstruct (volatile struct _somestruct *palignedvar)
{
    if ((size_t)palignedvar & 0xF)
        printf("structure misaligned!\n");
}

void somefunc(int a, int b, int c) {
    __attribute__((aligned (16))) volatile struct _somestruct alignedvar;

    while (1)
    {
        /* [other code] */
        if (a) {
            if (c) {
                /* [other code] */
                alignedvar.a = c;
                checkstruct(&alignedvar);
            } else {
                /* [other code] */
                break;
            }
        } else {
            if (b) {
                /* [other code] */
                alignedvar.a = a;
                checkstruct(&alignedvar);
            } else {
                if (c) {
                    break;
                } else {
                    /* [other code] */
                    alignedvar.a = a;
                    checkstruct(&alignedvar);
                }
            }
        }
        /* [other code] */
    }
}

I analyzed the generated assembly code. GCC reserves an area big enough to hold
the structure plus padding, so it can align the structure dynamically at
runtime. It stores a pointer to the reserved area and a pointer to the
structure within the area. As long as the code is simple, GCC uses the pointer
to the structure to access the data. However, if the code is complex enough,
GCC mistakenly uses the pointer to the reserved area - which of course is
sometimes not properly aligned. As a result, also the data of the structure
members are read/write incorrectly.

the stack is organized like this (the order may not match as showed in this
abstracted example):

struct {
    void *reserved_area;     /* this is the pointer GCC sometimes accidently
grabs */
    void *aligned_structure; /* this is the pointer GCC should always grab */

    char reserved[sizeof(structure) + sizeof(padding)];
};

I encountered this bug with -O3, I don't know if GCC also generates broken code
without optimizations. I tried to create a simple test case that triggers the
problem, but I failed. I'm going to do that in the next few days.


-- 

thomas at reactsoft dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas at reactsoft dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement
       [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
@ 2006-03-18 23:43 ` sabre at nondot dot org
  2006-09-06  7:14 ` thomas at reactsoft dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: sabre at nondot dot org @ 2006-03-18 23:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from sabre at nondot dot org  2006-03-18 23:43 -------
Huh?  Why can't it?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-12-23  5:57 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-16660-4@http.gcc.gnu.org/bugzilla/>
2010-10-01 23:04 ` [Bug middle-end/16660] attribute((aligned)) doesn't work for variables on the stack for greater than required alignement pinskia at gcc dot gnu.org
2013-02-15  0:52 ` brooks at gcc dot gnu.org
2013-02-15  1:07 ` pinskia at gcc dot gnu.org
2013-02-15  1:12 ` brooks at gcc dot gnu.org
2014-02-05  8:40 ` kugel at rockbox dot org
2014-02-05  8:54 ` kugel at rockbox dot org
2014-02-16 10:03 ` jackie.rosen at hushmail dot com
2021-12-23  5:57 ` pinskia at gcc dot gnu.org
     [not found] <bug-16660-1824@http.gcc.gnu.org/bugzilla/>
2006-03-18 23:43 ` sabre at nondot dot org
2006-09-06  7:14 ` thomas at reactsoft dot com
2007-01-13  1:58 ` pinskia at gcc dot gnu dot org
2007-10-03 22:04 ` hjl at lucon dot org
2007-10-03 22:08 ` pinskia at gcc dot gnu dot org
2007-10-03 22:17 ` hjl at lucon dot org
2007-10-03 22:27 ` hjl at lucon dot org
2007-10-03 22:41 ` pinskia at gcc dot gnu dot org
2007-10-04  0:02 ` hjl at lucon dot org
2008-01-03 18:01 ` pinskia at gcc dot gnu dot org
2008-07-31  1:05 ` hjl dot tools at gmail dot com
2008-07-31  1:07 ` pinskia at gcc dot gnu dot org
2009-03-05 14:03 ` hjl dot tools at gmail dot com
2009-04-16  9:22 ` nospamname at web dot de
2009-08-20  8:49 ` lessen42+gcc at gmail dot com

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).