Hi! The following C testcase shows how profiledbootstrap fails with checking compiler. We have a (nested) FUNCTION_DECL inside of BLOCK_VARS of an inline function, when it gets inlined, it is moved into BLOCK_NONLOCALIZED_VARS. And, decls_for_scope calls process_scope_var with NULL decl and non-NULL origin for all BLOCK_NONLOCALIZED_VARS. That is fine for variables, but for FUNCTION_DECLs it can actually try to dwarf2out_abstract_function that FUNCTION_DECL, which should be really done only when it is inlined (i.e. BLOCK_ABSTRACT_ORIGIN of some BLOCK). The effect is that we actually add DW_AT_inline attribute to that DW_TAG_subroutine, and then later when processing it again we add DW_AT_low_pc etc. and ICE, because those attributes should not appear on DW_AT_inline functions.
Fixed by handling FUNCTION_DECLs always the same, whether in BLOCK_VARS or BLOCK_NONLOCALIZED_VARS. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-03-23 Jakub Jelinek <ja...@redhat.com> PR debug/79255 * dwarf2out.c (decls_for_scope): If BLOCK_NONLOCALIZED_VAR is a FUNCTION_DECL, pass it as decl instead of origin to process_scope_var. * gcc.dg/pr79255.c: New test. --- gcc/dwarf2out.c.jj 2017-03-22 19:31:41.525055795 +0100 +++ gcc/dwarf2out.c 2017-03-23 17:57:09.419362739 +0100 @@ -24861,8 +24861,13 @@ decls_for_scope (tree stmt, dw_die_ref c if we've done it once already. */ if (! early_dwarf) for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++) - process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i), - context_die); + { + decl = BLOCK_NONLOCALIZED_VAR (stmt, i); + if (TREE_CODE (decl) == FUNCTION_DECL) + process_scope_var (stmt, decl, NULL_TREE, context_die); + else + process_scope_var (stmt, NULL_TREE, decl, context_die); + } } /* Even if we're at -g1, we need to process the subblocks in order to get --- gcc/testsuite/gcc.dg/pr79255.c.jj 2017-03-23 17:57:44.711911298 +0100 +++ gcc/testsuite/gcc.dg/pr79255.c 2017-03-23 17:56:24.000000000 +0100 @@ -0,0 +1,21 @@ +/* PR bootstrap/79255 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fno-toplevel-reorder -Wno-attributes" } */ + +static inline __attribute__((always_inline)) int foo (int x); + +int +baz (void) +{ + return foo (3) + foo (6) + foo (9); +} + +static inline __attribute__((always_inline)) int +foo (int x) +{ + auto inline int __attribute__((noinline)) bar (int x) + { + return x + 3; + } + return bar (x) + bar (x + 2); +} Jakub