https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128825
Adam Willis <return.of.octobot at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |return.of.octobot at gmail dot
com
--- Comment #4 from Adam Willis <return.of.octobot at gmail dot com> ---
The NULL dereference is in ipa_get_callee_param_type, called from the code
r17-6284-g610d42e09ff844 added to update_jump_functions_after_inlining. That
code asks for a parameter type whenever it folds an IPA_JF_CONST into an
IPA_JF_ANCESTOR jump function, and it does so for every outgoing edge of the
inlined callee, indirect edges included. For an edge without a callee,
ipa_get_callee_param_type uses gimple_call_fntype (e->call_stmt), but at WPA
the bodies aren't loaded and call_stmt is NULL.
Smaller C reproducer (an indirect call passed ¶m->member, in a function
inlined at WPA into a caller that passes a constant address):
$ cat t_0.c
struct S { long pad; int y; };
extern void (*fp) (const int *);
extern void call (const struct S *);
static const struct S cs = { 1, 2 };
static int seen;
static void check (const int *p) { seen = *p; }
int main (void) { fp = check; call (&cs); if (seen != 2) __builtin_abort ();
return 0; }
$ cat t_1.c
struct S { long pad; int y; };
void (*fp) (const int *);
void call (const struct S *s) { fp (&s->y); }
$ gcc -O2 -flto t_0.c t_1.c
during IPA pass: inline
lto1: internal compiler error: Segmentation fault
... ipa_get_callee_param_type(cgraph_edge*, int)
... ipa_propagate_indirect_call_infos(cgraph_edge*, vec<cgraph_edge*, va_heap,
vl_ptr>*)
... inline_call(cgraph_edge*, bool, vec<cgraph_edge*, va_heap, vl_ptr>*, int*,
bool, bool*)
Returning NULL from ipa_get_callee_param_type when the edge has neither a
callee nor a call statement fixes it. The caller already handles an unknown
type (as for a callee without a prototype), and IPA-CP checks the value
against the eventual callee's parameter type before using it. Patch posted
to gcc-patches:
https://inbox.sourceware.org/gcc-patches/[email protected]/