diff --git a/src/irgen.jl b/src/irgen.jl index ca3f21cf..1a461110 100644 --- a/src/irgen.jl +++ b/src/irgen.jl @@ -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 @@ -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 diff --git a/src/metal.jl b/src/metal.jl index b0b37633..a1025319 100644 --- a/src/metal.jl +++ b/src/metal.jl @@ -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