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

[Bug c/14445] New: stdargs broken with -mips64


Stdargs is broken in gcc 3.3.3 when specifying -mips64
and either mabi=n32 or meabi.

The compiler passes the first few varargs in registers.
They eventually get put in memory with 8 byte offsets by
the callee. The caller puts any args that don't fit in
registers in memory with 4 byte offsets.

#include <stdarg.h>

void func1(int a, ...)
{
    int i;
    va_list(ap);

    va_start(ap, a);
    for(i=0;i<a;i++) {
	int j;
	j = va_arg(ap, int);
    }
    va_end(ap);
}

void func2(void)
{
    func1(1,2,3,4,5,6,7,8,9,10);
}



	.file	1 "va.c"
	.section .mdebug.abiN32
	.previous
	.text
	.align	2
	.globl	func1
	.ent	func1
func1:
	.frame	$fp,96,$31		# vars= 16, regs= 1/0, args= 0, extra= 0
	.mask	0x40000000,-80
	.fmask	0x00000000,0
	subu	$sp,$sp,96
	sd	$fp,16($sp)
	move	$fp,$sp
	sd	$5,40($fp)
	sd	$6,48($fp)
	sd	$7,56($fp)
	sd	$8,64($fp)
	sd	$9,72($fp)
	sd	$10,80($fp)
	sd	$11,88($fp)
	sw	$4,0($fp)
	addu	$2,$fp,40
	sw	$2,8($fp)
	sw	$0,4($fp)
$L2:
	lw	$2,4($fp)
	lw	$3,0($fp)
	slt	$2,$2,$3
	bne	$2,$0,$L5
	j	$L1
$L5:
	lw	$2,8($fp)
	addu	$3,$2,7
	li	$2,-8			# 0xfffffffffffffff8
	and	$2,$3,$2
	sw	$2,8($fp)
	lw	$2,8($fp)
	addu	$2,$2,4
	move	$3,$2
	lw	$2,8($fp)
	addu	$2,$2,8
	sw	$2,8($fp)
	lw	$2,0($3)
	sw	$2,12($fp)
	lw	$2,4($fp)
	addu	$2,$2,1
	sw	$2,4($fp)
	j	$L2
$L1:
	move	$sp,$fp
	ld	$fp,16($sp)
	addu	$sp,$sp,96
	j	$31
	.end	func1
	.align	2
	.globl	func2
	.ent	func2
func2:
	.frame	$fp,32,$31		# vars= 0, regs= 2/0, args= 16, extra= 0
	.mask	0xc0000000,-8
	.fmask	0x00000000,0
	subu	$sp,$sp,32
	sd	$31,24($sp)
	sd	$fp,16($sp)
	move	$fp,$sp
	li	$2,9			# 0x9
	sw	$2,4($sp)
	li	$2,10			# 0xa
	sw	$2,12($sp)
	li	$4,1			# 0x1
	li	$5,2			# 0x2
	li	$6,3			# 0x3
	li	$7,4			# 0x4
	li	$8,5			# 0x5
	li	$9,6			# 0x6
	li	$10,7			# 0x7
	li	$11,8			# 0x8
	jal	func1
	move	$sp,$fp
	ld	$31,24($sp)
	ld	$fp,16($sp)
	addu	$sp,$sp,32
	j	$31
	.end	func2

-- 
           Summary: stdargs broken with -mips64
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: crmorrow at telus dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: mipsisa32-unknown-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14445


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