This is the mail archive of the 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]

Re: CFI directives and dynamic stack alignment

On Mon, Aug 03, 2015 at 02:48:09PM -0700, Steve Ellcey wrote:
> When I generate code to dynamically align the stack my code looks like
> this:
> fn2:
> 	.frame	$fp,32,$31		# vars= 0, regs= 2/0, args= 16, gp= 8
> 	.mask	0xc0000000,-4
> 	.fmask	0x00000000,0
> 	.set	noreorder
> 	.set	nomacro
> 	lui	$2,%hi(null)
> 	li	$3,-16			# 0xfffffffffffffff0
> 	lw	$2,%lo(null)($2)
> 	and	$sp,$sp,$3
> 	addiu	$sp,$sp,-32
> 	.cfi_def_cfa_offset 32
> 	sw	$fp,24($sp)
> 	.cfi_offset 30, -8
> 	move	$fp,$sp
> 	.cfi_def_cfa_register 30
> 	sw	$31,28($sp)
> 	.cfi_offset 31, -4
> 	jal	abort
> 	sb	$0,0($2)
> The 'and' instruction is where the stack gets aligned and if I remove that
> one instruction, everything works.  I think I need to put out some new CFI
> psuedo-ops to handle this but I am not sure what they should be.  I am just
> not very familiar with the CFI directives.

I don't speak mips assembly very well, but it looks to me that you
have more than just CFI problems.  How do you restore sp on return
from the function, assuming sp wasn't 16-byte aligned to begin with?
Past that "and $sp,$sp,$3" you don't have any means of calculating
the original value of sp!  (Which of course is why you also can't find
a way of representing the frame address.)

Alan Modra
Australia Development Lab, IBM

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