From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 154773858D32; Sun, 20 Nov 2022 21:26:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 154773858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668979615; bh=yunkRK2xlJ1nCILPbhfQAjSaAaY8g2xfbfLLWTFx1JY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=omEGFCnsje1n4hf+kDXWm4+wKEvaloRQ1xnbZs8tmL0b6y1ffS1NY+RdJesK9Bfnv BrV5qHGriak2itiEKmLegHjnS/oP71+le+s5cMtCARmB0VYDvTLHnU8uC3DCRsPx+/ 1K/wgZkneiZswFukHvL2T8uiogU0fr3oEeFlJHQ4= From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107661] [13 Regression] lambdas get merged incorrectly in tempaltes, cause llvm-12 miscompilation since r13-3358-ge0403e95689af7 Date: Sun, 20 Nov 2022 21:26:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: blocker X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: jamborm at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107661 --- Comment #13 from Sergei Trofimovich --- (In reply to Sergei Trofimovich from comment #12) > Testing the following: >=20 > --- a/gcc/ipa-cp.cc > +++ b/gcc/ipa-cp.cc > @@ -5869,37 +5869,37 @@ cgraph_edge_brings_all_scalars_for_node (struct > cgraph_edge *cs, > /* Determine whether CS also brings all aggregate values that NODE is > specialized for. */ >=20 > static bool > cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs, > struct cgraph_node *node) > { > ipcp_transformation *ts =3D ipcp_get_transformation_summary (node); > if (!ts || vec_safe_is_empty (ts->m_agg_values)) > return true; >=20 > const ipa_argagg_value_list existing (ts->m_agg_values); > auto_vec edge_values; > ipa_node_params *dest_info =3D ipa_node_params_sum->get (node); > gcc_checking_assert (dest_info->ipcp_orig_node); > dest_info =3D ipa_node_params_sum->get (dest_info->ipcp_orig_node); > push_agg_values_from_edge (cs, dest_info, &edge_values, &existing); > const ipa_argagg_value_list avl (&edge_values); > - return avl.superset_of_p (existing); > + return existing.superset_of_p (avl); > } It was not enough. What I expected: - avl contains: callback_fn_L and callback_fn_R - existing contains: callback_fn_L What I get: - avl contains: callback_fn_L - existing contains: callback_fn_L It seems to have something to do with push_agg_values_from_edge()/push_agg_values_for_index_from_edge() behaviour= of filtering self-recursive lattice values: if (interim && self_recursive_pass_through_p (cs, jfunc, index)) { interim->push_adjusted_values (src_idx, index, unit_delta, res); return; } Here we seem to ignore lattice values discovered on the edges and only copy already encountered values. But we only populate 'interim' with values we specialised the self-recursive call against: push_agg_values_from_edge (cs, dest_info, &edge_values, &existing); ('existing' variable is populated by values caller uses in one location). The following hack seems to fix the test case for me but I suspect it just breaks any self-recursive propagation: --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -5868,35 +5868,35 @@ cgraph_edge_brings_all_scalars_for_node (struct cgraph_edge *cs, /* Determine whether CS also brings all aggregate values that NODE is specialized for. */ static bool cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs, struct cgraph_node *node) { ipcp_transformation *ts =3D ipcp_get_transformation_summary (node); if (!ts || vec_safe_is_empty (ts->m_agg_values)) return true; const ipa_argagg_value_list existing (ts->m_agg_values); auto_vec edge_values; ipa_node_params *dest_info =3D ipa_node_params_sum->get (node); gcc_checking_assert (dest_info->ipcp_orig_node); dest_info =3D ipa_node_params_sum->get (dest_info->ipcp_orig_node); - push_agg_values_from_edge (cs, dest_info, &edge_values, &existing); + push_agg_values_from_edge (cs, dest_info, &edge_values, NULL); const ipa_argagg_value_list avl (&edge_values); return avl.superset_of_p (existing); }=