[llvm] [IR] Initial introduction of memset_pattern (PR #97583)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 06:46:23 PDT 2024


asb wrote:

> Something I'm still not completely sold on is that the size is specified in bytes. I think the only advantage of doing that is that it directly maps onto the apple libcalls. On the flip side, it has the disadvantage that we may end up generating an unnecessary tail loop.
> 
> However, the larger conceptual problem I see is that it may prevent future generalization (though I kind of wonder whether that should not be supported right away) to non-integer types. memset.pattern is a good opportunity to perform stores with the correct types. E.g. consider filling memory with non-integral pointers -- in that case you can't just perform the memset after a ptrtoint. And a store of only part of a non-integral pointer would be pretty ill-defined. To a lesser degree this problem also exists for integral pointers, due to provenance considerations.
> 
> I'd rather not end up having to need another separate intrinsic to satisfy that case.

I think this is a good call - thank you. I've gone ahead and made that change.

One awkwardness I want to flag for review is that MemSetPatternInst still inherits from MemSetInst which inherits from `MemSetBase`. The awkwardness is that `getLength` returns the length in bytes for the other mem* intrinsics, but it's the number of pattern sets for memset.pattern.

https://github.com/llvm/llvm-project/pull/97583


More information about the llvm-commits mailing list