Skip to content
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

Fix an SSA bug from the ASG refactoring #86108

Merged
merged 2 commits into from
May 12, 2023

Conversation

SingleAccretion
Copy link
Contributor

The SSA renaming code was changed in an incompatible way s.t. memory stores in protected blocks were no longer considered to induce PHIs in the corresponding handlers.

Recording PHIs from analyzable stores is a correctness requirement.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 11, 2023
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label May 11, 2023
@ghost
Copy link

ghost commented May 11, 2023

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

Issue Details

The SSA renaming code was changed in an incompatible way s.t. memory stores in protected blocks were no longer considered to induce PHIs in the corresponding handlers.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@@ -1114,7 +1114,7 @@ void SsaBuilder::BlockRenameVariables(BasicBlock* block)
{
for (GenTree* const tree : stmt->TreeList())
{
if (tree->OperIsSsaDef())
if (tree->OperIsStore() || tree->OperIs(GT_CALL))
Copy link
Contributor Author

@SingleAccretion SingleAccretion May 11, 2023

Choose a reason for hiding this comment

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

In actuality the same problem exists for un-analyzable stores as well. But that is a pre-existing issue.

Reproduction
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static bool Problem()
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Throw()
    {
        _intStatic = 1;
        throw new Exception();
    }

    _intStatic = 2;

    try
    {
        Throw();
        _intStatic = 2;
    }
    catch (Exception)
    {
        if (_intStatic == 2)
        {
            return true;
        }
    }

    return false;
}

Filed #86112 for this.

@SingleAccretion SingleAccretion marked this pull request as ready for review May 11, 2023 20:30
@SingleAccretion
Copy link
Contributor Author

No diffs - a small TP regression, but this is a correctness fix.

x86 failure is #35066.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Thanks for spotting this.

@AndyAyersMS AndyAyersMS merged commit 09ad892 into dotnet:main May 12, 2023
@SingleAccretion SingleAccretion deleted the Fix-Asg-Bug branch May 24, 2023 17:40
@ghost ghost locked as resolved and limited conversation to collaborators Jun 23, 2023
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 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.

2 participants