Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Bernd Schmidt
On 12/14/2015 03:20 PM, Richard Biener wrote: But there must be a reason statics/externals are expected and handled in all the callers (and the function). At the time this was written (git rev 60d031234), expand_one_var looked very different. It called a subroutine expand_one_static_var which

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Richard Biener
On Mon, Dec 14, 2015 at 1:09 PM, Bernd Schmidt wrote: > On 12/14/2015 10:07 AM, Richard Biener wrote: > >> Note that we also record alignment to make sure we can spill to properly >> aligned stack slots. > > >> I don't see why we don't need to do that for used statics/externs. That >> is >> are y

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Bernd Schmidt
On 12/14/2015 10:07 AM, Richard Biener wrote: Note that we also record alignment to make sure we can spill to properly aligned stack slots. I don't see why we don't need to do that for used statics/externs. That is are you sure we never need to spill a var of their type? Why would they be

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Jan Beulich
>>> On 14.12.15 at 10:07, wrote: > Note that we also record alignment to make sure we can spill to properly > aligned stack slots. > > I don't see why we don't need to do that for used statics/externs. That is > are you sure we never need to spill a var of their type? No, I'm not, but note that

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Richard Biener
On Mon, Dec 14, 2015 at 9:44 AM, Jan Beulich wrote: On 14.12.15 at 09:35, wrote: >> On Fri, Dec 11, 2015 at 2:54 PM, Bernd Schmidt wrote: >>> On 12/11/2015 02:48 PM, Jan Beulich wrote: Function (or more narrow) scope static variables (as well as others not placed on the stack

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Jan Beulich
>>> On 14.12.15 at 09:35, wrote: > On Fri, Dec 11, 2015 at 2:54 PM, Bernd Schmidt wrote: >> On 12/11/2015 02:48 PM, Jan Beulich wrote: >>> >>> Function (or more narrow) scope static variables (as well as others not >>> placed on the stack) should also not have any effect on the stack >>> alignmen

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-14 Thread Richard Biener
On Fri, Dec 11, 2015 at 2:54 PM, Bernd Schmidt wrote: > On 12/11/2015 02:48 PM, Jan Beulich wrote: >> >> Function (or more narrow) scope static variables (as well as others not >> placed on the stack) should also not have any effect on the stack >> alignment. I noticed the issue first with Linux'e

Re: [v4] avoid alignment of static variables affecting stack's

2015-12-11 Thread Bernd Schmidt
On 12/11/2015 02:48 PM, Jan Beulich wrote: Function (or more narrow) scope static variables (as well as others not placed on the stack) should also not have any effect on the stack alignment. I noticed the issue first with Linux'es dynamic_pr_debug() construct using an 8-byte aligned sub-file-sco

[v4] avoid alignment of static variables affecting stack's

2015-12-11 Thread Jan Beulich
; (s) : "0" (&x)); + + return n ? test(n - 1, x) : (x ^ p); +} + +int main (int argc, char *argv[] __attribute__((unused))) +{ + unsigned int x = test(argc, 0); + + x |= test(argc + 1, 0); + x |= test(argc + 2, 0); + + return !(x & (ALIGNMENT - 1)); +} avoid alignment o

Re: [v3] avoid alignment of static variables affecting stack's

