public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/94177] New: TLS global-dynamic model clobbers function parameter on AIX
@ 2020-03-14 22:59 dje at gcc dot gnu.org
  2021-03-09 18:11 ` [Bug target/94177] " dje at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dje at gcc dot gnu.org @ 2020-03-14 22:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94177

            Bug ID: 94177
           Summary: TLS global-dynamic model clobbers function parameter
                    on AIX
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dje at gcc dot gnu.org
  Target Milestone: ---
            Target: powerpc-ibm-aix*

In global-dynamic model, if a TLS variable first is referenced in the argument
list to a function call, GCC can load the parameters to the call before
invoking the function to legitimize the TLS variable, and the legitimize
function clobbers some of the same function argument registers.

extern int foo (char *, int *, int);

int main()
{
   static __thread int result;

   foo ("%p %u\n", &result, 169);
   return 0;
}

$ gcc -fPIC -S bug_tls.c
        li 5,169
        lwz 10,LCM..1(2)
        lwz 9,LC..1(2)
        mr 3,10
        mr 4,9
        bla __tls_get_addr <*** clobbers r4, r5 already loaded with arguments
to foo
        mr 9,3
        mr 4,9
        lwz 3,LC..2(2)
        bl .foo


The pattern that generates __tls_get_addr shows that it clobbers r4 and r5

(define_insn "tls_get_addr_internal<mode>"
  [(set (reg:P 3)
        (unspec:P [(reg:P 3) (reg:P 4)] UNSPEC_TLSTLS))
   (clobber (reg:P 0))
   (clobber (reg:P 4))
   (clobber (reg:P 5))
   (clobber (reg:P 11))
   (clobber (reg:CC CR0_REGNO))
   (clobber (reg:P LR_REGNO))]
  "TARGET_XCOFF && HAVE_AS_TLS"
  "bla __tls_get_addr")

but GCC overwrites the parameters in calls.c during initial RTL generation.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-28 20:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 22:59 [Bug target/94177] New: TLS global-dynamic model clobbers function parameter on AIX dje at gcc dot gnu.org
2021-03-09 18:11 ` [Bug target/94177] " dje at gcc dot gnu.org
2021-04-27 16:32 ` cvs-commit at gcc dot gnu.org
2021-04-27 19:01 ` dje at gcc dot gnu.org
2021-05-28 20:49 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).