[PATCH] D151943: [InstCombine] Propagate some func/arg/ret attributes from caller to callsite

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 14:42:04 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, StephenFan, jdoerfert.
Herald added subscribers: kerbowa, hiraditya, jvesely.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Some function attributes imply the attribute for all/some instructions
in the function. These attributes can be safely propagated to
callsites within the function that are missing the attribute. This can
be useful if the original caller is later inlined, as if the
attributes are not propagated, they will be lost.

This patch only implements the attributes can can be blindly propagated.

Function attributes:

- mustprogress, nofree, readonly, readnone, writeonly, willreturn

If any of the above are true for the function, they MUST apply to any
callsite in the function (along with any other instruction).

Argument attributes:

- noundef, nonnull, nofree, readonly, readnone, writeonly

If any of the above are true for an argument to the caller it will
hold true as an argument for the callsite.

Return attributes:

- noundef, nonnull

IFF the callsite's value is used as the caller's return value, we can
propagate those attributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151943

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Other/cgscc-devirt-iteration.ll
  llvm/test/Transforms/InstCombine/AMDGPU/memcpy-from-constant.ll
  llvm/test/Transforms/InstCombine/freeze-integer-intrinsics.ll
  llvm/test/Transforms/InstCombine/mem-deref-bytes-addrspaces.ll
  llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
  llvm/test/Transforms/InstCombine/mem-gep-zidx.ll
  llvm/test/Transforms/InstCombine/memcpy-from-global.ll
  llvm/test/Transforms/InstCombine/sdiv-guard.ll
  llvm/test/Transforms/InstCombine/strcmp-memcmp.ll
  llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll
  llvm/test/Transforms/PhaseOrdering/memset-tail.ll
  llvm/test/Transforms/PhaseOrdering/vector-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151943.527628.patch
Type: text/x-patch
Size: 38619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230601/2b30a419/attachment.bin>


More information about the llvm-commits mailing list