This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[FR-V, installed] use hard regs explicitly in tls indirect calls


As it turned out, the likely-spilled changes I installed in reload
last year were not enough to get glibc mainline to build with GCC
mainline: in one of the TLS test cases, sched moved an insn that set
gr8 as an argument for a function call before a TLS indirect call
instruction, and then failed to reload the operands whose constraints
required gr8.

I figured if turning the tls indirect call sequence into a
libcall-like sequence was the most reasonable way to avoid getting
reload into such dire straits, and this is what the patch does.
Tested by building a working glibc for frv-linux-gnu on
x86_64-linux-gnu.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/frv/frv.md ("tls_indirect_call"): Turn into libcall-like
	expand.
	("*tls_indirect_call"): New, reference hard regs directly.
	* config/frv/frv.c (gen_inlined_tls_plt): Adjust.

Index: gcc/config/frv/frv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.c,v
retrieving revision 1.82
diff -u -p -r1.82 frv.c
--- gcc/config/frv/frv.c 1 Feb 2005 06:33:33 -0000 1.82
+++ gcc/config/frv/frv.c 7 Feb 2005 07:59:34 -0000
@@ -3481,8 +3481,7 @@ gen_inlined_tls_plt (rtx addr)
     }
 
   retval = gen_reg_rtx (Pmode);
-  emit_insn (gen_tls_indirect_call (retval, addr, dest, gen_reg_rtx (Pmode),
-				    picreg));
+  emit_insn (gen_tls_indirect_call (retval, addr, dest, picreg));
   return retval;
 }
 
Index: gcc/config/frv/frv.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.md,v
retrieving revision 1.30
diff -u -p -r1.30 frv.md
--- gcc/config/frv/frv.md 1 Feb 2005 06:33:35 -0000 1.30
+++ gcc/config/frv/frv.md 7 Feb 2005 07:59:38 -0000
@@ -8203,25 +8203,42 @@
   [(set_attr "length" "4")
    (set_attr "type" "load_or_call")])
 
-;; Reads GR8 and GR9.
-;; Clobbers GR8.
-;; Modifies GR9.
-(define_insn "tls_indirect_call"
-  [(set (match_operand:SI 0 "register_operand" "=D09")
+;; We have to expand this like a libcall (it sort of actually is)
+;; because otherwise sched may move, for example, an insn that sets up
+;; GR8 for a subsequence call before the *tls_indirect_call insn, and
+;; then reload won't be able to fix things up.
+(define_expand "tls_indirect_call"
+  [(set (reg:DI GR8_REG)
+	(match_operand:DI 2 "register_operand" ""))
+   (parallel
+    [(set (reg:SI GR9_REG)
+	  (unspec:SI
+	   [(match_operand:SI 1 "symbolic_operand" "")
+	   (reg:DI GR8_REG)]
+	   UNSPEC_TLS_INDIRECT_CALL))
+    (clobber (reg:SI GR8_REG))
+    (clobber (reg:SI LRREG))
+    (use (match_operand:SI 3 "register_operand" ""))])
+   (set (match_operand:SI 0 "register_operand" "")
+	(reg:SI GR9_REG))]
+  "HAVE_AS_TLS")
+
+(define_insn "*tls_indirect_call"
+  [(set (reg:SI GR9_REG)
 	(unspec:SI
-	 [(match_operand:SI 1 "symbolic_operand" "")
-	  (match_operand:DI 2 "register_operand" "D89")]
+	 [(match_operand:SI 0 "symbolic_operand" "")
+	  (reg:DI GR8_REG)]
 	 UNSPEC_TLS_INDIRECT_CALL))
-   (clobber (match_operand:SI 3 "register_operand" "=D08"))
+   (clobber (reg:SI GR8_REG))
    (clobber (reg:SI LRREG))
    ;; If there was a way to represent the fact that we don't need GR9
    ;; or GR15 to be set before this instruction (it could be in
    ;; parallel), we could use it here.  This change wouldn't apply to
    ;; call_gettlsoff, thought, since the linker may turn the latter
    ;; into ldi @(gr15,offset),gr9.
-   (use (match_operand:SI 4 "register_operand" "D15"))]
+   (use (match_operand:SI 1 "register_operand" "D15"))]
   "HAVE_AS_TLS"
-  "calll #gettlsoff(%a1)@(%2,gr0)"
+  "calll #gettlsoff(%a0)@(gr8,gr0)"
   [(set_attr "length" "4")
    (set_attr "type" "jumpl")])
 
-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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