Skip to content

[NFCI][SYCL] Eliminate UB in ANSI alias violation accessing ByteArray's #7023

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 2 commits into from
Oct 12, 2022

Conversation

aelovikov-intel
Copy link
Contributor

As part of it provide a nicer (IMO) interface to it. Also, asserts are now moved into the underlying utility functions making it easier to read the core logic up the call stack.

As part of it provide a nicer (IMO) interface to it. Also, asserts are
now moved into the underlying utility functions making it easier to read
the core logic up the call stack.
@aelovikov-intel aelovikov-intel requested a review from a team as a code owner October 11, 2022 20:19
// The map is not locked here because updateSpecConstSymMap() is
// only supposed to be called from c'tor.
MSpecConstSymMap[std::string{SCName}].push_back(
SpecConstDescT{/*ID*/ It[0], /*CompositeOffset*/ It[1],
/*Size*/ It[2], BlobOffset});
SpecConstDescT{Id, CompositeOffset, Size, BlobOffset});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be

MSpecConstSymMap[std::string{SCName}].emplace_back(Id, CompositeOffset, Size, BlobOffset);

but should be done in a different PR (if at all).

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

I agree, this looks great! Just one minor comment, but I don't think it needs to block this.

T Val;
std::memcpy(&Val, Ptr, sizeof(T));
Ptr += sizeof(T);
Size -= sizeof(T);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but you could call dropBytes(sizeof(T)) here instead. Should make maintainability a little easier, in case something else comes along that needs to be mutated with every move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It evaluates the assert one more time now, but that should be fine.

@aelovikov-intel
Copy link
Contributor Author

@intel/llvm-gatekeepers , this PR is ready.

@steffenlarsen steffenlarsen merged commit 574891b into intel:sycl Oct 12, 2022
@aelovikov-intel aelovikov-intel deleted the byte-array branch November 8, 2022 20:44
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.

2 participants