https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100467

--- Comment #3 from Bernd Edlinger <edlinger at gcc dot gnu.org> ---
Okay, after some debugging I see the problem.

Usually thunks are emitted from ymtab-thunks.cc:

      cfun->is_thunk = 1;
      insn_locations_init ();
      set_curr_insn_location (DECL_SOURCE_LOCATION (thunk_fndecl));
      prologue_location = curr_insn_location ();

      targetm.asm_out.output_mi_thunk (asm_out_file, thunk_fndecl,
                                       fixed_offset, virtual_value, alias);


the only other place where prologue_location is set
is in cfgexpand.c:

  if (!DECL_IS_UNDECLARED_BUILTIN (current_function_decl))
    {
      /* Eventually, all FEs should explicitly set function_start_locus.  */
      if (LOCATION_LOCUS (fun->function_start_locus) == UNKNOWN_LOCATION)
        set_curr_insn_location
          (DECL_SOURCE_LOCATION (current_function_decl));
      else
        set_curr_insn_location (fun->function_start_locus);
    }
  else
    set_curr_insn_location (UNKNOWN_LOCATION);
  prologue_location = curr_insn_location ();


BUT this special "thunk" is emitted from toplev.c:

      /* This must be at the end before unwind and debug info.
         Some target ports emit PIC setup thunks here.  */
      targetm.asm_out.code_end ();

and here the prologue_location is not initialized, also the backend
does not know about it's significance.

So the source line number for this thunk is indeed wrong.

Reply via email to