2015-12-10 Thread Bernd Schmidt
On 12/10/2015 05:07 PM, Jan Beulich wrote: If not reaching if (TREE_CODE (origvar) == SSA_NAME) { gcc_assert (TREE_CODE (var) != VAR_DECL || (!DECL_EXTERNAL (var) && !DECL_HAS_VALUE_EXPR_P (var) && !TREE_STATIC (var)

Re: [v3] avoid alignment of static variables affecting stack's

2015-12-10 Thread Jan Beulich
>>> On 10.12.15 at 14:53, wrote: > On 12/10/2015 01:38 PM, Jan Beulich wrote: >> --- 2015-12-09/gcc/cfgexpand.c >> +++ 2015-12-09/gcc/cfgexpand.c >> @@ -1544,12 +1544,15 @@ static HOST_WIDE_INT >> expand_one_var (tree var, bool toplevel, bool really_expand) >> { >> unsigned int align = BIT

Re: [v3] avoid alignment of static variables affecting stack's

2015-12-10 Thread Bernd Schmidt
On 12/10/2015 01:38 PM, Jan Beulich wrote: * cfgexpand.c (expand_one_var): Exclude static and external variables when adjusting stack alignment related state. gcc/testsuite/ 2015-12-10 Jan Beulich * gcc.c-torture/execute/stkalign.c: New. --- 2015-12-09/gcc/cfgexpand

[v3] avoid alignment of static variables affecting stack's

2015-12-10 Thread Jan Beulich
ENT); + asm ("" : "=g" (x), "+m" (s) : "0" (&x)); + + return n ? test(n - 1, x) : (x ^ p); +} + +int main (int argc, char *argv[] __attribute__((unused))) +{ + unsigned int x = test(argc, 0); + + x |= test(argc + 1, 0); + x |= test(argc + 2, 0); + + re

Re: [PATCH v2] avoid alignment of static variables affecting stack's

2014-10-31 Thread Richard Biener
On Fri, Oct 24, 2014 at 4:57 PM, Jan Beulich wrote: > Function (or more narrow) scope static variables (as well as others not > placed on the stack) should also not have any effect on the stack > alignment. I noticed the issue first with Linux'es dynamic_pr_debug() > construct using an 8-byte alig

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Jeff Law
On 10/24/14 04:12, Jan Beulich wrote: On 24.10.14 at 11:52, wrote: On Fri, Oct 24, 2014 at 11:18 AM, Jakub Jelinek wrote: On Fri, Oct 24, 2014 at 11:10:08AM +0200, Richard Biener wrote: For something in static storage, this seems OK. However, I think a hard register variable ought to be lef

[PATCH v2] avoid alignment of static variables affecting stack's

2014-10-24 Thread Jan Beulich
bute__((__aligned__(ALIGNMENT))) c; } s; + unsigned x; + + assert(__alignof__(s) == ALIGNMENT); + asm ("" : "=g" (x), "+m" (s) : "0" (&x)); + + return n ? test(n - 1, x) : (x ^ p); +} + +int main (int argc, char *argv[] __attribute__((unused))) +{

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Richard Biener
On Fri, Oct 24, 2014 at 12:12 PM, Jan Beulich wrote: On 24.10.14 at 11:52, wrote: >> On Fri, Oct 24, 2014 at 11:18 AM, Jakub Jelinek wrote: >>> On Fri, Oct 24, 2014 at 11:10:08AM +0200, Richard Biener wrote: >> For something in static storage, this seems OK. However, I think a hard >>

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Jan Beulich
>>> On 24.10.14 at 11:52, wrote: > On Fri, Oct 24, 2014 at 11:18 AM, Jakub Jelinek wrote: >> On Fri, Oct 24, 2014 at 11:10:08AM +0200, Richard Biener wrote: >>> >> For something in static storage, this seems OK. However, I think a hard >>> >> register variable ought to be left alone -- even if w

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Richard Biener
On Fri, Oct 24, 2014 at 11:18 AM, Jakub Jelinek wrote: > On Fri, Oct 24, 2014 at 11:10:08AM +0200, Richard Biener wrote: >> >> For something in static storage, this seems OK. However, I think a hard >> >> register variable ought to be left alone -- even if we can't spill it to >> >> a stack slot

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Jakub Jelinek
On Fri, Oct 24, 2014 at 11:10:08AM +0200, Richard Biener wrote: > >> For something in static storage, this seems OK. However, I think a hard > >> register variable ought to be left alone -- even if we can't spill it to > >> a stack slot today, there's a reasonable chance we might add that > >> cap

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Jan Beulich
>>> On 24.10.14 at 11:10, wrote: > On Fri, Oct 24, 2014 at 11:01 AM, Jan Beulich wrote: > On 23.10.14 at 20:13, wrote: >>> On 10/23/14 01:09, Jan Beulich wrote: >>> On 23.10.14 at 08:50, wrote: > On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: >> Function (or more n

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Richard Biener
On Fri, Oct 24, 2014 at 11:01 AM, Jan Beulich wrote: On 23.10.14 at 20:13, wrote: >> On 10/23/14 01:09, Jan Beulich wrote: >> On 23.10.14 at 08:50, wrote: On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: > Function (or more narrow) scope static variables (as well as

Re: avoid alignment of static variables affecting stack's

2014-10-24 Thread Jan Beulich
>>> On 23.10.14 at 20:13, wrote: > On 10/23/14 01:09, Jan Beulich wrote: > On 23.10.14 at 08:50, wrote: >>> On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: Function (or more narrow) scope static variables (as well as others not placed on the stack) should also not have

Re: avoid alignment of static variables affecting stack's

2014-10-23 Thread Jeff Law
On 10/23/14 01:09, Jan Beulich wrote: On 23.10.14 at 08:50, wrote: On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: Function (or more narrow) scope static variables (as well as others not placed on the stack) should also not have any effect on the stack alignment. I noticed the iss

Re: avoid alignment of static variables affecting stack's

2014-10-23 Thread Jan Beulich
>>> On 23.10.14 at 08:50, wrote: > On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: >> Function (or more narrow) scope static variables (as well as others not >> placed on the stack) should also not have any effect on the stack >> alignment. I noticed the issue first with Linux'es dyna

Re: avoid alignment of static variables affecting stack's

2014-10-22 Thread Jakub Jelinek
On Thu, Oct 23, 2014 at 07:30:27AM +0100, Jan Beulich wrote: > Function (or more narrow) scope static variables (as well as others not > placed on the stack) should also not have any effect on the stack > alignment. I noticed the issue first with Linux'es dynamic_pr_debug() > construct using an 8-b

avoid alignment of static variables affecting stack's

2014-10-22 Thread Jan Beulich
ned__(ALIGNMENT))) c; } s; + unsigned x; + + assert(__alignof__(s) == ALIGNMENT); + asm ("" : "=g" (x), "+m" (s) : "0" (&x)); + + return n ? test(n - 1, x) : (x ^ p); +} + +int main (int argc, char *argv[] __attribute__((unused))) +{ + unsigned int x =