-
-
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
Support emitting debuginfo w.r.t. LLVM IR #56792
base: master
Are you sure you want to change the base?
Conversation
@@ -567,6 +567,8 @@ static void buildCleanupPipeline(ModulePassManager &MPM, PassBuilder *PB, Optimi | |||
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); | |||
} | |||
} | |||
// TODO: This should be conditionally enabled depending on the emission mode for the Execution engine | |||
MPM.addPass(createModuleToFunctionPassAdaptor(InstructionNamerPass())); |
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.
@gbaraldi Do you know where else I need to add this pass to get complete coverage?
It also needs to be turned on / off depending on the debuginfo mode, but I think I can probably pipe that through the OptimizationOptions maybe
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.
It should only be here. Though yeah make it conditional on the options. Similar to #55407 and maybe an llvmpasses test. Not sure if it's super worth it but 🤷
29679d0
to
b2bdd73
Compare
This change adds two new environmental variables: - `JULIA_DUMP_IR` - when provided, this is a path that all emitted LLVM IR (post-optimization, just before machine code generation) will be saved to - `JULIA_DEBUGINFO` - when set to "LLVM-IR" this will run an additional pass on any emitted functions to rewrite their debuginfo to refer to the LLVM source, rather than the Julia source it was generated from The `debugir` pass that rewrites the debuginfo is vendored from: https://github.com/vaivaswatha/debugir. For simplicity, this is just a copy of the one file that we need for the pass. Using both of these together allows `gdb` to open the dumped IR and means you can step through LLVM IR line-by-line, print SSA values, etc. This can be very useful for debugging segfaults, or issues in codegen.
b2bdd73
to
59f5c1e
Compare
This change adds two new environmental variables:
JULIA_DUMP_IR
- when provided, this is a path that all emitted LLVM IR (post-optimization, just before machine code generation) will be saved toJULIA_DEBUGINFO
- when set to "LLVM-IR" this will run an additional pass on any emitted functions to rewrite their debuginfo to refer to the LLVM source, rather than the Julia source it was generated fromThis allows
![image](https://private-user-images.githubusercontent.com/84105208/394432019-b7e52854-15d0-4937-a21e-7b4b3108cf8f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjkyMDQsIm5iZiI6MTczOTE2ODkwNCwicGF0aCI6Ii84NDEwNTIwOC8zOTQ0MzIwMTktYjdlNTI4NTQtMTVkMC00OTM3LWEyMWUtN2I0YjMxMDhjZjhmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDA2MjgyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmNDZiNGZjZTVmMDU4ZjVmMDczMzVmYjVmNjk0ODRkNmI4NzBiMjVlZjI2ZWY1YmRkNjE0MWEwOGQ4MWI2YjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.H-J5AbMaj9J6DYY4g5Epc-gCwd8L9CvgTBflzvX8Un4)
gdb
to open the dumped IR and means you can step through LLVM IR line-by-line, print SSA values, etc. which can be very useful for debugging segfaults, or issues in codegen:The
debugir
pass that rewrites the debuginfo is vendored from: https://github.com/vaivaswatha/debugir. For simplicity, this is just a copy of the one file that we need for the pass.