Dominic P <[email protected]> writes: > Since r17-6284, update_jump_functions_after_inlining calls > ipa_get_callee_param_type for the outgoing edges of an inlined callee. > For an indirect edge during LTO WPA there is neither a callee nor a call > statement, and gimple_call_fntype dereferences a null pointer. Return > NULL there, as for an unknown parameter type; the caller then folds the > constant without converting it. > > Bootstrapped and regression tested on x86_64-pc-linux-gnu. > > Assisted-by: Claude Opus 5.5 (Anthropic)
We have https://inbox.sourceware.org/gcc-patches/[email protected]/ too (PR128825). > > gcc/ChangeLog: > > * ipa-prop.cc (ipa_get_callee_param_type): Return NULL for an > edge with neither a callee nor a call statement. > > gcc/testsuite/ChangeLog: > > * gcc.dg/lto/ipa-ancestor-indirect_0.c: New test. > * gcc.dg/lto/ipa-ancestor-indirect_1.c: New test. > > Signed-off-by: Dominic P <[email protected]> > --- > The same applies to the new caller in "Extend ipa-prop/ipa-cp to handle > constants with uknown offsets": > https://gcc.gnu.org/pipermail/gcc-patches/2026-November/739221.html > > OK for trunk? > > gcc/ipa-prop.cc | 3 ++ > .../gcc.dg/lto/ipa-ancestor-indirect_0.c | 28 +++++++++++++++++++ > .../gcc.dg/lto/ipa-ancestor-indirect_1.c | 8 ++++++ > 3 files changed, 39 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_0.c > create mode 100644 gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_1.c > > diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc > index 61b2dbd5d6b..77c7e930efc 100644 > --- a/gcc/ipa-prop.cc > +++ b/gcc/ipa-prop.cc > @@ -2529,6 +2529,9 @@ tree > ipa_get_callee_param_type (struct cgraph_edge *e, int i) > { > int n; > + > + if (!e->callee && !e->call_stmt) > + return NULL; > tree type = (e->callee > ? TREE_TYPE (e->callee->decl) > : gimple_call_fntype (e->call_stmt)); > diff --git a/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_0.c > b/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_0.c > new file mode 100644 > index 00000000000..5e9c614a805 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_0.c > @@ -0,0 +1,28 @@ > +/* { dg-lto-do link } */ > +/* { dg-lto-options { { -O2 -flto } } } */ > + > +struct A { int v; }; > +struct B { int x; struct A a; }; > + > +void f (struct B *, void (*) (struct A *)); > +struct B gb; > + > +void > +caller (void (*fp) (struct A *)) > +{ > + f (&gb, fp); > +} > + > +static void > +g (struct A *a) > +{ > + a->v = 1; > +} > + > +int > +main (void) > +{ > + void (*volatile vp) (struct A *) = g; > + caller (vp); > + return 0; > +} > diff --git a/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_1.c > b/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_1.c > new file mode 100644 > index 00000000000..d8420c3551d > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/lto/ipa-ancestor-indirect_1.c > @@ -0,0 +1,8 @@ > +struct A { int v; }; > +struct B { int x; struct A a; }; > + > +void > +f (struct B *b, void (*fp) (struct A *)) > +{ > + fp (&b->a); > +}
signature.asc
Description: PGP signature
