Skip to content

Fix crash when using -ffp-accuracy and std:: trigonometric functions. #11606

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

Merged
merged 5 commits into from
Oct 30, 2023

Conversation

zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Oct 19, 2023

This is to fix a crash in the host compilation when calling any std:: trigonometric function.

@zahiraam zahiraam temporarily deployed to WindowsCILock October 19, 2023 17:56 — with GitHub Actions Inactive
@zahiraam zahiraam temporarily deployed to WindowsCILock October 19, 2023 19:04 — with GitHub Actions Inactive
@zahiraam zahiraam marked this pull request as ready for review October 20, 2023 20:44
@zahiraam zahiraam requested review from a team as code owners October 20, 2023 20:44
@zahiraam zahiraam changed the title Fix crash Fix crash when using -ffp-accuracy and std:: trigonometric functions. Oct 20, 2023
CI = EmitFPBuiltinIndirectCall(IRFuncTy, IRCallArgs, CalleePtr, FD);
if (CI)
return RValue::get(CI);
if (FD) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When do we get a null FD here? Can we assert that condition instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We get the null when the entire sycl.hpp is included. And to use std::sin we need to include the entire sycl.hpp.

Copy link
Contributor

@premanandrao premanandrao Oct 20, 2023

Choose a reason for hiding this comment

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

I mean what property of this entity is it that causes FD to be NULL? Can we assert (FD || that condition) instead of removing the non-NULL FD check that we had before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FD is null when TargetDecl is not a FunctionDecl. Not really sure what "that condition" should be?

Copy link
Contributor

Choose a reason for hiding this comment

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

I chatted with @zahiraam offline; she believes that all the null FD cases are understood and handled here, so no assertion is necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @premanandrao for the updates about NULL cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just an additional comment about the assert.
For any TargetDecl, the control flow passes through this code. In the case we are using the fp-accuracy we need to check that the TargetDecl is a FunctionDecl and only then we can generate a call to the intrinsic. For any other kind of TargetDecl we can just create the call (in this particular case, the TargetDecl was a CXXConstructorDecl).

@zahiraam
Copy link
Contributor Author

Review please.

@zahiraam zahiraam requested a review from premanandrao October 24, 2023 15:00
@zahiraam
Copy link
Contributor Author

@premanandrao Can you please review. This is time critical. Thanks.

@zahiraam zahiraam temporarily deployed to WindowsCILock October 27, 2023 20:03 — with GitHub Actions Inactive
@zahiraam zahiraam temporarily deployed to WindowsCILock October 27, 2023 20:42 — with GitHub Actions Inactive
@zahiraam
Copy link
Contributor Author

@aelovikov-intel Can you please review this? Thanks.

@aelovikov-intel aelovikov-intel merged commit 3139f5c into intel:sycl Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants