mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Fix broken invariant
Summary: A Copy with a source that is zeros is the same as a Set of zeros. This fixes the invariant that SrcAlign should always be non-null. Reviewers: courbet Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73791
This commit is contained in:
parent
290c00761d
commit
3b360aa73f
@ -125,6 +125,8 @@ struct MemOp {
|
||||
static MemOp Copy(uint64_t Size, bool DstAlignCanChange, unsigned DstAlign,
|
||||
unsigned SrcAlign, bool IsVolatile,
|
||||
bool MemcpyStrSrc = false) {
|
||||
assert(DstAlign && "Destination alignment should be set");
|
||||
assert(SrcAlign && "Source alignment should be set");
|
||||
return {
|
||||
/*.Size =*/Size,
|
||||
/*.DstAlign =*/DstAlignCanChange ? 0 : DstAlign,
|
||||
@ -137,6 +139,7 @@ struct MemOp {
|
||||
}
|
||||
static MemOp Set(uint64_t Size, bool DstAlignCanChange, unsigned DstAlign,
|
||||
bool IsZeroMemset, bool IsVolatile) {
|
||||
assert(DstAlign && "Destination alignment should be set");
|
||||
return {
|
||||
/*.Size =*/Size,
|
||||
/*.DstAlign =*/DstAlignCanChange ? 0 : DstAlign,
|
||||
|
@ -5908,12 +5908,14 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl,
|
||||
bool CopyFromConstant = isMemSrcFromConstant(Src, Slice);
|
||||
bool isZeroConstant = CopyFromConstant && Slice.Array == nullptr;
|
||||
unsigned Limit = AlwaysInline ? ~0U : TLI.getMaxStoresPerMemcpy(OptSize);
|
||||
const MemOp Op = isZeroConstant
|
||||
? MemOp::Set(Size, DstAlignCanChange, Alignment,
|
||||
/*IsZeroMemset*/ true, isVol)
|
||||
: MemOp::Copy(Size, DstAlignCanChange, Alignment,
|
||||
SrcAlign, isVol, CopyFromConstant);
|
||||
if (!TLI.findOptimalMemOpLowering(
|
||||
MemOps, Limit,
|
||||
MemOp::Copy(Size, DstAlignCanChange, Alignment,
|
||||
isZeroConstant ? 0 : SrcAlign, isVol, CopyFromConstant),
|
||||
DstPtrInfo.getAddrSpace(), SrcPtrInfo.getAddrSpace(),
|
||||
MF.getFunction().getAttributes()))
|
||||
MemOps, Limit, Op, DstPtrInfo.getAddrSpace(),
|
||||
SrcPtrInfo.getAddrSpace(), MF.getFunction().getAttributes()))
|
||||
return SDValue();
|
||||
|
||||
if (DstAlignCanChange) {
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
define void @test1() {
|
||||
; CHECK-LABEL: @test1
|
||||
; CHECK: adrp
|
||||
; CHECK: ldr q0
|
||||
; CHECK: str q0
|
||||
; CHECK: ret
|
||||
entry:
|
||||
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 undef, i8* align 8 bitcast (%structA* @stubA to i8*), i64 48, i1 false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user