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

Don't bail out on side-effects in assertionprop #108418

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Oct 1, 2024

No description provided.

@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 Oct 1, 2024
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 October 1, 2024 20:08
@EgorBo
Copy link
Member Author

EgorBo commented Oct 1, 2024

@dotnet/jit-contrib @AndyAyersMS PTAL, small change, Diffs

TLDR:

We have HelperCall(arg0, arg1) and if we need to fold it to just arg0 we require arg0 to be side-effect free and call gtExtractSideEffects because otherwise we may duplicate some side-effects (calls have complex structure - setup args, late args, indirect-target node, etc).

In order to allow arg0 to have side-effects. we simply create a temp inside LateArg and use that temp. Thus, gtExtractSideEffects properly handles all side-effects

PS: I recommend reviewing with "Hide whitespaces" option.

@EgorBo EgorBo requested a review from AndyAyersMS October 1, 2024 20:10
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.

Changes LGTM.

Since we're in the middle of VN/SSA phases, I wonder if it would make sense to build a version of fgMakeMultiUse that puts the new temp into SSA and gives it the right VNs.

@EgorBo EgorBo merged commit 7474054 into dotnet:main Oct 2, 2024
106 of 108 checks passed
@EgorBo EgorBo deleted the dont-bail-out-side-effects branch October 2, 2024 14:50
sirntar pushed a commit to sirntar/runtime that referenced this pull request Oct 3, 2024
lambdageek pushed a commit to lambdageek/runtime that referenced this pull request Oct 3, 2024
Comment on lines -2663 to -2669
if ((castObjArg->gtFlags & GTF_ALL_EFFECT) != 0)
{
// It won't be trivial to properly extract side-effects from the call node.
// Ideally, we only need side effects from the castClsArg argument as the call itself
// won't throw any exceptions. But we should not forget about the EarlyNode (setup args)
return nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why would gtExtractSideEffList(call, ..., /* ignoreRoot */ true) not be sufficient here? I don't think extracting the side effects of the operands of a call is all that hard.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jakobbotsch I am not sure I understand how it can work, say I have

call(arg0, arg1, arg2)

I want to fold it to just arg1 (or to e.g. arg1*arg1 in case of Math.Pow(x, 2)) and say arg1 has a side-effect in it.
if we just return arg1 node and wrap with gtExtractSideEffList we'll just duplicate the side effect

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, I see -- that makes sense.

@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.

3 participants