Skip to content

Commit

Permalink
Add function signature to code_native and code_llvm
Browse files Browse the repository at this point in the history
  • Loading branch information
pchintalapudi committed Jul 22, 2023
1 parent bf00ff4 commit 90c0e19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7447,6 +7447,14 @@ static jl_llvm_functions_t
declarations.functionObject = needsparams ? "jl_fptr_sparam" : "jl_fptr_args";
}

if (ctx.emission_context.debug_level >= 2 && lam->def.method && jl_is_method(lam->def.method) && lam->specTypes != (jl_value_t*)jl_emptytuple_type) {
ios_t sigbuf;
ios_mem(&sigbuf, 0);
jl_static_show_func_sig((JL_STREAM*) &sigbuf, (jl_value_t*)lam->specTypes);
f->addFnAttr("julia.fsig", StringRef(sigbuf.buf, sigbuf.size));
ios_close(&sigbuf);
}

AttrBuilder FnAttrs(ctx.builder.getContext(), f->getAttributes().getFnAttrs());
AttrBuilder RetAttrs(ctx.builder.getContext(), f->getAttributes().getRetAttrs());

Expand Down
4 changes: 4 additions & 0 deletions src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ class LineNumberAnnotatedWriter : public AssemblyAnnotationWriter {
void LineNumberAnnotatedWriter::emitFunctionAnnot(
const Function *F, formatted_raw_ostream &Out)
{
if (F->hasFnAttribute("julia.fsig")) {
auto sig = F->getFnAttribute("julia.fsig").getValueAsString();
Out << "; Function Signature: " << sig << "\n";
}
InstrLoc = nullptr;
DISubprogram *FuncLoc = F->getSubprogram();
if (!FuncLoc) {
Expand Down

0 comments on commit 90c0e19

Please sign in to comment.