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
* [Bug target/94177] TLS global-dynamic model clobbers function parameter on AIX 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 ` dje at gcc dot gnu.org 2021-04-27 16:32 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: dje at gcc dot gnu.org @ 2021-03-09 18:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94177 David Edelsohn <dje at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-03-09 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from David Edelsohn <dje at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/94177] TLS global-dynamic model clobbers function parameter on AIX 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 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-04-27 16:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94177 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Edelsohn <dje@gcc.gnu.org>: https://gcc.gnu.org/g:a21b399708175f6fc0ac723a0cebc127da421c60 commit r12-165-ga21b399708175f6fc0ac723a0cebc127da421c60 Author: David Edelsohn <dje.gcc@gmail.com> Date: Sun Apr 11 19:41:26 2021 -0400 aix: TLS precompute register parameters (PR 94177) AIX uses a compiler-managed TOC for global data, including TLS symbols. The GCC TOC implementation manages the TOC entries through the constant pool. TLS symbols sometimes require a function call to obtain the TLS base pointer. The arguments to the TLS call can conflict with arguments to a normal function call if the TLS symbol is an argument in the normal call. GCC specifically checks for this situation and precomputes the TLS arguments, but the mechanism to check for this requirement utilizes legitimate_constant_p(). The necessary result of legitimate_constant_p() for correct TOC behavior and for correct TLS argument behavior is in conflict. This patch adds a new target hook precompute_tls_p() to decide if an argument should be precomputed regardless of the result from legitmate_constant_p(). gcc/ChangeLog: PR target/94177 * calls.c (precompute_register_parameters): Additionally test targetm.precompute_tls_p to pre-compute argument. * config/rs6000/aix.h (TARGET_PRECOMPUTE_TLS_P): Define. * config/rs6000/rs6000.c (rs6000_aix_precompute_tls_p): New. * target.def (precompute_tls_p): New. * doc/tm.texi.in (TARGET_PRECOMPUTE_TLS_P): Add hook documentation. * doc/tm.texi: Regenerated. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/94177] TLS global-dynamic model clobbers function parameter on AIX 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 3 siblings, 0 replies; 5+ messages in thread From: dje at gcc dot gnu.org @ 2021-04-27 19:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94177 David Edelsohn <dje at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |12.0 --- Comment #3 from David Edelsohn <dje at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/94177] TLS global-dynamic model clobbers function parameter on AIX 2020-03-14 22:59 [Bug target/94177] New: TLS global-dynamic model clobbers function parameter on AIX dje at gcc dot gnu.org ` (2 preceding siblings ...) 2021-04-27 19:01 ` dje at gcc dot gnu.org @ 2021-05-28 20:49 ` cvs-commit at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-05-28 20:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94177 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by David Edelsohn <dje@gcc.gnu.org>: https://gcc.gnu.org/g:0be51abf080f1d7515e3777dd5e5a983b47573a8 commit r11-8481-g0be51abf080f1d7515e3777dd5e5a983b47573a8 Author: David Edelsohn <dje.gcc@gmail.com> Date: Fri Apr 30 14:27:46 2021 -0400 aix: TLS precompute register parameters (PR 94177) AIX uses a compiler-managed TOC for global data, including TLS symbols. The GCC TOC implementation manages the TOC entries through the constant pool. TLS symbols sometimes require a function call to obtain the TLS base pointer. The arguments to the TLS call can conflict with arguments to a normal function call if the TLS symbol is an argument in the normal call. GCC specifically checks for this situation and precomputes the TLS arguments, but the mechanism to check for this requirement utilizes legitimate_constant_p(). The necessary result of legitimate_constant_p() for correct TOC behavior and for correct TLS argument behavior is in conflict. This patch adds a new target hook precompute_tls_p() to decide if an argument should be precomputed regardless of the result from legitmate_constant_p(). gcc/ChangeLog: PR target/94177 * calls.c (precompute_register_parameters): Additionally test targetm.precompute_tls_p to pre-compute argument. * config/rs6000/aix.h (TARGET_PRECOMPUTE_TLS_P): Define. * config/rs6000/rs6000.c (rs6000_aix_precompute_tls_p): New. * target.def (precompute_tls_p): New. * doc/tm.texi.in (TARGET_PRECOMPUTE_TLS_P): Add hook documentation. * doc/tm.texi: Regenerated. (cherry-picked from commit a21b399708175f6fc0ac723a0cebc127da421c60) ^ 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).