Skip to content

Conversation

@s-barannikov
Copy link
Contributor

This patch changes the type of the value argument of @llvm.memset and
similar intrinsics from i8 to iN, where N is the byte width specified
in data layout string.
Note that the argument still has fixed type (not overloaded), but type
checker will complain if the type does not match the byte width.

Ideally, the type of the argument would be dependent on the address
space of the pointer argument. It is easy to do this (and I did it
downstream as a PoC), but since data layout string doesn't currently
allow different byte widths for different address spaces, I refrained
from doing it now.

Copy link
Contributor Author

s-barannikov commented Aug 29, 2024

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

I don't think this is the right direction for memset. I would prefer actually overloading it and making the memset/memset.pattern distinction redundant. See also #97583 (comment) and following comments.

@s-barannikov
Copy link
Contributor Author

I don't think this is the right direction for memset. I would prefer actually overloading it and making the memset/memset.pattern distinction redundant. See also #97583 (comment) and following comments.

Thanks for the link. I'm in favor of the RFC and in fact I considered this approach, too. It will take long time for the llvm.memset to be replaced with llvm.memset.pattern though, and until then we need to get llvm.memset working with non-8-bit bytes somehow. The suggested approach requires minimum changes, is backward compatible, and follows the semantics specified by the LangRef:

The ‘llvm.memset.*’ intrinsics fill “len” bytes of memory starting at the destination location.

That said, I can keep this patch downstream if you think it does something wrong.

@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from 98c3676 to 31ee84f Compare October 27, 2024 00:56
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from f78b4f6 to edcea1e Compare October 27, 2024 00:56
@github-actions
Copy link

github-actions bot commented Oct 27, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from edcea1e to 4cee863 Compare October 27, 2024 01:13
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from 31ee84f to b46d554 Compare February 4, 2025 13:59
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from 4cee863 to 65a421f Compare February 4, 2025 14:00
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from b46d554 to 4048990 Compare April 6, 2025 17:22
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from 65a421f to 97cce99 Compare April 6, 2025 17:22
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from 4048990 to 2488060 Compare April 19, 2025 08:18
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from 97cce99 to 0bf73e3 Compare April 19, 2025 08:18
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from 2488060 to 3539d10 Compare July 11, 2025 16:25
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch 3 times, most recently from 28662b7 to 2080c3e Compare July 11, 2025 17:12
This patch changes the type of the value argument of @llvm.memset and
similar intrinsics from i8 to iN, where N is the byte width specified
in data layout string.
Note that the argument still has fixed type (not overloaded), but type
checker will complain if the type does not match the byte width.

Ideally, the type of the argument would be dependent on the address
space of the pointer argument. It is easy to do this (and I did it
downstream as a PoC), but since data layout string doesn't currently
allow different byte widths for different address spaces, I refrained
from doing it now.
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/2-memset-intrinsic branch from 2080c3e to 5332872 Compare November 8, 2025 09:11
@s-barannikov s-barannikov force-pushed the users/s-barannikov/byte/1-datalayout branch from 3539d10 to 670e94d Compare November 8, 2025 09:11
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.

3 participants