Hi! GCC 7 and earlier had in this spot if (list && loc_list->first->next) gen_llsym (list); where we wanted to force loclist if we've seen more than one NOTE_INSN_VAR_LOCATION for the decl, which means it is not possible to use a block form DW_AT_location.
Alex has changed this to maybe_gen_llsym (list) call, which does: if (!list || (!list->dw_loc_next && !loc_list_has_views (list))) return; gen_llsym (list); This matches what the other caller of gen_llsym did: if (list && list->dw_loc_next) gen_llsym (list); but not the dw_loc_list spot. The difference between the two is (when -gno-variable-location-views) that maybe_gen_llsym will not force loclist form if we transform 2+ NOTE_INSN_VAR_LOCATION notes into a single defined location expression, which can happen e.g. when the first note is some usable location and the second one is <optimized away>. In that case we must use loclist to force the variable to be <optimized away> in the second part of the function, because the first DWARF expression would give wrong results there. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-08 Jakub Jelinek <ja...@redhat.com> PR debug/84456 * dwarf2out.c (dw_loc_list): If list && loc_list->first->next, call gen_llsym, otherwise call maybe_gen_llsym. --- gcc/dwarf2out.c.jj 2018-03-02 00:15:54.704780976 +0100 +++ gcc/dwarf2out.c 2018-03-08 12:54:01.794054675 +0100 @@ -17076,7 +17076,10 @@ dw_loc_list (var_loc_list *loc_list, tre representable, we don't want to pretend a single entry that was applies to the entire scope in which the variable is available. */ - maybe_gen_llsym (list); + if (list && loc_list->first->next) + gen_llsym (list); + else + maybe_gen_llsym (list); return list; } Jakub