Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Jun 6, 2025

Fixes #116143

Both "Expand runtime lookup" and "Expand static cctors" (NativeAOT) may run in Tier0/MinOpts (Debug). Convert BBF_INTERNAL to BBF_IMPORTER for new blocks (as was suggested by @eterekhin)

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@EgorBo EgorBo marked this pull request as ready for review June 6, 2025 12:13
Copilot AI review requested due to automatic review settings June 6, 2025 12:13
Copy link
Contributor

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.

Pull Request Overview

This PR updates the flag conversion logic in helperexpansion.cpp to use BBF_IMPORTED for new blocks, addressing the issue raised in #116143.

  • Removed an unused variable (sigNode) in fgExpandRuntimeLookupsForCall.
  • Updated BBF_INTERNAL flag conversion to BBF_IMPORTED in both runtime lookup and static initializer expansion paths.

@EgorBo
Copy link
Member Author

EgorBo commented Jun 6, 2025

PTAL @jakobbotsch @noahfalk

I only touched the phases that may introduce internal blocks for Tier0/MinOpts - there are a few more places for optimized code, do we need to handle them as well?

@eterekhin
Copy link
Contributor

@EgorBo, Thank you for working on that!

I checked with this commit, unfortunately ICorDebugILFrame::GetIP still returns NO_MAPPING result on my code snippet and NO_MAP entry is there.

Attached a piece of ConfigureFormattingUiTestBase2<>.Test10 JIT dump

*************** In genIPmappingGen()
IP mapping count : 9
IL offs PROLOG : 0x00000000 ( STACK_EMPTY )
IL offs NO_MAP : 0x0000001C ( STACK_EMPTY )
IL offs 0x0000 : 0x0000002A ( STACK_EMPTY )
IL offs 0x0001 : 0x0000002B ( STACK_EMPTY )
IL offs NO_MAP : 0x00000055 ( STACK_EMPTY ) // <---
IL offs 0x000B : 0x00000079 ( CALL_INSTRUCTION )
IL offs 0x0010 : 0x00000082
IL offs 0x0011 : 0x00000083 ( STACK_EMPTY )
IL offs EPILOG : 0x00000084 ( STACK_EMPTY )

@EgorBo EgorBo force-pushed the fix-bbf-internal branch from a78ec56 to 1f95d65 Compare June 6, 2025 13:04
@noahfalk
Copy link
Member

noahfalk commented Jun 6, 2025

there are a few more places for optimized code, do we need to handle them as well?

For optimized code the long-standing convention has been the JIT would make "best effort" to produce good mapping information in optimized code, but there is no guarantee on it. My preference would be that we fix it in optimized code too assuming it isn't particularly onerous or risky to do.

@EgorBo EgorBo force-pushed the fix-bbf-internal branch from ad68b1f to 3b3532f Compare August 1, 2025 10:28
@EgorBo
Copy link
Member Author

EgorBo commented Aug 1, 2025

@eterekhin sorry, this fell off my radar, I've just updated it.

@dotnet/jit-contrib @AndyAyersMS PTAL

It seems like for optimized codegen we have tons of places where we don't propagate the flag properly. Since we're late in the cycle, I've pushed the fix for this particular problem for Debug codegen (since we expand runtime lookups pretty much always regardless of opts). We also do static cctor initialization expansion always (on NativeAOT at least).

@EgorBo EgorBo requested a review from AndyAyersMS August 1, 2025 10:31
@eterekhin
Copy link
Contributor

@EgorBo, I can confirm, the fix is working, thank you!

@EgorBo EgorBo enabled auto-merge (squash) August 1, 2025 14:44
@EgorBo EgorBo merged commit 41c675e into dotnet:main Aug 1, 2025
108 of 110 checks passed
@EgorBo EgorBo deleted the fix-bbf-internal branch August 1, 2025 14:45
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICorDebugILFrame::GetIP() returns not accurate result

5 participants