[PATCH] D147025: [InstCombine] Teach alloca replacement to handle `addrspacecast`

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 08:19:17 PDT 2023


hliao added a comment.

a new keep test is added.



================
Comment at: llvm/test/Transforms/InstCombine/ptr-replace-alloca.ll:438
+;
+  %alloca = alloca [32 x i8], addrspace(1)
+  call void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) %alloca, ptr @g1, i64 32, i1 false)
----------------
yaxunl wrote:
> if half of %alloca is filled with @g1, and half of %alloca is filled with @g2, will it be replaced in the call of @readonly_caller? do we need a test for that?
it won't replace that alloca as `isOnlyCopiedFromConstantMemory` bails out if more than one copy to alloca (including pointers calculated from GEPs) is found. Even if we could find that's the safe case as the copies from g1 and g2 won't overlap, that initialization of the alloca is way complicated to be handled in this scenario (passing through a function call). For other scenarios, I hope SROA could slice that [32 x i8] alloca into 2 smaller ones. But, it still won't be handled here directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147025



More information about the llvm-commits mailing list