Hi, this testcase triggers ICE because we try to inline into -O0 function. Fixed thus.
Bootstrapped/regtested x86_64-linux, comitted. Honza * gcc.c-torture/compile/pr81360.c: New testcase. * ipa-inline.c (can_inline_edge_p): Also check that caller is optimized Index: testsuite/gcc.c-torture/compile/pr81360.c =================================================================== --- testsuite/gcc.c-torture/compile/pr81360.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr81360.c (working copy) @@ -0,0 +1,11 @@ +typedef a; +b(void *c, a d) { + if (c) + e(0, __PRETTY_FUNCTION__); +} +typedef f, g; +__attribute__((optimize(0))) h() { + g i; + b(i, sizeof(f)); +} + Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 254929) +++ ipa-inline.c (working copy) @@ -324,7 +324,8 @@ can_inline_edge_p (struct cgraph_edge *e e->inline_failed = CIF_BODY_NOT_AVAILABLE; inlinable = false; } - if (!early && !opt_for_fn (callee->decl, optimize)) + if (!early && (!opt_for_fn (callee->decl, optimize) + || opt_for_fn (caller->decl, optimize))) { e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED; inlinable = false;