Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jakobbotsch
Copy link
Member

Some intrinsics can be a noop when they are imported. For example,
Unsafe.BitCast<T, T>(X) just returns its operand when importing. If
that operand is a call then we will run the tail logic of call
importation for that call node twice, since that logic tries to filter
out intrinsic importation with an IsCall() check. Switch the check to
be based on !bIntrinsicImported instead.

Fix #96461

Some intrinsics can be a noop when they are imported. For example,
`Unsafe.BitCast<T, T>(X)` just returns its operand when importing. If
that operand is a call then we will run the tail logic of call
importation for that call node twice, since that logic tries to filter
out intrinsic importation with an `IsCall()` check. Switch the check to
be based on `!bIntrinsicImported` instead.

Fix dotnet#96461
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 5, 2024
@ghost ghost assigned jakobbotsch Jan 5, 2024
@ghost
Copy link

ghost commented Jan 5, 2024

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

Issue Details

Some intrinsics can be a noop when they are imported. For example,
Unsafe.BitCast<T, T>(X) just returns its operand when importing. If
that operand is a call then we will run the tail logic of call
importation for that call node twice, since that logic tries to filter
out intrinsic importation with an IsCall() check. Switch the check to
be based on !bIntrinsicImported instead.

Fix #96461

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch marked this pull request as ready for review January 5, 2024 18:00
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

No diffs


if (call->IsCall())
// Sometimes "call" is not a GT_CALL (if we imported an intrinsic that didn't turn into a call)
if (!bIntrinsicImported)
Copy link
Member

Choose a reason for hiding this comment

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

Is this something that needs backported?

Looks like it's been a potential issue for a long time, although it's unclear to me why we're only just seeing this "now" given how widely used intrinsics have been, including in potentially tail recursive positions, and we've many that can be no-ops or just return one of the input operands (such as op_UnaryPlus, AsInt32, etc).

-- Notably looks like there are some asserts in this block checking that !bIntrinsicImported that can potentially be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Seems likely this double-processing ended up with the same result, so didn't actually cause a bug.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it needs to be backported, I think it's very hard for the code that runs twice here to cause problems in release builds. Also we need a customer report for backporting.

Looks like it's been a potential issue for a long time, although it's unclear to me why we're only just seeing this "now" given how widely used intrinsics have been, including in potentially tail recursive positions, and we've many that can be no-ops or just return one of the input operands (such as op_UnaryPlus, AsInt32, etc).

Presumably people do not write code that involves noop intrinsics like op_UnaryPlus very often, and even more rarely that also satisfies the other conditions to hit the bug.

-- Notably looks like there are some asserts in this block checking that !bIntrinsicImported that can potentially be removed.

Let me address that as part of a future PR to rerunning CI.

@jakobbotsch jakobbotsch merged commit 4ce2ee9 into dotnet:main Jan 5, 2024
@jakobbotsch jakobbotsch deleted the fix-96461 branch January 5, 2024 18:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 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 assert on Unix in ReturnTypeDesc::InitializeStructReturnType
3 participants