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 the incorrect merge logic for back edges for GlobalFlowStateAnalysis #6029

Merged
merged 1 commit into from Jun 25, 2022

Conversation

mavasani
Copy link
Member

Fixes #6015

GlobalFlowStateAnalysisValueSet.Unset is used to represent unanalyzed flow state, GlobalFlowStateAnalysisValueSet.Empty is used to represent analyzed flow state with no analysis values. We initialize the flow states for the entry basic block of the CFG with Unset value, but never replace the Unset with Empty for subsequent passes. This in turn leads to incorrect merge when a Known value flows from the back edge to the loop start and ends up overriding the Unset value instead of being overridden by the Empty value. Now we correctly perform this merge logic.

I verified that prior to this fix, the added unit test hang due to this issue. I also verified that building the github repo cited in the feedback ticket with platform compat analyzer also leads to a hang before this fix. Both these repros are fixed after this PR.

Fixes dotnet#6015

`GlobalFlowStateAnalysisValueSet.Unset` is used to represent unanalyzed flow state, `GlobalFlowStateAnalysisValueSet.Empty` is used to represent analyzed flow state with no analysis values. We initialize the flow states for the entry basic block of the CFG with `Unset` value, but never replace the `Unset` with `Empty` for subsequent passes. This in turn leads to incorrect merge when a `Known` value flows from the back edge to the loop start and ends up overriding the `Unset` value instead of being overridden by the `Empty` value. Now we correctly perform this merge logic.

I verified that prior to this fix, the added unit test hang due to this issue. I also verified that building the github repo cited in the feedback ticket with platform compat analyzer also leads to a hang before this fix. Both these repros are fixed after this PR.
@mavasani mavasani requested a review from buyaa-n June 23, 2022 11:14
@mavasani mavasani requested a review from a team as a code owner June 23, 2022 11:14
{
return value1;
return GlobalFlowStateAnalysisValueSet.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

It's not entirely clear to me why you always set Empty in the case of merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink This matches the intended merge logic also documented in

/// <summary>
/// Unset value set.
/// This is needed along with Empty to ensure the following merge results:
/// Unset + Known = Known
/// Empty + Known = Empty
/// </summary>
Unset,
. I goofed up in the merge implementation

Copy link
Member

Choose a reason for hiding this comment

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

Didn't read the doc... sorry :)

Copy link
Member

@buyaa-n buyaa-n 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 the fix!

@buyaa-n
Copy link
Member

buyaa-n commented Jun 23, 2022

@mavasani JFYI: the build failures with NuGet errors: NU1504, NU1505 I can also see locally

@mavasani
Copy link
Member Author

@jmarolf is this a known issue?

@Youssef1313
Copy link
Member

@mavasani @buyaa-n Functionality for that on NuGet-side was implemented in NuGet/NuGet.Client#4484. I'm fixing the error in #6032

@jmarolf
Copy link
Contributor

jmarolf commented Jun 24, 2022

@jmarolf is this a known issue?

let me take a look

@jmarolf jmarolf self-assigned this Jun 24, 2022
@mavasani
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mavasani mavasani enabled auto-merge June 25, 2022 05:06
@mavasani mavasani merged commit 3783967 into dotnet:main Jun 25, 2022
@codecov
Copy link

codecov bot commented Jun 25, 2022

Codecov Report

Merging #6029 (7a51dbd) into main (0e7f40d) will decrease coverage by 0.00%.
The diff coverage is 92.10%.

@@            Coverage Diff             @@
##             main    #6029      +/-   ##
==========================================
- Coverage   96.03%   96.03%   -0.01%     
==========================================
  Files        1338     1338              
  Lines      307164   307197      +33     
  Branches     9787     9788       +1     
==========================================
+ Hits       294978   295007      +29     
- Misses       9809     9812       +3     
- Partials     2377     2378       +1     

@github-actions github-actions bot added this to the vNext milestone Jun 25, 2022
@mavasani mavasani deleted the FixFlowAnalysis branch June 25, 2022 07:06
@jmarolf jmarolf modified the milestones: vNext, .NET 7.x Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiling .net 6 project with PlatformCompatibilityAnalyzer enabled never completes
5 participants