[PATCH] D150970: (WIP) [MemCpyOpt]remove memcpy on noalias readonly attributed arguments

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 21 10:02:10 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp:1750
+            if (MayWrite)
+              continue;
+            for (Attribute::AttrKind Kind :
----------------
This whole can can be replaced with `CB->onlyReadsMemory(i)`. This will check readonly and readnone and will also correctly handle inheritance of attributes from the function.


================
Comment at: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp:1755
+              if (!CB->getParamAttr(i, Kind).isValid() &&
+                  !F->hasParamAttribute(i, Kind))
+                continue;
----------------
`CB->paramHasAttr(i, Kind)` is enough, it will handle attribute inheritance.


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

https://reviews.llvm.org/D150970



More information about the llvm-commits mailing list