fix tls vs regparm ice

Richard Henderson rth@redhat.com
Tue Oct 1 13:50:00 GMT 2002


Found in a glibc build.


r~


        * calls.c (precompute_register_parameters): Force non-legitimate
        constants into pseudos.
	* gcc.dg/tls/opt-3.c: New.

Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.238
diff -c -p -d -r1.238 calls.c
*** calls.c	27 Sep 2002 04:12:51 -0000	1.238
--- calls.c	1 Oct 2002 20:40:22 -0000
*************** precompute_register_parameters (num_actu
*** 876,881 ****
--- 876,887 ----
  	    emit_queue ();
  	  }
  
+ 	/* If the value is a non-legitimate constant, force it into a
+ 	   pseudo now.  TLS symbols sometimes need a call to resolve.  */
+ 	if (CONSTANT_P (args[i].value)
+ 	    && !LEGITIMATE_CONSTANT_P (args[i].value))
+ 	  args[i].value = force_reg (args[i].mode, args[i].value);
+ 
  	/* If we are to promote the function arg to a wider mode,
  	   do it now.  */
  
Index: testsuite/gcc.dg/tls/opt-3.c
===================================================================
RCS file: testsuite/gcc.dg/tls/opt-3.c
diff -N testsuite/gcc.dg/tls/opt-3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/tls/opt-3.c	1 Oct 2002 20:40:22 -0000
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fpic } */
+ /* { dg-options "-O2 -fpic -mregparm=3" { target i?86-*-* } } */
+ 
+ extern __thread int i, j, k;
+ extern void bar(int *, int *, int *);
+ void foo(void)
+ {
+   bar(&i, &j, &k);
+ }



More information about the Gcc-patches mailing list