https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83945
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Sat Mar 3 13:15:49 2018 New Revision: 258171 URL: https://gcc.gnu.org/viewcvs?rev=258171&root=gcc&view=rev Log: Backported from mainline 2018-01-20 Jakub Jelinek <ja...@redhat.com> PR middle-end/83945 * tree-emutls.c: Include gimplify.h. (lower_emutls_2): New function. (lower_emutls_1): If ADDR_EXPR is a gimple invariant and walk_tree with lower_emutls_2 callback finds some TLS decl in it, unshare_expr it before further processing. * gcc.dg/tls/pr83945.c: New test. Added: branches/gcc-7-branch/gcc/testsuite/gcc.dg/tls/pr83945.c Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/tree-emutls.c