Do not call null register_common in emutls
authorAlexandre Oliva <oliva@adacore.com>
Mon, 17 Feb 2020 20:08:11 +0000 (17:08 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Mon, 17 Feb 2020 20:08:11 +0000 (17:08 -0300)
commit96bae436e0cb2b3e14ea7f16854e1b535a72ca66
treeadd8279bb9b95dc60a2acd439ae488277b67df5e
parentbc0f8df124f6ee12c82c5a6c1335868a15bcaecb
Do not call null register_common in emutls

Thread-local variables with DECL_COMMON trigger an internal compiler
error on targets that use emulated TLS without register_common, when
we attempt to expand a call to the NULL register_common, with
testcases as simple as gcc.dg/tls/emutls-2.c.

The documentation states that, on such targets, common variables would
fall back to explicitly initialized.  This patch rearranges the code
that deals with initialization of common and non-common variables,
complementing code that is already in place to detect
register_common-less targets.

for  gcc/ChangeLog

* tree-emutls.c (new_emutls_decl, emutls_common_1): Complete
handling of register_common-less targets.

for  gcc/testsuite/ChangeLog

* gcc.dg/tls/emutls-3.c: New, combining emutls-2.c and
thr-init-2.c into an execution test with explicitly common
variables.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tls/emutls-3.c [new file with mode: 0644]
gcc/tree-emutls.c