Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reduce string interpolation overhead #114497

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pentp
Copy link
Contributor

@pentp pentp commented Apr 10, 2025

For Nullable<T> where T:ISpanFormattable removes a lot of dead code for null values (ToString and AppendLiteral calls).
For reference types removes many redundant null checks and two interface casts (CORINFO_HELP_CHKCASTINTERFACE).

For non-null Nullable<T> the CORINFO_HELP_BOX_NULLABLE allocation still remains - this needs fixing in JIT.

@Copilot Copilot AI review requested due to automatic review settings April 10, 2025 16:30
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 10, 2025
@am11 am11 added area-System.Runtime and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 10, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

@EgorBo
Copy link
Member

EgorBo commented Apr 10, 2025

For non-null Nullable the CORINFO_HELP_BOX_NULLABLE allocation still remains - this needs fixing in JIT.

@pentp is there a minimal repro for it?

@pentp
Copy link
Contributor Author

pentp commented Apr 11, 2025

For non-null Nullable the CORINFO_HELP_BOX_NULLABLE allocation still remains - this needs fixing in JIT.

@pentp is there a minimal repro for it?

Minimal repro: https://godbolt.org/z/WcnoMG9GK

@EgorBo
Copy link
Member

EgorBo commented Apr 11, 2025

For non-null Nullable the CORINFO_HELP_BOX_NULLABLE allocation still remains - this needs fixing in JIT.

@pentp is there a minimal repro for it?

Minimal repro: https://godbolt.org/z/WcnoMG9GK

@AndyAyersMS looks like something EA could help with?

***** BB02 [0002]
STMT00004 ( 0x00D[E-] ... ??? ) <- INLRT @ 0x000[E-]
               [000022] DAC-G------                         *  STORE_LCL_VAR ref    V02 tmp1         
               [000019] --C-G------                         \--*  CALL nullcheck ref    System.Guid:ToString(System.String,System.IFormatProvider):System.String:this
               [000021] --C-G------ this                       +--*  ADD       byref 
               [000015] --C-G------                            |  +--*  CALL help ref    CORINFO_HELP_BOX_NULLABLE
               [000013] H---------- arg0                       |  |  +--*  CNS_INT(h) long   0x7ffab4be4648 class System.Nullable`1[System.Guid]
               [000014] ----------- arg1                       |  |  \--*  LCL_ADDR  byref  V00 arg0         [+0]
               [000020] -----------                            |  \--*  CNS_INT   long   8
               [000017] ----------- arg1                       +--*  CNS_INT   ref    null
               [000018] ----------- arg2                       \--*  CNS_INT   ref    null

@AndyAyersMS
Copy link
Member

@AndyAyersMS looks like something EA could help with?

If we expand CORINFO_HELP_BOX_NULLABLE inline then perhaps... or we could try and handle it as an allocator and then inline expand it when it does not escape. That would require spilling the result of the helper call to a temp in the importer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants