From: Andrew Stubbs Date: Sun, 6 Dec 2020 19:23:55 +0000 (+0000) Subject: Fix offload dwarf info X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27a14054a8a21b994bb91c624f3306dc24a3888b;p=thirdparty%2Fgcc.git Fix offload dwarf info Add a notional code range to the notional parent function of offload kernel functions. This is enough to prevent GDB discarding them. gcc/ChangeLog: * dwarf2out.cc (gen_subprogram_die): Add high/low_pc attributes for parents of offload kernels. --- diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 444d008139dd..4346ea0411c2 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2020-12-06 Andrew Stubbs + + * dwarf2out.cc (gen_subprogram_die): Add high/low_pc attributes for + parents of offload kernels. + 2021-01-13 Julian Brown * doc/tm.texi.in (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Add diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index d7a39944424b..dfdc0426cf1f 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -23755,6 +23755,20 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* We have already generated the labels. */ add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end, false); + + /* Offload kernel functions are nested within a parent function + that doesn't actually exist within the offload object. GDB + will ignore the function and everything nested within unless + we give it a notional code range (the values aren't + important, as long as they are valid). */ + if (flag_generate_offload + && lookup_attribute ("omp target entrypoint", + DECL_ATTRIBUTES (decl)) + && subr_die->die_parent + && subr_die->die_parent->die_tag == DW_TAG_subprogram + && !get_AT_low_pc (subr_die->die_parent)) + add_AT_low_high_pc (subr_die->die_parent, fde->dw_fde_begin, + fde->dw_fde_end, false); } else {