Skip to content
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

[Feature Request]: Add flag for munging generated code with file and line info #26621

Open
jabraham17 opened this issue Jan 29, 2025 · 1 comment

Comments

@jabraham17
Copy link
Member

When profiling Chapel code, it would be useful to be able to map generated symbol names back to the original Chapel code, without looking at the generated code.

For example,

proc foo(x: int) {
  writeln(x);
}
proc foo(x: real) {
  writeln(x);
}
proc foo(x: bool) {
  writeln(x);
}

foo(1);
foo(1.0);
foo(true);

The generated code for this code snippet with have foo_chpl, foo_chpl2, and foo_chpl3, but without looking at the generated code there is no way to know which is which. With the C backend, before each function name we print a comment with the original filename and line number (compiler/codegen/cg-symbol.cpp:2764), like

/*MySourceFile.chpl:7 */
void foo_chpl3(....) {

This information is harder to glean from the LLVM backend, and furthermore its unfortunate to require looking at the generated code to get this information

It would be useful to provide a flag like --munge-with-locations (similar to --munge-with-ids), which would embed the filename and line number in the function name, e.g. foo_chpl_MySourceFile_1

@mppf
Copy link
Member

mppf commented Jan 30, 2025

Some related things that you migth already be aware of:

  • the stacktrace support has some function name tables
  • --cpp-lines and -g
  • --munge-with-ids embeds dyno's IDs into symbol names (and only works with the LLVM backend). It would be relatively straightforward to make a helper tool to go from such a munged name to a source location.

Ideally, with the LLVM backend, we would be generating sufficiently good debug information for debuggers and other tooling. Perhaps that would be enough for your use cases as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants