[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 03:07:27 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:93
+             (IsArgOperand &&
+              Call->paramHasAttr(DataOpNo, Attribute::ReadOnly) &&
+              Call->paramHasAttr(DataOpNo, Attribute::NoAlias))) &&
----------------
Use onlyReadsMemory(DataOpNo) here, to also handle readnone implicitly.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:94
+              Call->paramHasAttr(DataOpNo, Attribute::ReadOnly) &&
+              Call->paramHasAttr(DataOpNo, Attribute::NoAlias))) &&
             (Call->use_empty() || Call->doesNotCapture(DataOpNo)))
----------------
Do we actually need the noalias requirement here? The code in this function should visit all uses of the alloca and bail out on any captures. So if there is a second argument based on the alloca that is not readonly, then we would reject it at that point. Does that sound right?


================
Comment at: llvm/test/Transforms/InstCombine/forward-memcpy-to-readonly-noalias.ll:4
+;
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
----------------
Use update_test_checks.py please.


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