@@ -189,7 +189,7 @@ mutable struct DebugInfoStream
189189 end
190190 # DebugInfoStream(def::Union{MethodInstance,Nothing}, di::DebugInfo, nstmts::Int) =
191191 # if debuginfo_file1(di.def) === debuginfo_file1(di.def)
192- # new(def, di.linetable, Core.svec(di.edges...), getdebugidx(di, 0),
192+ # new(def, di.linetable, Core.svec(di.edges...), getdebugidx(di, 0)[1] ,
193193 # ccall(:jl_uncompress_codelocs, Any, (Any, Int), di.codelocs, nstmts)::Vector{Int32})
194194 # else
195195 function DebugInfoStream (def:: Union{MethodInstance,Nothing} , di:: DebugInfo , nstmts:: Int )
@@ -206,15 +206,37 @@ Core.DebugInfo(di::DebugInfoStream, nstmts::Int) =
206206 Core. DebugInfo (something (di. def), di. linetable, Core. svec (di. edges... ),
207207 ccall (:jl_compress_codelocs , Any, (Int32, Any, Int), di. firstline, di. codelocs, nstmts):: String )
208208
209- getdebugidx (debuginfo:: Core.DebugInfo , pc:: Int ) = ccall (:jl_uncompress1_codeloc , NTuple{3 ,Int32}, (Any, Int), debuginfo. codelocs, pc)
209+ struct DebugCodeLoc
210+ line:: Int32
211+ edge:: Int32
212+ edge_line:: Int32
213+ end
214+ function getindex (dcl:: DebugCodeLoc , idx:: Int )
215+ if idx == 1
216+ return dcl. line
217+ elseif idx == 2
218+ return dcl. edge
219+ elseif idx == 3
220+ return dcl. edge_line
221+ else
222+ throw (BoundsError (dcl, idx))
223+ end
224+ end
225+ function iterate (dcl:: DebugCodeLoc , i:: Int = 1 )
226+ i > 3 && return nothing
227+ return getfield (dcl, i), i+ 1
228+ end
229+
230+ getdebugidx (debuginfo:: Core.DebugInfo , pc:: Int ) = DebugCodeLoc (
231+ ccall (:jl_uncompress1_codeloc , NTuple{3 ,Int32}, (Any, Int), debuginfo. codelocs, pc)... )
210232
211233function getdebugidx (debuginfo:: DebugInfoStream , pc:: Int )
212234 if 3 <= 3 pc <= length (debuginfo. codelocs)
213- return (debuginfo. codelocs[3 pc - 2 ], debuginfo. codelocs[3 pc - 1 ], debuginfo. codelocs[3 pc - 0 ])
235+ return DebugCodeLoc (debuginfo. codelocs[3 pc - 2 ], debuginfo. codelocs[3 pc - 1 ], debuginfo. codelocs[3 pc - 0 ])
214236 elseif pc == 0
215- return ( Int32 ( debuginfo. firstline), Int32 ( 0 ), Int32 ( 0 ) )
237+ return DebugCodeLoc ( debuginfo. firstline, 0 , 0 )
216238 else
217- return ( Int32 ( - 1 ), Int32 ( 0 ), Int32 ( 0 ) )
239+ return DebugCodeLoc ( - 1 , 0 , 0 )
218240 end
219241end
220242
@@ -310,15 +332,15 @@ Instruction(is::InstructionStream) = Instruction(is, add_new_idx!(is))
310332 isdefined (node, fld) && return getfield (node, fld)
311333 fldarray = getfield (getfield (node, :data ), fld)
312334 fldidx = getfield (node, :idx )
313- (fld === :line ) && return (fldarray[3 fldidx- 2 ], fldarray[3 fldidx- 1 ], fldarray[3 fldidx- 0 ])
335+ (fld === :line ) && return DebugCodeLoc (fldarray[3 fldidx- 2 ], fldarray[3 fldidx- 1 ], fldarray[3 fldidx- 0 ])
314336 return fldarray[fldidx]
315337end
316338@inline function setindex! (node:: Instruction , @nospecialize (val), fld:: Symbol )
317339 (fld === :inst ) && (fld = :stmt ) # deprecated
318340 fldarray = getfield (getfield (node, :data ), fld)
319341 fldidx = getfield (node, :idx )
320342 if fld === :line
321- (fldarray[3 fldidx- 2 ], fldarray[3 fldidx- 1 ], fldarray[3 fldidx- 0 ]) = val:: NTuple{3,Int32}
343+ (fldarray[3 fldidx- 2 ], fldarray[3 fldidx- 1 ], fldarray[3 fldidx- 0 ]) = val:: DebugCodeLoc
322344 else
323345 fldarray[fldidx] = val
324346 end
@@ -370,31 +392,31 @@ struct NewInstruction
370392 stmt:: Any
371393 type:: Any
372394 info:: CallInfo
373- line:: Union{NTuple{3,Int32} ,Nothing} # if nothing, copy the line from previous statement in the insertion location
395+ line:: Union{DebugCodeLoc ,Nothing} # if nothing, copy the line from previous statement in the insertion location
374396 flag:: Union{UInt32,Nothing} # if nothing, IR flags will be recomputed on insertion
375397 function NewInstruction (@nospecialize (stmt), @nospecialize (type), @nospecialize (info:: CallInfo ),
376- line:: Union{NTuple{3,Int32} ,Int32,Nothing} , flag:: Union{UInt32,Nothing} )
377- line isa Int32 && (line = (line, zero (Int32), zero (Int32) ))
398+ line:: Union{DebugCodeLoc ,Int32,Nothing} , flag:: Union{UInt32,Nothing} )
399+ line isa Int32 && (line = DebugCodeLoc (line, 0 , 0 ))
378400 return new (stmt, type, info, line, flag)
379401 end
380402end
381- function NewInstruction (@nospecialize (stmt), @nospecialize (type), line:: Union{NTuple{3,Int32} ,Int32,Nothing} = nothing )
403+ function NewInstruction (@nospecialize (stmt), @nospecialize (type), line:: Union{DebugCodeLoc ,Int32,Nothing} = nothing )
382404 return NewInstruction (stmt, type, NoCallInfo (), line, nothing )
383405end
384406@nospecialize
385407function NewInstruction (newinst:: NewInstruction ;
386408 stmt:: Any = newinst. stmt,
387409 type:: Any = newinst. type,
388410 info:: CallInfo = newinst. info,
389- line:: Union{NTuple{3,Int32} ,Int32,Nothing} = newinst. line,
411+ line:: Union{DebugCodeLoc ,Int32,Nothing} = newinst. line,
390412 flag:: Union{UInt32,Nothing} = newinst. flag)
391413 return NewInstruction (stmt, type, info, line, flag)
392414end
393415function NewInstruction (inst:: Instruction ;
394416 stmt:: Any = inst[:stmt ],
395417 type:: Any = inst[:type ],
396418 info:: CallInfo = inst[:info ],
397- line:: Union{NTuple{3,Int32} ,Int32,Nothing} = inst[:line ],
419+ line:: Union{DebugCodeLoc ,Int32,Nothing} = inst[:line ],
398420 flag:: Union{UInt32,Nothing} = inst[:flag ])
399421 return NewInstruction (stmt, type, info, line, flag)
400422end
@@ -939,7 +961,7 @@ function add_pending!(compact::IncrementalCompact, pos::Int, attach_after::Bool)
939961end
940962
941963function inst_from_newinst! (node:: Instruction , newinst:: NewInstruction ,
942- newline:: NTuple{3,Int32} = newinst. line:: NTuple{3,Int32} , newflag:: UInt32 = newinst. flag:: UInt32 )
964+ newline:: DebugCodeLoc = newinst. line:: DebugCodeLoc , newflag:: UInt32 = newinst. flag:: UInt32 )
943965 node[:stmt ] = newinst. stmt
944966 node[:type ] = newinst. type
945967 node[:info ] = newinst. info
@@ -1029,7 +1051,7 @@ function maybe_reopen_bb!(compact)
10291051end
10301052
10311053function insert_node_here! (compact:: IncrementalCompact , newinst:: NewInstruction , reverse_affinity:: Bool = false )
1032- newline = newinst. line:: NTuple{3,Int32}
1054+ newline = newinst. line:: DebugCodeLoc
10331055 refinish = false
10341056 result_idx = compact. result_idx
10351057 result_bbs = compact. cfg_transform. result_bbs
@@ -1671,7 +1693,7 @@ function resize!(compact::IncrementalCompact, nnewnodes::Int)
16711693 return compact
16721694end
16731695
1674- const NoLineUpdate = ( Int32 ( 0 ), Int32 ( 0 ), Int32 ( 0 ) )
1696+ const NoLineUpdate = DebugCodeLoc ( 0 , 0 , 0 )
16751697
16761698function finish_current_bb! (compact:: IncrementalCompact , active_bb:: Int ,
16771699 old_result_idx:: Int = compact. result_idx, unreachable:: Bool = false )
0 commit comments