calls.c (precompute_register_parameters): Force non-legitimate constants into pseudos.
authorRichard Henderson <rth@redhat.com>
Tue, 1 Oct 2002 20:49:39 +0000 (13:49 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 1 Oct 2002 20:49:39 +0000 (13:49 -0700)
        * calls.c (precompute_register_parameters): Force non-legitimate
        constants into pseudos.
* gcc.dg/tls/opt-3.c: New.

From-SVN: r57709

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/gcc.dg/tls/opt-3.c [new file with mode: 0644]

index 4af6f0fe95fe599636026d71b203bedb34177659..a4a53a410a9f362d672fc1c6cd13d0475ff7dfe1 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-01  Richard Henderson  <rth@redhat.com>
+
+       * calls.c (precompute_register_parameters): Force non-legitimate
+       constants into pseudos.
+
 2002-10-01  Nick Clifton  <nickc@redhat.com>
 
        * config/rs6000/spe.md (spe_evrlwi): Add missing third operand
index ffedacabbb051f1e890c0e26649734f731dd6714..d706751c16265b5900811e7a661a353806e11da2 100644 (file)
@@ -876,6 +876,12 @@ precompute_register_parameters (num_actuals, args, reg_parm_seen)
            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.  */
 
diff --git a/gcc/testsuite/gcc.dg/tls/opt-3.c b/gcc/testsuite/gcc.dg/tls/opt-3.c
new file mode 100644 (file)
index 0000000..0e56991
--- /dev/null
@@ -0,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);
+}