In PR ipa/96291 the test contained an SCC with one
unoptimized function. This tricked ipa-cp into NULL dereference.
has_undead_caller_from_outside_scc_p() did not take into account
that unoptimized funtions don't have IPA summary analysis. And
dereferenced NULL pointer causing an ICE.
gcc/
PR ipa/96291
* ipa-cp.c (has_undead_caller_from_outside_scc_p): Consider
unoptimized callers as undead.
gcc/testsuite/
PR ipa/96291
* gcc.dg/lto/pr96291_0.c: New testcase.
* gcc.dg/lto/pr96291_1.c: Support file.
* gcc.dg/lto/pr96291_2.c: Likewise.
* gcc.dg/lto/pr96291.h: Likewise.
(has_undead_caller_from_outside_scc_p, NULL, true))
return true;
else if (!ipa_edge_within_scc (cs)
- && !IPA_NODE_REF (cs->caller)->node_dead)
- return true;
+ && (!IPA_NODE_REF (cs->caller) /* Unoptimized caller. */
+ || !IPA_NODE_REF (cs->caller)->node_dead))
+ return true;
return false;
}
--- /dev/null
+void e(void);
+void f(void);
+void a(void *, void *);
+void c(int);
--- /dev/null
+/* { dg-lto-do link } */
+
+#include "pr96291.h"
+
+static void * b;
+void c(int d) {
+ f();
+ a(b, b);
+}
+
+void e(void) { c(0); }
--- /dev/null
+#include "pr96291.h"
+
+void f(void) { c(0); }
--- /dev/null
+/* { dg-options {-O0} } */
+
+#include "pr96291.h"
+
+void a(void * a1, void * a2) { e(); }
+
+int main(){}