@@ -8657,6 +8657,7 @@ static jl_llvm_functions_t
86578657 DebugLoc loc;
86588658 StringRef file;
86598659 ssize_t line;
8660+ ssize_t line0; // if this represents pc=1, then also cover the entry to the function (pc=0)
86608661 bool is_user_code;
86618662 int32_t edgeid;
86628663 bool sameframe (const DebugLineTable &other) const {
@@ -8667,12 +8668,12 @@ static jl_llvm_functions_t
86678668 DebugLineTable topinfo;
86688669 topinfo.file = ctx.file ;
86698670 topinfo.line = toplineno;
8671+ topinfo.line0 = 0 ;
86708672 topinfo.is_user_code = mod_is_user_mod;
86718673 topinfo.loc = topdebugloc;
86728674 topinfo.edgeid = 0 ;
86738675 std::map<std::tuple<StringRef, StringRef>, DISubprogram*> subprograms;
86748676 SmallVector<DebugLineTable, 0 > prev_lineinfo, new_lineinfo;
8675- new_lineinfo.push_back (topinfo);
86768677 auto update_lineinfo = [&] (size_t pc) {
86778678 std::function<bool (jl_debuginfo_t *, jl_value_t *, size_t , size_t )> append_lineinfo =
86788679 [&] (jl_debuginfo_t *debuginfo, jl_value_t *func, size_t to, size_t pc) -> bool {
@@ -8699,6 +8700,13 @@ static jl_llvm_functions_t
86998700 modu = ctx.module ;
87008701 info.file = jl_debuginfo_file1 (debuginfo);
87018702 info.line = i;
8703+ info.line0 = 0 ;
8704+ if (pc == 1 ) {
8705+ struct jl_codeloc_t lineidx = jl_uncompress1_codeloc (debuginfo->codelocs , 0 );
8706+ assert (lineidx.to == 0 && lineidx.pc == 0 );
8707+ if (lineidx.line > 0 && info.line != lineidx.line )
8708+ info.line0 = lineidx.line ;
8709+ }
87028710 if (info.file .empty ())
87038711 info.file = " <missing>" ;
87048712 if (modu == ctx.module )
@@ -8867,8 +8875,11 @@ static jl_llvm_functions_t
88678875 for (; dbg < new_lineinfo.size (); dbg++) {
88688876 const auto &newdbg = new_lineinfo[dbg];
88698877 bool is_tracked = in_tracked_path (newdbg.file );
8870- if (do_coverage (newdbg.is_user_code , is_tracked))
8878+ if (do_coverage (newdbg.is_user_code , is_tracked)) {
8879+ if (newdbg.line0 != 0 && (dbg >= prev_lineinfo.size () || newdbg.edgeid != prev_lineinfo[dbg].edgeid || newdbg.line0 != prev_lineinfo[dbg].line ))
8880+ coverageVisitLine (ctx, newdbg.file , newdbg.line0 );
88718881 coverageVisitLine (ctx, newdbg.file , newdbg.line );
8882+ }
88728883 }
88738884 };
88748885 auto mallocVisitStmt = [&] (Value *sync, bool have_dbg_update) {
@@ -8908,18 +8919,8 @@ static jl_llvm_functions_t
89088919 struct jl_codeloc_t lineidx = jl_uncompress1_codeloc (debuginfo->codelocs , pc);
89098920 if (lineidx.line == -1 )
89108921 break ;
8911- jl_debuginfo_t *linetable = debuginfo->linetable ;
8912- while (lineidx.line >= 0 && (jl_value_t *)linetable != jl_nothing) {
8913- if (lineidx.line == 0 ) {
8914- lineidx = jl_uncompress1_codeloc (linetable->codelocs , lineidx.line );
8915- break ;
8916- }
8917- lineidx = jl_uncompress1_codeloc (linetable->codelocs , lineidx.line );
8918- linetable = linetable->linetable ;
8919- }
8920- if (lineidx.line > 0 ) {
8922+ if (lineidx.line > 0 )
89218923 jl_coverage_alloc_line (file, lineidx.line );
8922- }
89238924 }
89248925 }
89258926 };
@@ -8975,12 +8976,12 @@ static jl_llvm_functions_t
89758976 BB[label] = bb;
89768977 }
89778978
8979+ new_lineinfo.push_back (topinfo);
89788980 Value *sync_bytes = nullptr ;
89798981 if (do_malloc_log (true , mod_is_tracked))
89808982 sync_bytes = ctx.builder .CreateCall (prepare_call (diff_gc_total_bytes_func), {});
8981- // coverage for the function definition line number
8982- if (do_coverage (topinfo.is_user_code , mod_is_tracked))
8983- coverageVisitLine (ctx, topinfo.file , topinfo.line );
8983+ // coverage for the function definition line number (topinfo)
8984+ coverageVisitStmt ();
89848985
89858986 find_next_stmt (0 );
89868987 while (cursor != -1 ) {
0 commit comments