public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment
@ 2008-05-17 0:18 hjl dot tools at gmail dot com
2008-05-17 2:18 ` [Bug middle-end/36253] " hjl dot tools at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-17 0:18 UTC (permalink / raw)
To: gcc-bugs
setup_save_areas calls assign_stack_local to allocate a stack
slot for a hard register in the widest mode. assign_stack_local
has
if (align == 0)
{
tree type;
if (mode == BLKmode)
alignment = BIGGEST_ALIGNMENT;
else
alignment = GET_MODE_ALIGNMENT (mode);
/* Allow the target to (possibly) increase the alignment of this
stack slot. */
type = lang_hooks.types.type_for_mode (mode, 0);
if (type)
alignment = LOCAL_ALIGNMENT (type, alignment);
alignment /= BITS_PER_UNIT;
}
For x87, the widest mode is XF, which is 12byte aligned at 4 byte.
So a 12byte stack slot aligned at 4 byte is allocated for an x87
register. For x87, DF is 8 byte aligned at 8 byte. If it turns out
later that we need to save/restore DF instead XF, we load/store the DF
register at 4 byte instead of 8 byte. It won't give us the best x87
performance. One fix is change
if (type)
alignment = LOCAL_ALIGNMENT (type, alignment);
to
alignment = LOCAL_ALIGNMENT (type, mode, alignment);
If type is NULL, it is used for stack slot. We can return proper
alignment based on mode.
--
Summary: Caller-save stack slot may not have proper alignment
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
@ 2008-05-17 2:18 ` hjl dot tools at gmail dot com
2008-05-17 15:19 ` hjl dot tools at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-17 2:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from hjl dot tools at gmail dot com 2008-05-17 02:17 -------
With this patch to verify alignment of caller-save slot:
Index: caller-save.c
===================================================================
--- caller-save.c (revision 2603)
+++ caller-save.c (working copy)
@@ -704,6 +704,12 @@ insert_restore (struct insn_chain *chain
mem = adjust_address (mem, save_mode[regno], 0);
else
mem = copy_rtx (mem);
+
+ /* Verify that the alignment of spill space is equal to or greater
+ than required. */
+ if (GET_MODE_ALIGNMENT (GET_MODE (mem)) > MEM_ALIGN (mem))
+ gcc_unreachable ();
+
pat = gen_rtx_SET (VOIDmode,
gen_rtx_REG (GET_MODE (mem),
regno), mem);
@@ -776,6 +782,12 @@ insert_save (struct insn_chain *chain, i
mem = adjust_address (mem, save_mode[regno], 0);
else
mem = copy_rtx (mem);
+
+ /* Verify that the alignment of spill space is equal to or greater
+ than required. */
+ if (GET_MODE_ALIGNMENT (GET_MODE (mem)) > MEM_ALIGN (mem))
+ gcc_unreachable ();
+
pat = gen_rtx_SET (VOIDmode, mem,
gen_rtx_REG (GET_MODE (mem),
regno));
Index: function.c
===================================================================
--- function.c (revision 2603)
+++ function.c (working copy)
@@ -341,7 +341,7 @@ assign_stack_local (enum machine_mode mo
{
rtx x, addr;
int bigend_correction = 0;
- unsigned int alignment;
+ unsigned int alignment, alignment_in_bits;
int frame_off, frame_alignment, frame_phase;
if (align == 0)
@@ -378,8 +378,10 @@ assign_stack_local (enum machine_mode mo
if (alignment * BITS_PER_UNIT > PREFERRED_STACK_BOUNDARY)
alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
- if (crtl->stack_alignment_needed < alignment * BITS_PER_UNIT)
- crtl->stack_alignment_needed = alignment * BITS_PER_UNIT;
+ alignment_in_bits = alignment * BITS_PER_UNIT;
+
+ if (crtl->stack_alignment_needed < alignment_in_bits)
+ crtl->stack_alignment_needed = alignment_in_bits;
/* Calculate how many bytes the start of local variables is off from
stack alignment. */
@@ -432,6 +434,7 @@ assign_stack_local (enum machine_mode mo
frame_offset += size;
x = gen_rtx_MEM (mode, addr);
+ set_mem_align (x, alignment_in_bits);
MEM_NOTRAP_P (x) = 1;
stack_slot_list
On Linux/Intel64, I got
gnu/java/awt/GradientPaintContext.java: In class
'gnu.java.awt.GradientPaintContext':
gnu/java/awt/GradientPaintContext.java: In method
'gnu.java.awt.GradientPaintContext.getRaster(int,int,int,int)':
In file included from gnu/java/awt/EventModifier.java:105,
from gnu/java/awt/EmbeddedWindow.java:137,
from gnu/java/awt/ComponentReshapeEvent.java:84,
from gnu/java/awt/ComponentDataBlitOp.java:154,
from gnu/java/awt/ClasspathToolkit.java:231,
from gnu/java/awt/ClasspathGraphicsEnvironment.java:65,
from gnu/java/awt/Buffers.java:222,
from
/export/gnu/src/gcc-expand/gcc/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java:292,
from
/export/gnu/src/gcc-expand/gcc/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java:202,
from gnu/java/awt/BitwiseXORComposite.java:130,
from gnu/java/awt/BitMaskExtent.java:77,
from
/export/gnu/src/gcc-expand/gcc/libjava/classpath/gnu/java/awt/AWTUtilities.java:253,
from
/export/gnu/src/gcc-expand/gcc/libjava/classpath/gnu/java/awt/AWTUtilities.java:296,
from gnu/java/awt/AWTUtilities.java:895,
from <built-in>:63:
gnu/java/awt/GradientPaintContext.java:153: internal compiler error: in
insert_save, at caller-save.c:789
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[6]: *** [gnu/java/awt.lo] Error 1
make[6]: *** Waiting for unfinished jobs....
when I was building 32bit libjava.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
2008-05-17 2:18 ` [Bug middle-end/36253] " hjl dot tools at gmail dot com
@ 2008-05-17 15:19 ` hjl dot tools at gmail dot com
2008-05-17 23:51 ` hjl dot tools at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-17 15:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from hjl dot tools at gmail dot com 2008-05-17 15:18 -------
A patch is posted at
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01021.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2008-
| |05/msg01021.html
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
2008-05-17 2:18 ` [Bug middle-end/36253] " hjl dot tools at gmail dot com
2008-05-17 15:19 ` hjl dot tools at gmail dot com
@ 2008-05-17 23:51 ` hjl dot tools at gmail dot com
2008-05-17 23:59 ` hjl at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-17 23:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl dot tools at gmail dot com 2008-05-17 23:50 -------
An updated patch is posted at
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01029.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Joey dot ye at intel dot
| |com, xuepeng dot guo at
| |intel dot com
URL|http://gcc.gnu.org/ml/gcc- |http://gcc.gnu.org/ml/gcc-
|patches/2008- |patches/2008-
|05/msg01021.html |05/msg01029.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
` (2 preceding siblings ...)
2008-05-17 23:51 ` hjl dot tools at gmail dot com
@ 2008-05-17 23:59 ` hjl at gcc dot gnu dot org
2008-05-26 14:01 ` hjl at gcc dot gnu dot org
2008-05-26 14:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-05-17 23:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from hjl at gcc dot gnu dot org 2008-05-17 23:58 -------
Subject: Bug 36253
Author: hjl
Date: Sat May 17 23:57:59 2008
New Revision: 135486
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135486
Log:
2008-05-17 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36253
* caller-save.c (insert_restore): Verify alignment of spill
space.
(insert_save): Likewise.
* cfgexpand.c (LOCAL_ALIGNMENT): Removed.
(get_decl_align_unit): Pass VOIDmode to LOCAL_ALIGNMENT.
* defaults.h (LOCAL_ALIGNMENT): New. Provide default.
* function.c (LOCAL_ALIGNMENT): Removed.
(get_stack_local_alignment): New.
(assign_stack_local): Use it. Set alignment on stack slot.
(assign_stack_temp_for_type): Use get_stack_local_alignment.
* config/bfin/bfin.c (bfin_local_alignment): Updated.
* config/bfin/bfin.h (LOCAL_ALIGNMENT): Likewise.
* config/bfin/bfin-protos.h (bfin_local_alignment): Likewise.
* config/i386/i386.h (LOCAL_ALIGNMENT): Likewise.
* config/i386/i386-protos.h (ix86_local_alignment): Likewise.
* config/mips/mips.h (LOCAL_ALIGNMENT): Likewise.
* config/mmix/mmix.c (mmix_local_alignment): Likewise.
* config/mmix/mmix.h (LOCAL_ALIGNMENT): Likewise.
* config/mmix/mmix-protos.h (mmix_local_alignment): Likewise.
* config/rs6000/rs6000.h (LOCAL_ALIGNMENT): Likewise.
* config/score/score.h (LOCAL_ALIGNMENT): Likewise.
* config/sh/sh.h (LOCAL_ALIGNMENT): Likewise.
* config/sparc/sparc.h (LOCAL_ALIGNMENT): Likewise.
* config/spu/spu.h (LOCAL_ALIGNMENT): Likewise.
* config/i386/i386.c (ix86_local_alignment): Handle caller-save
stack slot in XFmode.
* config/rs6000/rs6000.h (LOCAL_ALIGNMENT_1): New.
* config/sh/sh.h (LOCAL_ALIGNMENT_1): Likewise.
* doc/tm.texi (LOCAL_ALIGNMENT): Add mode.
Modified:
branches/stack/gcc/ChangeLog.stackalign
branches/stack/gcc/caller-save.c
branches/stack/gcc/cfgexpand.c
branches/stack/gcc/config/bfin/bfin-protos.h
branches/stack/gcc/config/bfin/bfin.c
branches/stack/gcc/config/bfin/bfin.h
branches/stack/gcc/config/i386/i386-protos.h
branches/stack/gcc/config/i386/i386.c
branches/stack/gcc/config/i386/i386.h
branches/stack/gcc/config/mips/mips.h
branches/stack/gcc/config/mmix/mmix-protos.h
branches/stack/gcc/config/mmix/mmix.c
branches/stack/gcc/config/mmix/mmix.h
branches/stack/gcc/config/rs6000/rs6000.h
branches/stack/gcc/config/score/score.h
branches/stack/gcc/config/sh/sh.h
branches/stack/gcc/config/sparc/sparc.h
branches/stack/gcc/config/spu/spu.h
branches/stack/gcc/defaults.h
branches/stack/gcc/doc/tm.texi
branches/stack/gcc/function.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
` (3 preceding siblings ...)
2008-05-17 23:59 ` hjl at gcc dot gnu dot org
@ 2008-05-26 14:01 ` hjl at gcc dot gnu dot org
2008-05-26 14:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-05-26 14:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl at gcc dot gnu dot org 2008-05-26 14:00 -------
Subject: Bug 36253
Author: hjl
Date: Mon May 26 13:59:56 2008
New Revision: 135927
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135927
Log:
2008-05-26 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36253
* caller-save.c (insert_restore): Verify alignment of spill
space.
(insert_save): Likewise.
* cfgexpand.c (LOCAL_ALIGNMENT): Removed.
* defaults.h (LOCAL_ALIGNMENT): New. Provide default.
(STACK_SLOT_ALIGNMENT): Likewise.
* function.c (LOCAL_ALIGNMENT): Removed.
(get_stack_local_alignment): New.
(assign_stack_local): Use it. Set alignment on stack slot.
(assign_stack_temp_for_type): Use get_stack_local_alignment.
* config/i386/i386.h (LOCAL_ALIGNMENT): Updated.
(STACK_SLOT_ALIGNMENT): New.
* config/i386/i386.c (ix86_local_alignment): Handle caller-save
stack slot in XFmode.
* doc/tm.texi (STACK_SLOT_ALIGNMENT): New.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/caller-save.c
trunk/gcc/cfgexpand.c
trunk/gcc/config/i386/i386-protos.h
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/i386.h
trunk/gcc/defaults.h
trunk/gcc/doc/tm.texi
trunk/gcc/function.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/36253] Caller-save stack slot may not have proper alignment
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
` (4 preceding siblings ...)
2008-05-26 14:01 ` hjl at gcc dot gnu dot org
@ 2008-05-26 14:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-26 14:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from hjl dot tools at gmail dot com 2008-05-26 14:28 -------
Fixed by
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01615.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-05-26 14:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-17 0:18 [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment hjl dot tools at gmail dot com
2008-05-17 2:18 ` [Bug middle-end/36253] " hjl dot tools at gmail dot com
2008-05-17 15:19 ` hjl dot tools at gmail dot com
2008-05-17 23:51 ` hjl dot tools at gmail dot com
2008-05-17 23:59 ` hjl at gcc dot gnu dot org
2008-05-26 14:01 ` hjl at gcc dot gnu dot org
2008-05-26 14:29 ` hjl dot tools 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).