[llvm] [SROA] Rewrite invariant group intrinsics after splitting alloca (PR #107557)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 06:56:58 PDT 2024
================
@@ -3531,8 +3531,19 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
return true;
}
- if (II.isLaunderOrStripInvariantGroup())
+ if (II.isLaunderOrStripInvariantGroup()) {
+ Value *AdjustedPtr = getNewAllocaSlicePtr(IRB, OldPtr->getType());
+ Value *New = nullptr;
+ if (II.getIntrinsicID() == Intrinsic::launder_invariant_group)
+ New = IRB.CreateLaunderInvariantGroup(AdjustedPtr);
+ else if (II.getIntrinsicID() == Intrinsic::strip_invariant_group)
+ New = IRB.CreateStripInvariantGroup(AdjustedPtr);
+
+ New->takeName(&II);
+ II.replaceAllUsesWith(New);
----------------
antoniofrighetto wrote:
Oh, you mean the case where we launder only a field of the alloca (not sure if this makes sense though?)
```llvm
define void @memcpy_after_laundering_alloca_2(ptr %ptr) {
%alloca = alloca { i64, i64 }, align 8
%field2_ptr = getelementptr inbounds { i64, i64 }, ptr %alloca, i32 0, i32 1
%launder = call ptr @llvm.launder.invariant.group.p0(ptr %field2_ptr)
call void @llvm.memcpy.p0.p0.i64(ptr %launder, ptr %ptr, i64 8, i1 false)
ret void
}
```
https://github.com/llvm/llvm-project/pull/107557
More information about the llvm-commits
mailing list