🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #411

gcc 2.1 bug with frame ptr handling

#411
From: Brendan Kehoe
Date: Tue, 14 Apr 1992 20:59
37 lines
1502 bytes
The code below on a sparc produces bad code when no opimization is
turned on---note that it uses %fp *after* it's been zero'd out.  A
similar program for the DecStation exhibits the same problem.  I'm not
sure if this falls under the "gcc bug" section, or under the "really
nasty user trick".  Should gcc recognize that you've altered fp and
compensate [if it can]?

This bug came out of the sun4 start.c in the GNU C library failing to
build properly without optimization.

--
/* For mips, change %sp to `sp', and %fp to `$fp'.  */
register long int sp asm("%sp"), fp asm("%fp");

foo ()
{
  int a;

  /* mov 0, %fp */
  fp = 0;

  /* ld [%sp+16], %o0
     st %o0, [%fp-20] */
  a = ((int *)sp)[4];

  /* ld [%fp-20], %i0 */
  return a;

  /* When optimized, all of the above becomes the single instruction
       ld [%sp+16], %i0
     which avoids the problem.  */
}


--
Brendan Kehoe, Sun Network Manager                      brendan@cs.widener.edu
Widener University                                                 Chester, PA
Technical Details
Message-ID: <199204150459.AA00555@lisa.cs.widener.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.widener.edu!brendan

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.widener.edu!brendan
From: brendan@cs.widener.edu (Brendan Kehoe)
Subject: gcc 2.1 bug with frame ptr handling
Message-ID: <199204150459.AA00555@lisa.cs.widener.edu>
Sender: gnulists@ai.mit.edu
Reply-To: brendan@cs.widener.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 14 Apr 1992 20:59:28 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 38