public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/17565] New: asms in delay slots
@ 2004-09-20  6:43 rsandifo at gcc dot gnu dot org
  2004-09-20  6:43 ` [Bug target/17565] " rsandifo at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2004-09-20  6:43 UTC (permalink / raw)
  To: gcc-bugs

The MIPS port allows asms to be put into delay slots if the
compiler guesses they are only one instruction long.  This is
wrong because of the possibiltiy of it containing macros.

The problem can be reproduced as an assembler warning
in the following testcase:

int foo (int n)
{
  register int k asm ("$16") = n;
  if (k > 0)
    {
      bar ();
      asm ("li %0,0x12345678" : "=r" (k));
    }
  return k;
}

because the multi-instruction asm statement goes into the delay
slot of the call to bar().

This is reduced from a much more serious linux problem.
Linux is fond of using empty asm statements, and since gcc estimates
empty asms to be one instruction long, they too might be put into
delay slots.  This actually has the effect of putting the following
instruction into the delay slot instead.  Since there's no assembler
warning, the problem was only detected as a run-time failure.

This problem goes back to at least 2.95.

Richard

-- 
           Summary: asms in delay slots
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rsandifo at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: mips64-elf


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-01-08 14:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-20  6:43 [Bug target/17565] New: asms in delay slots rsandifo at gcc dot gnu dot org
2004-09-20  6:43 ` [Bug target/17565] " rsandifo at gcc dot gnu dot org
2004-09-20  6:54 ` cvs-commit at gcc dot gnu dot org
2004-09-20  7:00 ` rsandifo at gcc dot gnu dot org
2004-09-20 12:57 ` [Bug target/17565] [3.4 only] " pinskia at gcc dot gnu dot org
2004-09-20 12:59 ` rsandifo at redhat dot com
2004-09-20 14:36 ` mark at codesourcery dot com
2004-09-20 15:27 ` cvs-commit at gcc dot gnu dot org
2004-09-22 21:26 ` [Bug target/17565] [3.3 " pinskia at gcc dot gnu dot org
2004-09-28 13:41 ` gdr at gcc dot gnu dot org
2005-01-08 14:11 ` cvs-commit at gcc dot gnu dot org
2005-01-08 14:14 ` rsandifo at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).