[PATCH] D146327: [ArgPromotion] Remove dead code produced by removing dead arguments

Jeffrey Byrnes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 13:18:59 PDT 2023


jrbyrnes created this revision.
jrbyrnes added reviewers: arsenm, nikic.
Herald added subscribers: ormris, StephenFan, hiraditya.
Herald added a project: All.
jrbyrnes requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

ArgPromotion currently produces phantom / dead loads. A good example of this is store-into-inself.ll. First, ArgPromo finds the promotable argument %p in @l. Then it inserts a load of %p in the caller, and passes instead the loaded value / transforms the function body. PromoteMem2Reg is able to optimize out the entire function body, resulting in an unused argument. In a subsequent ArgPromotion pass, it removes the dead argument, resulting in a dead load in the caller. These dead loads may reduce effectiveness of other transformations (e.g. SimplifyCFG, MergedLoadStoreMotion).

This patch removes loads and geps that are made dead in the caller after removal of dead args.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146327

Files:
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/test/Transforms/ArgumentPromotion/propagate-remove-dead-args.ll
  llvm/test/Transforms/ArgumentPromotion/store-into-inself.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146327.506187.patch
Type: text/x-patch
Size: 6076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230317/bde04b95/attachment.bin>


More information about the llvm-commits mailing list