+2020-04-02 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/92676
+ * ipa-sra.c (struct caller_issues): New fields candidate and
+ call_from_outside_comdat.
+ (check_for_caller_issues): Check for calls from outsied of
+ candidate's same_comdat_group.
+ (check_all_callers_for_issues): Set up issues.candidate, check result
+ of the new check.
+ (mark_callers_calls_comdat_local): New function.
+ (process_isra_node_results): Set calls_comdat_local of callers if
+ appropriate.
+
2020-04-02 Richard Biener <rguenther@suse.de>
PR c/94392
struct caller_issues
{
+ /* The candidate being considered. */
+ cgraph_node *candidate;
/* There is a thunk among callers. */
bool thunk;
/* Call site with no available information. */
bool unknown_callsite;
+ /* Call from outside the the candidate's comdat group. */
+ bool call_from_outside_comdat;
/* There is a bit-aligned load into one of non-gimple-typed arguments. */
bool bit_aligned_aggregate_argument;
};
thunks. */
return true;
}
+ if (issues->candidate->calls_comdat_local
+ && issues->candidate->same_comdat_group
+ && !issues->candidate->in_same_comdat_group_p (cs->caller))
+ {
+ issues->call_from_outside_comdat = true;
+ return true;
+ }
isra_call_summary *csum = call_sums->get (cs);
if (!csum)
{
struct caller_issues issues;
memset (&issues, 0, sizeof (issues));
+ issues.candidate = node;
node->call_for_symbol_and_aliases (check_for_caller_issues, &issues, true);
if (issues.unknown_callsite)
node->dump_name ());
return true;
}
+ if (issues.call_from_outside_comdat)
+ {
+ if (dump_file)
+ fprintf (dump_file, "Function would become private comdat called "
+ "outside of its comdat group.\n");
+ return true;
+ }
if (issues.bit_aligned_aggregate_argument)
{
}
}
+/* Worker for all call_for_symbol_thunks_and_aliases. Set calls_comdat_local
+ flag of all callers of NODE. */
+
+static bool
+mark_callers_calls_comdat_local (struct cgraph_node *node, void *)
+{
+ for (cgraph_edge *cs = node->callers; cs; cs = cs->next_caller)
+ cs->caller->calls_comdat_local = true;
+ return false;
+}
+
/* Do final processing of results of IPA propagation regarding NODE, clone it
if appropriate. */
= node->create_virtual_clone (callers, NULL, new_adjustments, "isra",
suffix_counter);
suffix_counter++;
- if (node->same_comdat_group)
- new_node->add_to_same_comdat_group (node);
+ if (node->calls_comdat_local && node->same_comdat_group)
+ {
+ new_node->add_to_same_comdat_group (node);
+ new_node->call_for_symbol_and_aliases (mark_callers_calls_comdat_local,
+ NULL, true);
+ }
new_node->calls_comdat_local = node->calls_comdat_local;
if (dump_file)