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
20 changes: 14 additions & 6 deletions src/irgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function irgen(@nospecialize(job::CompilerJob))
EnumAttribute("sspstrong", 0))
end

delete!(function_attributes(llvmf),
StringAttribute("probe-stack", "inline-asm"))

if Sys.iswindows()
personality!(llvmf, nothing)
end
Expand Down Expand Up @@ -261,29 +264,34 @@ end

function classify_arguments(@nospecialize(job::CompilerJob), codegen_ft::LLVM.FunctionType)
source_sig = job.source.specTypes

source_types = [source_sig.parameters...]

source_argnames = Base.method_argnames(job.source.def)
while length(source_argnames) < length(source_types)
# this is probably due to a trailing vararg; repeat its name
push!(source_argnames, source_argnames[end])
end

codegen_types = parameters(codegen_ft)

args = []
codegen_i = 1
for (source_i, source_typ) in enumerate(source_types)
for (source_i, (source_typ, source_name)) in enumerate(zip(source_types, source_argnames))
if isghosttype(source_typ) || Core.Compiler.isconstType(source_typ)
push!(args, (cc=GHOST, typ=source_typ))
push!(args, (cc=GHOST, typ=source_typ, name=source_name))
continue
end

codegen_typ = codegen_types[codegen_i]
if codegen_typ isa LLVM.PointerType && !issized(eltype(codegen_typ))
push!(args, (cc=MUT_REF, typ=source_typ,
push!(args, (cc=MUT_REF, typ=source_typ, name=source_name,
codegen=(typ=codegen_typ, i=codegen_i)))
elseif codegen_typ isa LLVM.PointerType && issized(eltype(codegen_typ)) &&
!(source_typ <: Ptr) && !(source_typ <: Core.LLVMPtr)
push!(args, (cc=BITS_REF, typ=source_typ,
push!(args, (cc=BITS_REF, typ=source_typ, name=source_name,
codegen=(typ=codegen_typ, i=codegen_i)))
else
push!(args, (cc=BITS_VALUE, typ=source_typ,
push!(args, (cc=BITS_VALUE, typ=source_typ, name=source_name,
codegen=(typ=codegen_typ, i=codegen_i)))
end
codegen_i += 1
Expand Down
6 changes: 6 additions & 0 deletions src/metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,12 @@ function add_argument_metadata!(@nospecialize(job::CompilerJob), mod::LLVM.Modul
push!(md, MDString("air.arg_type_align_size"))
push!(md, Metadata(ConstantInt(Int32(Base.datatype_alignment(arg_type)))))

push!(md, MDString("air.arg_type_name"))
push!(md, MDString(repr(arg.typ)))

push!(md, MDString("air.arg_name"))
push!(md, MDString(String(arg.name)))

push!(arg_infos, MDNode(md))

i += 1
Expand Down