[PATCH] D150967: precommit test for memcpy removal for noalias, readonly attributed arguments

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 20 01:54:50 PDT 2023


nikic added inline comments.


================
Comment at: llvm/test/Transforms/MemCpyOpt/memcpy.ll:397
+; before and after the call because of its attributes.
+declare void @fnr(ptr noalias readonly)
+define noundef i32 @noalias_readonly_i8(ptr align 4 noalias readonly %val) {
----------------
StephenFan wrote:
> For `readonly`, the LangRef says: This attribute indicates that the function does not write through this pointer argument, even though it may write to the memory that the pointer points to.
> IIUC, it means there is no write that through this argument, but we can't guarantee that the memory is not written. So maybe we need to make sure the function `@fnr` has the attribute `memory(read)`? 
> 
> 
The combination of readonly and noalias guarantees this. Due to the noalias the only write can happen though that argument, which is readonly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150967/new/

https://reviews.llvm.org/D150967



More information about the llvm-commits mailing list