Skip to content

Commit 90c0e19

Browse files
committed
Add function signature to code_native and code_llvm
1 parent bf00ff4 commit 90c0e19

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/codegen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7447,6 +7447,14 @@ static jl_llvm_functions_t
74477447
declarations.functionObject = needsparams ? "jl_fptr_sparam" : "jl_fptr_args";
74487448
}
74497449

7450+
if (ctx.emission_context.debug_level >= 2 && lam->def.method && jl_is_method(lam->def.method) && lam->specTypes != (jl_value_t*)jl_emptytuple_type) {
7451+
ios_t sigbuf;
7452+
ios_mem(&sigbuf, 0);
7453+
jl_static_show_func_sig((JL_STREAM*) &sigbuf, (jl_value_t*)lam->specTypes);
7454+
f->addFnAttr("julia.fsig", StringRef(sigbuf.buf, sigbuf.size));
7455+
ios_close(&sigbuf);
7456+
}
7457+
74507458
AttrBuilder FnAttrs(ctx.builder.getContext(), f->getAttributes().getFnAttrs());
74517459
AttrBuilder RetAttrs(ctx.builder.getContext(), f->getAttributes().getRetAttrs());
74527460

src/disasm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ class LineNumberAnnotatedWriter : public AssemblyAnnotationWriter {
363363
void LineNumberAnnotatedWriter::emitFunctionAnnot(
364364
const Function *F, formatted_raw_ostream &Out)
365365
{
366+
if (F->hasFnAttribute("julia.fsig")) {
367+
auto sig = F->getFnAttribute("julia.fsig").getValueAsString();
368+
Out << "; Function Signature: " << sig << "\n";
369+
}
366370
InstrLoc = nullptr;
367371
DISubprogram *FuncLoc = F->getSubprogram();
368372
if (!FuncLoc) {

0 commit comments

Comments
 (0)