-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name LLVM function arguments #50500
Name LLVM function arguments #50500
Conversation
LGTM, I was thinking about this today, the result seems very cool. |
I guess the next question is if we want this enabled always or just when running with -g2 |
That looks a bit odd, considering our indexing usually starts at 1. |
Another thought - since this is (presumably) always from slurping, we don't have to worry about offset arrays here, right? |
These indexes are fake anyways, by the time we're making up LLVM argument names for varargs they're already individual LLVM arguments. The index is just for pretty presentation rather than ...1, ...2, etc. |
src/codegen.cpp
Outdated
f = cast<Function>(returninfo.decl.getCallee()); | ||
has_sret = (returninfo.cc == jl_returninfo_t::SRet || returninfo.cc == jl_returninfo_t::Union); | ||
jl_init_function(f, ctx.emission_context.TargetTriple); | ||
auto arg_typename = [&](size_t i) JL_NOTSAFEPOINT { return jl_symbol_name(((jl_datatype_t*)jl_tparam(lam->specTypes, i))->name->name); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not safe to cast this to a datatype.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the overhead of doing this?
Probably not great for functions with large numbers of arguments, so it might be better to stick it behind -g1 and force debug info emission with code_llvm. |
src/codegen.cpp
Outdated
if (ctx.emission_context.debug_level > 0) { | ||
auto arg_typename = [&](size_t i) JL_NOTSAFEPOINT { | ||
auto tp = jl_tparam(lam->specTypes, i); | ||
return jl_is_datatype(tp) ? jl_symbol_name(((jl_datatype_t*)tp)->name->name) : "<unknown datatype>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return jl_is_datatype(tp) ? jl_symbol_name(((jl_datatype_t*)tp)->name->name) : "<unknown datatype>"; | |
return jl_is_datatype(tp) ? jl_symbol_name(((jl_datatype_t*)tp)->name->name) : "<unknown datatype>"; |
But it isn't a datatype, so why does it say "unknown datatype"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we mark it as unknown type
or ::Any
then?
This makes it easier to correlate LLVM IR with the originating source code by including both argument name and argument type in the LLVM argument variable.
Example 1
Example 2