From: Richard Sandiford <rsandifo@redhat.com>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: linux-mips@linux-mips.org
Subject: Re: gcc 3.3.4/3.4.1 and get_user
Date: Wed, 01 Sep 2004 09:51:16 +0100 [thread overview]
Message-ID: <87656yqsmz.fsf@redhat.com> (raw)
In-Reply-To: <20040901.012223.59462025.anemo@mba.ocn.ne.jp> (Atsushi Nemoto's message of "Wed, 01 Sep 2004 01:22:23 +0900 (JST)")
Atsushi Nemoto <anemo@mba.ocn.ne.jp> writes:
> Is this a get_user's problem or gcc's?
The latter. gcc is putting the empty asm:
__asm__ ("":"=r" (__gu_val));
into the delay slot of the call.
Part of the problem is that gcc estimates the length of an asm to be the
number of instruction separators + 1. This means that it estimates the
asm above to be one instruction long, which is perhaps a little silly
for an empty string.
But the real problem is that gcc should never trust this estimate anyway,
since each "instruction" could obviously be a multi-instruction macro.
gcc should certainly never put asms into delay slots.
FWIW, I don't think the bug is specific to 3.3 or 3.4. It could
probably trigger for other gcc versions too. It is highly dependent
on scheduling though.
The attached 3.4.x patch fixes the problem there, but if you want to work
around it for old versions, just avoid using empty asms if you can,
or make them volatile if you can't.
Of course, the problem isn't confined to empty asms. If you have an asm
with a single, multi-instruction macro, gcc might try putting that in a
delay slot too. You should at least get an assembler warning in that case.
Richard
Index: config/mips/mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.211.4.7
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.211.4.7 mips.md
--- config/mips/mips.md 25 Jun 2004 07:35:30 -0000 1.211.4.7
+++ config/mips/mips.md 1 Sep 2004 08:26:02 -0000
@@ -251,7 +251,7 @@ (define_attr "single_insn" "no,yes"
;; Can the instruction be put into a delay slot?
(define_attr "can_delay" "no,yes"
- (if_then_else (and (eq_attr "type" "!branch,call,jump")
+ (if_then_else (and (eq_attr "type" "!branch,call,jump,multi")
(and (eq_attr "hazard" "none")
(eq_attr "single_insn" "yes")))
(const_string "yes")
next prev parent reply other threads:[~2004-09-01 8:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-31 16:22 gcc 3.3.4/3.4.1 and get_user Atsushi Nemoto
2004-09-01 8:51 ` Richard Sandiford [this message]
2004-09-01 15:14 ` Atsushi Nemoto
2004-09-01 15:16 ` Atsushi Nemoto
2004-09-20 8:59 ` Richard Sandiford
2004-09-20 14:18 ` Atsushi Nemoto
2004-09-20 15:40 ` Ralf Baechle
2004-09-20 17:10 ` Ralf Baechle
2004-09-24 7:39 ` Atsushi Nemoto
2004-11-04 6:37 ` Atsushi Nemoto
2004-11-12 13:44 ` Ralf Baechle
2004-11-16 3:15 ` Atsushi Nemoto
2004-09-24 3:18 ` Atsushi Nemoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87656yqsmz.fsf@redhat.com \
--to=rsandifo@redhat.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.