Skip to content

Commit d238bb8

Browse files
committed
Add comments for the forward offset
1 parent 289b44d commit d238bb8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,11 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
11701170
auto MCopyLoc = MemoryLocation::getForSource(MDep).getWithNewSize(
11711171
MemoryLocation::getForSource(M).Size);
11721172

1173-
// We need to update `MCopyLoc` if an offset exists.
1173+
// When the forwarding offset is greater than 0, we transform
1174+
// memcpy(d1 <- s1)
1175+
// memcpy(d2 <- d1+o)
1176+
// to
1177+
// memcpy(d2 <- s1+o)
11741178
if (MForwardOffset > 0) {
11751179
// The copy destination of `M` maybe can serve as the source of copying.
11761180
std::optional<int64_t> MDestOffset =
@@ -1180,6 +1184,7 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
11801184
else
11811185
CopySource = Builder.CreateInBoundsPtrAdd(
11821186
CopySource, Builder.getInt64(MForwardOffset));
1187+
// We need to update `MCopyLoc` if an offset exists.
11831188
MCopyLoc = MCopyLoc.getWithNewPtr(CopySource);
11841189
if (CopySourceAlign)
11851190
CopySourceAlign = commonAlignment(*CopySourceAlign, MForwardOffset);

0 commit comments

Comments
 (0)