https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121352
--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> --- That patch deliberately takes care not to optimize in presence of the attribute: /* Upgrade TLS access model based on optimized visibility status, unless it was specified explicitly or no references remain. */ if (DECL_THREAD_LOCAL_P (decl) && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)) && vnode->ref_list.referring.length ()) {