cleanup the whole addpattern / trx nonsense
[openwrt.git] / openwrt / toolchain / gcc / 3.4.1 / 400-mips-delay-slot.patch
1 http://www.linux-mips.org/archives/linux-mips/2004-09/msg00000.html
2
3 Atsushi Nemoto <anemo@mba.ocn.ne.jp> writes:
4 >/ Is this a get_user's problem or gcc's?/
5
6 The latter. gcc is putting the empty asm:
7
8 __asm__ ("":"=r" (__gu_val));
9
10 into the delay slot of the call.
11
12 Part of the problem is that gcc estimates the length of an asm to be the
13 number of instruction separators + 1. This means that it estimates the
14 asm above to be one instruction long, which is perhaps a little silly
15 for an empty string.
16
17 But the real problem is that gcc should never trust this estimate anyway,
18 since each "instruction" could obviously be a multi-instruction macro.
19 gcc should certainly never put asms into delay slots.
20
21 FWIW, I don't think the bug is specific to 3.3 or 3.4. It could
22 probably trigger for other gcc versions too. It is highly dependent
23 on scheduling though.
24
25 The attached 3.4.x patch fixes the problem there, but if you want to work
26 around it for old versions, just avoid using empty asms if you can,
27 or make them volatile if you can't.
28
29 Of course, the problem isn't confined to empty asms. If you have an asm
30 with a single, multi-instruction macro, gcc might try putting that in a
31 delay slot too. You should at least get an assembler warning in that case.
32
33 Richard
34
35
36 --- gcc-3.4.1/gcc/config/mips/mips.md-orig 2004-09-02 10:38:36.000000000 -0500
37 +++ gcc-3.4.1/gcc/config/mips/mips.md 2004-09-02 10:38:42.000000000 -0500
38 @@ -251,7 +251,7 @@
39
40 ;; Can the instruction be put into a delay slot?
41 (define_attr "can_delay" "no,yes"
42 - (if_then_else (and (eq_attr "type" "!branch,call,jump")
43 + (if_then_else (and (eq_attr "type" "!branch,call,jump,multi")
44 (and (eq_attr "hazard" "none")
45 (eq_attr "single_insn" "yes")))
46 (const_string "yes")
This page took 0.04521 seconds and 5 git commands to generate.