Skip to content

Conversation

@amanasifkhalid
Copy link
Contributor

Fixes #108406. When removing redundant store nodes in RBO, we need to also update SSA definitions to no longer track the removed stores. Because call sites that use SSA definitions are responsible for null-checking the store node, the simplest method of removal is to null out the node pointer in the SSA def.

cc @dotnet/jit-contrib, @AndyAyersMS PTAL. I can include a regression test if you think it would be useful, but I think the new DEBUG_DESTROY_NODE gives us better coverage anyway.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 3, 2024
@amanasifkhalid amanasifkhalid added this to the 9.0.0 milestone Oct 3, 2024
assert(candidateStmt->GetRootNode()->OperIs(GT_STORE_LCL_VAR));
GenTreeLclVarCommon* const rootNode = candidateStmt->GetRootNode()->AsLclVarCommon();

LclVarDsc* const varDsc = lvaGetDesc(rootNode);
Copy link
Member

Choose a reason for hiding this comment

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

Since the local is in SSA you should be able to locate the LclSsaVarDsc directly. Something like:

unsigned const ssaNum = rootNode->GetSsaNum();
LclSsaVarDsc* const defDsc = varDsc->GetPerSsaData(ssaNum);
assert(defDsc->GetDefNode() == rootNode);
defDsc->SetDefNode(nullptr);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed

@amanasifkhalid amanasifkhalid merged commit fce7c7d into dotnet:main Oct 4, 2024
@amanasifkhalid amanasifkhalid deleted the remove-ssa-defs branch October 4, 2024 14:55
@amanasifkhalid
Copy link
Contributor Author

/backport to release/9.0

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2024

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/11182189273

sirntar pushed a commit to sirntar/runtime that referenced this pull request Oct 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2024
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.

JIT: Assertion failed 'tree == stmt->GetRootNode()'

2 participants