Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function backtrace(inst::LLVM.Instruction, bt = StackTraces.StackFrame[])
name = replace(something(scope.name, ""), r";$"=>"")
isempty(name) && (name = "unknown")
file = scope.file
path = file === nothing ? "unknown" : joinpath(file.directory, file.filename)
path = file === nothing ? "unknown" :
joinpath(file.directory::Union{Nothing,String},
file.filename::Union{Nothing,String})
line = loc.line
push!(bt, StackTraces.StackFrame(name, path, line))
end
Expand Down
4 changes: 2 additions & 2 deletions src/determinism.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ function dedup_compile_units!(mod::LLVM.Module)
cus = mds["llvm.dbg.cu"].operands
length(cus) <= 1 && return false

canonical = Dict{Tuple,LLVM.Metadata}()
canonical = Dict{Vector{Union{Nothing,LLVM.Metadata}},LLVM.Metadata}()
canonical_cus = LLVM.Metadata[]
replacement = Dict{LLVM.Metadata,LLVM.Metadata}()
for cu in cus
cu === nothing && continue
key = Tuple(cu.operands)
key = Union{Nothing,LLVM.Metadata}[cu.operands...]
canon = get!(canonical, key, cu)
if canon == cu
push!(canonical_cus, cu)
Expand Down
8 changes: 7 additions & 1 deletion src/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ const __llvm_initialized = Ref(false)
# which was loaded in a newer world.
dyn_ir, dyn_meta = @invokelatest deferred_codegen(dyn_job, job)
dyn_entry_fn = dyn_meta.entry.name
merge!(compiled, dyn_meta.compiled)
# the sibling compiler's result isn't inferred
dyn_compiled = dyn_meta.compiled
if dyn_compiled isa Dict{Any,Any}
merge!(compiled, dyn_compiled)
else
Base.inferencebarrier(merge!)(compiled, dyn_compiled)
end
@assert dyn_ir.context == ir.context
link_relocatable!(ir, relocations, dyn_ir,
dyn_meta.relocations)
Expand Down
2 changes: 1 addition & 1 deletion src/irgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ end
# is not passed at the LLVM level.
function classify_arguments(@nospecialize(job::CompilerJob), codegen_ft::LLVM.FunctionType;
post_optimization::Bool=false)
source_sig = job.source.specTypes
source_sig = job.source.specTypes::DataType
source_types = collect(Any, source_sig.parameters)

source_argnames = Base.method_argnames(job.source.def)
Expand Down
4 changes: 2 additions & 2 deletions src/mangling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function mangle_param(@nospecialize(t), substitutions = Any[], top = false)
# check if we already know this base type
str = find_substitution(t.name.wrapper)
if str === nothing
tn = safe_name(t)
tn = safe_name(t)::String
str = "$(length(tn))$tn"
push!(substitutions, t.name.wrapper)
end
Expand Down Expand Up @@ -171,7 +171,7 @@ function mangle_param(@nospecialize(t), substitutions = Any[], top = false)
bits = string(reinterpret(UInt64, t); base=16)
"Ld$(bits)E"
else
tn = safe_name(t) # TODO: actually does support digits...
tn = safe_name(t)::String # TODO: actually does support digits...
if startswith(tn, r"\d")
# C++ classes cannot start with a digit, so mangling doesn't support it
tn = "_$(tn)"
Expand Down
9 changes: 5 additions & 4 deletions src/metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2389,18 +2389,19 @@ function msl_identifier(@nospecialize(T))
str = String(strip(replace(julia_type_words(T), r"[^A-Za-z0-9_]+" => "_"), '_'))
return isempty(str) || isdigit(str[1]) ? "_" * str : str
end
function julia_type_words(@nospecialize(x))
# (recursive, so the result type is declared for inference)
function julia_type_words(@nospecialize(x))::String
if x isa DataType
join([String(nameof(x)); map(julia_type_words, x.parameters)], "_")
join([String(nameof(x)); String[julia_type_words(p) for p in x.parameters]], "_")
elseif x isa Union
# (sorted, as Julia orders union members by module name, which can be generated)
join(["Union"; sort!(map(julia_type_words, Base.uniontypes(x)))], "_")
join(["Union"; sort!(String[julia_type_words(T) for T in Base.uniontypes(x)])], "_")
elseif x isa UnionAll
julia_type_words(Base.unwrap_unionall(x))
elseif x isa TypeVar
String(x.name)
elseif x isa Tuple
join(map(julia_type_words, x), "_")
join(String[julia_type_words(y) for y in x], "_")
elseif x isa Union{Number,Symbol,AbstractChar,AbstractString}
string(x)
else
Expand Down
2 changes: 1 addition & 1 deletion src/relocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end
function resolve_relocation_target(target::CGlobalRef)
if target.library === nothing
# `jl_cglobal` accepts the symbol directly and does the process-wide `jl_dlfind`.
address = ccall(:jl_cglobal, Any, (Any, Any), target.symbol, UInt)
address = ccall(:jl_cglobal, Any, (Any, Any), target.symbol, UInt)::Ptr{UInt}
return unsafe_load(address + target.offset)
end
handle = Libdl.dlopen(target.library)
Expand Down
2 changes: 1 addition & 1 deletion src/rtlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function LLVM.call!(builder, rt::Runtime.RuntimeMethodInstance, args=LLVM.Value[
runtime_function_type(job, rt)
end
LLVM.Function(mod, rt.llvm_name, ft)
end
end::LLVM.Function
ft = f.function_type
if !isdeclaration(f) && (rt.name !== :gc_pool_alloc && rt.name !== :report_exception)
# XXX: uses of the gc_pool_alloc intrinsic can be introduced _after_ the runtime
Expand Down
3 changes: 3 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ end
struct ExternalBackend
library::String # path to the shared library, as exported by its JLL
prefix::String # e.g. "NVPTX" for `NVPTXCompile`

# JLLs are loaded lazily, so the type of their library paths isn't inferred
ExternalBackend(library, prefix) = new(library::String, prefix::String)
end

function api(backend::ExternalBackend, name::String)
Expand Down
1 change: 1 addition & 0 deletions src/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ function emitted_functions(mod::LLVM.Module, compiled)
for entry in values(compiled)
for name in (entry.func, entry.specfunc)
name === nothing && continue
name = name::String # `compiled` holds entries of any type
emitted[name] = entry
# functions may have been renamed since, but not their debug information
f = get(functions, name, nothing)
Expand Down
Loading