This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Pointer alignment


Hi,

PR opt/13041 is a miscompilation of the 2.6.0-test9 kernel on i386 at -O2 
-fomit-frame-pointer, which is related to pointer alignment.

emit-rtl.c:init_emit has these lines:

#ifdef STACK_BOUNDARY
  REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY;
  REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM) = STACK_BOUNDARY;
  REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = STACK_BOUNDARY;
  REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = STACK_BOUNDARY;
#endif

and AFAICS this is the only place where hard registers are given pointer 
alignment.

Now, of course, if it happens that HARD_FRAME_POINTER_REGNUM is allocated to 
a pseudo holding a pointer, this pointer is automatically promoted to  
STACK_BOUNDARY alignment.  On i386, this means that the associated MEM will 
satisfy i386.c:aligned_operand and, as a consequence, a half-word (HImode) 
move to the MEM in question will be promoted to a full-word (SImode) move.

I think a fix suited to the 3.3 branch is to decrease the alignment of 
HARD_FRAME_POINTER_REGNUM after register allocation based on the flag 
frame_pointer_needed from final.c.  But what about mainline?  Should hard 
regs be given the pointer alignment of the pseudos they are allocated to, 
for example using emit-rtl.c:mark_reg_pointer which has the nice property to 
never increase the alignment?

-- 
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]