[PATCH] D74083: MemCpyOpt cannot use ABI alignment even if it was not given
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 12:10:52 PST 2020
aqjune created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aqjune added reviewers: gchatelet, lenary, nikic.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=44388 which incorrectly assigns an ABI alignment to memset when there was no explicit alignment given.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74083
Files:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/form-memset.ll
Index: llvm/test/Transforms/MemCpyOpt/form-memset.ll
===================================================================
--- llvm/test/Transforms/MemCpyOpt/form-memset.ll
+++ llvm/test/Transforms/MemCpyOpt/form-memset.ll
@@ -217,7 +217,7 @@
tail call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 12, i1 false)
ret void
; CHECK-LABEL: @test6(
-; CHECK: call void @llvm.memset.p0i8.i64(i8* align 4 %2, i8 0, i64 24, i1 false)
+; CHECK: call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 24, i1 false)
}
; More aggressive heuristic
@@ -280,7 +280,7 @@
ret void
; CHECK-LABEL: @test10(
; CHECK-NOT: memset
-; CHECK: call void @llvm.memset.p0i8.i64(i8* align 1 %P, i8 0, i64 42, i1 false)
+; CHECK: call void @llvm.memset.p0i8.i64(i8* %P, i8 0, i64 42, i1 false)
; CHECK-NOT: memset
; CHECK: ret void
}
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -387,13 +387,8 @@
// Get the starting pointer of the block.
StartPtr = Range.StartPtr;
- // Determine alignment
- const Align Alignment = DL.getValueOrABITypeAlignment(
- MaybeAlign(Range.Alignment),
- cast<PointerType>(StartPtr->getType())->getElementType());
-
AMemSet = Builder.CreateMemSet(StartPtr, ByteVal, Range.End - Range.Start,
- Alignment);
+ MaybeAlign(Range.Alignment));
LLVM_DEBUG(dbgs() << "Replace stores:\n"; for (Instruction *SI
: Range.TheStores) dbgs()
<< *SI << '\n';
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74083.242722.patch
Type: text/x-patch
Size: 1741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200205/0d74ab30/attachment.bin>
More information about the llvm-commits
mailing list