From fd1e5d25e3f39f8ebfc8c3486288f3700d526e98 Mon Sep 17 00:00:00 2001 From: Richard Henderson <rth@redhat.com> Date: Tue, 1 Oct 2002 13:49:39 -0700 Subject: [PATCH] calls.c (precompute_register_parameters): Force non-legitimate constants into pseudos. * calls.c (precompute_register_parameters): Force non-legitimate constants into pseudos. * gcc.dg/tls/opt-3.c: New. From-SVN: r57709 --- gcc/ChangeLog | 5 +++++ gcc/calls.c | 6 ++++++ gcc/testsuite/gcc.dg/tls/opt-3.c | 10 ++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tls/opt-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4af6f0fe95fe..a4a53a410a9f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/calls.c b/gcc/calls.c index ffedacabbb05..d706751c1626 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -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 index 000000000000..0e56991400c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tls/opt-3.c @@ -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); +} -- GitLab