Bug 52828

Summary: powerpc -m32 -Os writes register saves below stack
Product: gcc Reporter: Alan Modra <amodra>
Component: targetAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: segher
Priority: P3    
Version: 4.8.0   
Target Milestone: ---   
Host: Target: powerpc-linux
Build: Known to work:
Known to fail: Last reconfirmed: 2012-04-03 00:00:00

Description Alan Modra 2012-04-02 02:27:49 UTC
An example is gcc.c-torture/compile/20020604-1.c compiled with -m32 -g -Os -fno-omit-frame-pointer.  (The -fno-omit-frame-pointer is there just to get a reg saved.  An asm volatile reg clobber gives the same result.)
The relevant part of the prologue code looks like

 lis 0,0xffff
 mr 12,1
 ori 0,0,32736
 stw 31,-4(12)
 stwux 1,1,0
 .cfi_def_cfa_offset 32800
 .cfi_offset 31, 32796

Notice the r31 save before the stack adjust.  Another consequence of the reordering is wrong debug/eh_frame info for r31.
Comment 1 Alan Modra 2012-04-12 22:26:28 UTC
Author: amodra
Date: Thu Apr 12 22:26:24 2012
New Revision: 186397

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186397
Log:
	PR target/52828
	* config/rs6000/rs6000.c (rs6000_emit_stack_tie): Rewrite with
	tie regs on destination of sets.  Delete forward declaration.
	(rs6000_emit_stack_reset): Update rs6000_emit_stack_tie calls.
	(rs6000_emit_prologue): Likewise.
	(rs6000_emit_epilogue): Likewise.  Use in place of gen_frame_tie
	and gen_stack_tie.
	(is_mem_ref): Use tie_operand to recognise stack ties.
	* config/rs6000/predicates.md (tie_operand): New.
	* config/rs6000/rs6000.md (restore_stack_block): Generate new
	stack tie rtl.
	(restore_stack_nonlocal): Likewise.
	(stack_tie): Update.
	(frame_tie): Delete.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/predicates.md
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/rs6000.md
Comment 2 Segher Boessenkool 2015-11-21 20:01:43 UTC
Assuming fixed.