[PATCH] D136822: [InstCombine] Allow memcpys from constant memory to readonly noalias parameters to be elided.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 09:05:41 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:95
+              Call->paramHasAttr(DataOpNo, Attribute::NoAlias))) &&
             (Call->use_empty() || Call->doesNotCapture(DataOpNo)))
           continue;
----------------
I think this change introduces a subtle bug wrt capturing: If we have call without return value that is not-nocapture and not-readonly, and only the parameter is readonly, then the parameter might be captured by writing to some other location (e.g. a global) and then the captured pointer might be used after the call in a way we can't inspect.

So I think if only the parameter is readonly, then we need to require that it is nocapture as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136822



More information about the llvm-commits mailing list