On Wed, 10 Sep 2025, Alexander Monakov wrote:
> Sorry, I think this comment is more confusing than helpful. As mentioned
> before,
> decl_default_tls_model does not scan the attribute list, and may return a
> weaker
> model than the attribute. If there was no attribute, we can expect that
> recomputed model is never weaker. Can you put it in code like this, please:
>
> old_model = decl_tls_model (decl);
> if (CHECKING_P
> && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)))
> gcc_assert (new_model >= old_model);
>
> Thanks.
> Alexander
>
> > if (new_model >= decl_tls_model (decl))
> > set_decl_tls_model (decl, new_model);
> > }
Oh, actually the assert can go in the 'else' of the existing 'if':
if (new_model >= decl_tls_model (decl))
set_decl_tls_model (decl, new_model);
else
{
tree attrs = DECL_ATTRIBUTES (decl);
gcc_checking_assert (lookup_attribute ("tls_model", attrs));
}