From: Alexander Monakov Date: Wed, 26 Oct 2022 13:37:34 +0000 (+0300) Subject: ipa-visibility: remove assert in TLS optimization [PR107353] X-Git-Tag: basepoints/gcc-14~3698 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82e629c26647313be406c41a01e6868cfad0f289;p=thirdparty%2Fgcc.git ipa-visibility: remove assert in TLS optimization [PR107353] When upgrading TLS access model based on optimized symbol visibility status, we attempted to assert that recomputing the model would not weaken it. It turns out that C, C++, and Fortran front-ends all can (unintentionally) assign a stronger model than what can be derived from the declaration. Let's act conservatively instead of asserting, at least as long as such pre-existing issues remain. gcc/ChangeLog: PR other/107353 * ipa-visibility.cc (function_and_variable_visibility): Conditionally upgrade TLS model instead of asserting. --- diff --git a/gcc/ipa-visibility.cc b/gcc/ipa-visibility.cc index 3ed2b7cf6797..238f7eb84d43 100644 --- a/gcc/ipa-visibility.cc +++ b/gcc/ipa-visibility.cc @@ -886,8 +886,12 @@ function_and_variable_visibility (bool whole_program) && vnode->ref_list.referring.length ()) { enum tls_model new_model = decl_default_tls_model (decl); - gcc_checking_assert (new_model >= decl_tls_model (decl)); - set_decl_tls_model (decl, new_model); + STATIC_ASSERT (TLS_MODEL_GLOBAL_DYNAMIC < TLS_MODEL_LOCAL_DYNAMIC); + STATIC_ASSERT (TLS_MODEL_INITIAL_EXEC < TLS_MODEL_LOCAL_EXEC); + /* We'd prefer to assert that recomputed model is not weaker than + what the front-end assigned, but cannot: see PR 107353. */ + if (new_model >= decl_tls_model (decl)) + set_decl_tls_model (decl, new_model); } } }