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]

Bug on sparc-sun-solaris2.6 causes __builtin_apply/return to fail



Machine: sparc-sun-solaris2.6
Compiler: gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
Compiler Build Options: None (configure; make bootstrap)

There is a bug on sparc and/or solaris machines the causes the
__builtin_apply and related functions to fail. Enclosed is a programs that
shows this bug, and also a patch. This patch was mostly discovered by
someone else (Scott Christley <scottc@net-community.com>), so I do not
know why it works or if it is correct.

This bug has existed in all versions of egcs (that I know of) and in gcc
back to gcc 2.8.0

---
Adam Fedor
Digital Optics Co.
fedor@doc.com
fedor@gnu.org

#include <stdio.h>

int invoke_function(int a)
{
  printf("invoke_function invoked with %d\n", a);
  return a+1;
}

int function(int a)
{
  void *returned;
  void *argframe;
  int argsize;

  argframe = __builtin_apply_args();
  argsize  = 0;
  returned = __builtin_apply(invoke_function, argframe, argsize);
  __builtin_return(returned);
}

int
main()
{
  printf("got %d from invoke_function\n", function(10));
  return 0;
}

*** config/sparc/sparc.md.orig	Thu Jun 17 22:49:53 1999
--- config/sparc/sparc.md	Thu Jun 17 22:51:20 1999
***************
*** 5616,5622 ****
  		    gen_rtvec (3,
  			       gen_rtx_SET (VOIDmode, pc_rtx,
  					XEXP (operands[0], 0)),
! 			       GEN_INT (INTVAL (operands[3]) & 0xfff),
  			       gen_rtx_CLOBBER (VOIDmode,
  					gen_rtx_REG (Pmode, 15)))));
        else
--- 5616,5622 ----
  		    gen_rtvec (3,
  			       gen_rtx_SET (VOIDmode, pc_rtx,
  					XEXP (operands[0], 0)),
! 			       operands[3],
  			       gen_rtx_CLOBBER (VOIDmode,
  					gen_rtx_REG (Pmode, 15)))));
        else
***************
*** 5648,5654 ****
      emit_call_insn
        (gen_rtx_PARALLEL (VOIDmode,
  		gen_rtvec (3, gen_rtx_CALL (VOIDmode, fn_rtx, nregs_rtx),
! 			   GEN_INT (INTVAL (operands[3]) & 0xfff),
  			   gen_rtx_CLOBBER (VOIDmode,
  				    gen_rtx_REG (Pmode, 15)))));
    else
--- 5648,5654 ----
      emit_call_insn
        (gen_rtx_PARALLEL (VOIDmode,
  		gen_rtvec (3, gen_rtx_CALL (VOIDmode, fn_rtx, nregs_rtx),
! 			   operands[3],
  			   gen_rtx_CLOBBER (VOIDmode,
  				    gen_rtx_REG (Pmode, 15)))));
    else

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