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

Add constant evaluation for fmod to CodeGen #6411

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tex3d
Copy link
Contributor

@tex3d tex3d commented Mar 14, 2024

When you use literals with fmod, it generates the hl intrinsic usind double. During HLOperationLower, this expands to several operations, including DXIL FRC intrinsic. FRC intrinsic doesn't support double, so GetOpFunc returns nullptr for the overload. nullptr is blindly used in CreateCall, which crashes trying to deref nullptr.

This change fixes the literal case by adding constant eval to CodeGen for this intrinsic.

It will still crash if non-constant doubles are used explicitly. Fixing that will require a special path in HLOperationLower to change the generated instruction sequence to something compatible with double.

Fixes #6410.

When you use literals with fmod, it generates the hl intrinsic usind double.
During HLOperationLower, this expands to several operations, including DXIL FRC intrinsic.
FRC intrinsic doesn't support double, so GetOpFunc returns nullptr for the overload.
nullptr is blindly used in CreateCall, which crashes trying to deref nullptr.

This change fixes the literal case by adding constant eval to CodeGen for this intrinsic.

It will still crash if non-constant doubles are used explicitly.
Fixing that will require a special path in HLOperationLower to change the generated instruction sequence to something compatible with double.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

[DXIL] Null pointer exception due to double floating-point literals in fmod intrinsic
1 participant