[PATCH] D125485: [ArgPromotion] Unify byval promotion with non-byval

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 08:13:33 PDT 2022


nikic added a comment.

In D125485#3515850 <https://reviews.llvm.org/D125485#3515850>, @psamolysov wrote:

> Unfortunately, `PromoteMemToReg` optimizes almost nothing. If there is a `GEP` from an `alloca`, and this `GEP` is used by `store`, for example, the `isAllocaPromotable` function returns `false` because the `if (!onlyUsedByLifetimeMarkersOrDroppableInsts(GEPI))` (which allows intrinsics as `GEP` users only) check fails. I always use `store` instructions to write the new argument values into the `alloca`, so this check will always fail for structures and will pass for primitives only. I've tried to run the `mem2reg` pass using the `opt` utility and get the same result, my IR generated by the `ArgumentPromotion` pass looks as not optimized. The SROA pass works fine, but I'm not sure is this a good idea to run SROA directly from another pass (the `PromoteMemToReg` function creates an instance of the `PromoteMem2Reg` class and calls its `run` member function but this class is not a pass).

When rewriting to an alloca, I believe that you should end up with only direct loads and stores to the alloca, without any remaining GEPs. There should be one alloca for each ArgPart, not one alloca for all parts. In that case PromoteMemToReg should be able to promote it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125485



More information about the llvm-commits mailing list