[PATCH] D115829: Allow calls with known writes when trying to remove allocas

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 13:36:43 PST 2021


reames created this revision.
reames added reviewers: anna, nikic.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

isAllocSiteRemovable tracks whether all uses of an alloca are both non-capturing, and non-reading.  If so, we can remove said alloca because nothing can depend on its content or address.

This patch extends this reasoning to allow writes from calls where we can prove the call has no side effect other than writing to said allocation.  This is a fairly natural fit for the existing code with one subtle detail - the call can write to multiple locations at once which stores can't.

As a follow up, we can likely sink the intrinsic handling into the generic code by allowing readnone arguments as well.  I deliberately left that out to minimize conceptual churn.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115829

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/trivial-dse-calls.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115829.394652.patch
Type: text/x-patch
Size: 8539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211215/4d92ae19/attachment.bin>


More information about the llvm-commits mailing list