https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109304

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Early IPA visibility introduces a local alias (because of
-fno-semantic-interposition).  Local IPA pure-const makes PyUnicode_FindChar
looping pure.
IPA profile instruments the functions, but the .localalias () call remains
pure.

The issue is that node->set_pure_flag uses call_for_symbol_thunks_and_aliases
to apply the adjustments but the call adjustment now no longer updates all
stmts but uses the same guard

        if (!gimple_has_body_p (node->decl)
            || !(!node->clone_of
            || node->decl != node->clone_of->decl))
          continue;

(or rather just gimple_has_body_p), skipping updating the stmt.  For const
calls that would leave the const on the fntype, for pure calls as here
this leaves the call not updated.

We can either restore unconditional updating of all calls or fix the original
issue also for const calls to aliases by adjusting the check.  Maybe like

                /* We do not clear pure/const on decls without body.  */
                tree fndecl = gimple_call_fndecl (call);
                cgraph_node *callee;
                if (fndecl
                    && (callee = cgraph_node::get (fndecl))
                    && callee->get_availability (node) == AVAIL_NOT_AVAILABLE)
                  continue;

that works, but not sure if by design.  Will test that.

Reply via email to