https://github.com/JuliaLang/julia
Revision 6f143eaf241f2f514bce550bf40bba0ed60711f9 authored by Jameson Nash on 11 March 2024, 16:54:11 UTC, committed by GitHub on 11 March 2024, 16:54:11 UTC
Previously, our linetables (similar to LLVM) represented line
information as a linked list from callee via inlined_at up to the
original information. This requires many copies of this information to
be created. Instead we can take advantage of the necessary existence of
the line table from the child to flip this chain of information and
instead make each statement be a table describing (for each IR
instruction):
`(current line number, (index into edges, index into edges statements))`
plus a table of all edges, plus a table with the original line numbers
from the parser, plus the file name. This is all packed into the struct

    struct DebugInfo
        def::Union{Method,MethodInstance,Symbol}
        linetable::Union{Nothing,DebugInfo}
        edges::SimpleVector{DebugInfo}
        codelocs::String
    end

Which is described in doc/src/devdocs/ast.md for what each field means
and look at stacktraces.jl or compiler/ssair/show.jl to look at how to
decode and interpret this information.

For the sysimage, this saves several megabytes (about 113 MB -> 110 MB)
and about 5% of the stdlib pkgimages (294 MB -> 279 MB).

It also now happens to have the full type information for the inlined
functions. Now if you create an `IRShow.DILineInfoPrinter` with
`showtypes=true`, it can print that information when printing IR.

```
julia> @eval Base.IRShow DILineInfoPrinter(debuginfo, def) = DILineInfoPrinter(debuginfo, def, true)
DILineInfoPrinter (generic function with 2 methods)

julia> (@code_typed 1 + 1.0)[1]
CodeInfo(
    @ promotion.jl:425 within `+`
   ┌ invoke MethodInstance for promote(::Int64, ::Float64)
   │ @ promotion.jl:396 within `promote`
   │┌ invoke MethodInstance for Base._promote(::Int64, ::Float64)
   ││ @ promotion.jl:373 within `_promote`
   ││┌ invoke MethodInstance for convert(::Type{Float64}, ::Int64)
   │││ @ number.jl:7 within `convert`
   │││┌ invoke MethodInstance for Float64(::Int64)
   ││││ @ float.jl:221 within `Float64`
1 ─││││ %1 = Base.sitofp(Float64, x)::Float64
│  └└└└
│  ┌ invoke MethodInstance for +(::Float64, ::Float64)
│  │ @ float.jl:460 within `+`
│  │ %2 = Base.add_float(%1, y)::Float64
│  └
└──      return %2
)
```
1 parent 8413b97
History
Tip revision: 6f143eaf241f2f514bce550bf40bba0ed60711f9 authored by Jameson Nash on 11 March 2024, 16:54:11 UTC
invert linetable representation (#52415)
Tip revision: 6f143ea
File Mode Size
.devcontainer
.github
base
cli
contrib
deps
doc
etc
src
stdlib
test
.buildkite-external-version -rw-r--r-- 5 bytes
.clang-format -rw-r--r-- 3.3 KB
.clangd -rw-r--r-- 114 bytes
.codecov.yml -rw-r--r-- 52 bytes
.git-blame-ignore-revs -rw-r--r-- 371 bytes
.gitattributes -rw-r--r-- 65 bytes
.gitignore -rw-r--r-- 571 bytes
.mailmap -rw-r--r-- 12.7 KB
CITATION.bib -rw-r--r-- 513 bytes
CITATION.cff -rw-r--r-- 1012 bytes
CONTRIBUTING.md -rw-r--r-- 23.4 KB
HISTORY.md -rw-r--r-- 388.1 KB
LICENSE.md -rw-r--r-- 1.3 KB
Make.inc -rw-r--r-- 56.1 KB
Makefile -rw-r--r-- 30.3 KB
NEWS.md -rw-r--r-- 3.7 KB
README.md -rw-r--r-- 7.4 KB
THIRDPARTY.md -rw-r--r-- 3.9 KB
VERSION -rw-r--r-- 11 bytes
julia.spdx.json -rw-r--r-- 37.8 KB
pkgimage.mk -rw-r--r-- 1.4 KB
sysimage.mk -rw-r--r-- 4.2 KB
typos.toml -rw-r--r-- 78 bytes

README.md

back to top