Optimizer: don't inline named functions in debug builds#19548
Optimizer: don't inline named functions in debug builds#19548auduchinok wants to merge 1 commit intodotnet:mainfrom
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
inlinefunctions are fully inlined on the call sites by F# compiler. This means the source information and actual calls are lost, so it's very hard to reliably debug code using such functions.This PR prevents inlining
inlinefunctions in debug builds. This improves debugging experience by allowing setting breakpoints inside such functions and allowing stepping into them and checking the function arguments. It also allows IDEs to analyze the produced IL more reliably during debug.The implementation handles two cases. When possible, a normal call to the existing method is emitted. When a function contains SRTPs, a specialized method is created for each type instantiation.
An example
inlinefunction that can be called directly:The existing method is called:

An
inlinefunction with SRTPs:A specialized method is produced and called:

Open questions:
DebuggerNonUserCode?Implements fsharp/fslang-suggestions#824 for debug builds.
Fixes #9555.