Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 29, 2020

Overview

As discussed several times with @aschackmull, post-dominance makes more sense when restricted to paths that leave the callable normally, that is, without throwing an exception or halting.

For example, in

void M3(string s)
{
    if (s is null)
        throw new ArgumentNullException(nameof(s));
    Console.WriteLine(s);
}

the call Console.WriteLine(s) will happen on all normal paths through M3, so we want it to post-dominate the entry point.

Implementation

Before this PR, the CFG for M3 was
Screenshot 2020-10-29 at 14 12 57
and post-dominance was defined in terms of the exit M3 node.

This PR changes the CFG for M3 to
Screenshot 2020-10-29 at 14 09 39
and redefines post-dominance with respect to the new exit M3 (normal) node that represents normal execution (highlighted in red).

Note that each callable will still have a unique exit node, which is reached from the two new normal/abnormal exit nodes: this is for backwards compatibility, and so that we can recover the old post-dominance logic, if needed.

CSharp-Differences here.

@github-actions github-actions bot added the C# label Oct 29, 2020
@hvitved hvitved force-pushed the csharp/cfg/post-dominance branch from c4c7981 to d22ce94 Compare October 29, 2020 19:56
@hvitved hvitved force-pushed the csharp/cfg/post-dominance branch from d22ce94 to 6723e5b Compare October 30, 2020 08:15
@hvitved hvitved marked this pull request as ready for review November 2, 2020 12:43
@hvitved hvitved requested a review from a team as a code owner November 2, 2020 12:43
Copy link
Contributor

@tamasvajk tamasvajk left a comment

Choose a reason for hiding this comment

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

These CFG diagrams are super useful.

The differences job is red.

@hvitved
Copy link
Contributor Author

hvitved commented Nov 3, 2020

The differences job is red.

Yeah, I am not quite sure why that is, as it has run all projects successfully and done the comparison. So I think we can just ignore it.

@hvitved hvitved requested a review from tamasvajk November 5, 2020 13:55
@hvitved hvitved merged commit 10ab330 into github:main Nov 5, 2020
@hvitved hvitved deleted the csharp/cfg/post-dominance branch November 5, 2020 14:31
@hvitved hvitved mentioned this pull request Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants