Skip to content

Commit 0c7b467

Browse files
authored
Merge pull request #518 from JuliaGPU/tb/metal_name_md
Metal: Emit name metadata.
2 parents a607fd5 + ac9ee33 commit 0c7b467

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/irgen.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ function irgen(@nospecialize(job::CompilerJob))
1818
EnumAttribute("sspstrong", 0))
1919
end
2020

21+
delete!(function_attributes(llvmf),
22+
StringAttribute("probe-stack", "inline-asm"))
23+
2124
if Sys.iswindows()
2225
personality!(llvmf, nothing)
2326
end
@@ -261,29 +264,34 @@ end
261264

262265
function classify_arguments(@nospecialize(job::CompilerJob), codegen_ft::LLVM.FunctionType)
263266
source_sig = job.source.specTypes
264-
265267
source_types = [source_sig.parameters...]
266268

269+
source_argnames = Base.method_argnames(job.source.def)
270+
while length(source_argnames) < length(source_types)
271+
# this is probably due to a trailing vararg; repeat its name
272+
push!(source_argnames, source_argnames[end])
273+
end
274+
267275
codegen_types = parameters(codegen_ft)
268276

269277
args = []
270278
codegen_i = 1
271-
for (source_i, source_typ) in enumerate(source_types)
279+
for (source_i, (source_typ, source_name)) in enumerate(zip(source_types, source_argnames))
272280
if isghosttype(source_typ) || Core.Compiler.isconstType(source_typ)
273-
push!(args, (cc=GHOST, typ=source_typ))
281+
push!(args, (cc=GHOST, typ=source_typ, name=source_name))
274282
continue
275283
end
276284

277285
codegen_typ = codegen_types[codegen_i]
278286
if codegen_typ isa LLVM.PointerType && !issized(eltype(codegen_typ))
279-
push!(args, (cc=MUT_REF, typ=source_typ,
287+
push!(args, (cc=MUT_REF, typ=source_typ, name=source_name,
280288
codegen=(typ=codegen_typ, i=codegen_i)))
281289
elseif codegen_typ isa LLVM.PointerType && issized(eltype(codegen_typ)) &&
282290
!(source_typ <: Ptr) && !(source_typ <: Core.LLVMPtr)
283-
push!(args, (cc=BITS_REF, typ=source_typ,
291+
push!(args, (cc=BITS_REF, typ=source_typ, name=source_name,
284292
codegen=(typ=codegen_typ, i=codegen_i)))
285293
else
286-
push!(args, (cc=BITS_VALUE, typ=source_typ,
294+
push!(args, (cc=BITS_VALUE, typ=source_typ, name=source_name,
287295
codegen=(typ=codegen_typ, i=codegen_i)))
288296
end
289297
codegen_i += 1

src/metal.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ function add_argument_metadata!(@nospecialize(job::CompilerJob), mod::LLVM.Modul
699699
push!(md, MDString("air.arg_type_align_size"))
700700
push!(md, Metadata(ConstantInt(Int32(Base.datatype_alignment(arg_type)))))
701701

702+
push!(md, MDString("air.arg_type_name"))
703+
push!(md, MDString(repr(arg.typ)))
704+
705+
push!(md, MDString("air.arg_name"))
706+
push!(md, MDString(String(arg.name)))
707+
702708
push!(arg_infos, MDNode(md))
703709

704710
i += 1

0 commit comments

Comments
 (0)