mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Allow call-slop optzn for destinations with a suitable dereferenceable attribute
Summary: Currently, call slot optimization requires that if the destination is an argument, the argument has the sret attribute. This is to ensure that the memory access won't trap. In addition to sret, we can also allow the optimization to happen for arguments that have the new dereferenceable attribute, which gives the same guarantee. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5832 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219950 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -634,22 +634,24 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy,
|
||||
if (destSize < srcSize)
|
||||
return false;
|
||||
} else if (Argument *A = dyn_cast<Argument>(cpyDest)) {
|
||||
// If the destination is an sret parameter then only accesses that are
|
||||
// outside of the returned struct type can trap.
|
||||
if (!A->hasStructRetAttr())
|
||||
return false;
|
||||
if (A->getDereferenceableBytes() < srcSize) {
|
||||
// If the destination is an sret parameter then only accesses that are
|
||||
// outside of the returned struct type can trap.
|
||||
if (!A->hasStructRetAttr())
|
||||
return false;
|
||||
|
||||
Type *StructTy = cast<PointerType>(A->getType())->getElementType();
|
||||
if (!StructTy->isSized()) {
|
||||
// The call may never return and hence the copy-instruction may never
|
||||
// be executed, and therefore it's not safe to say "the destination
|
||||
// has at least <cpyLen> bytes, as implied by the copy-instruction",
|
||||
return false;
|
||||
Type *StructTy = cast<PointerType>(A->getType())->getElementType();
|
||||
if (!StructTy->isSized()) {
|
||||
// The call may never return and hence the copy-instruction may never
|
||||
// be executed, and therefore it's not safe to say "the destination
|
||||
// has at least <cpyLen> bytes, as implied by the copy-instruction",
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t destSize = DL->getTypeAllocSize(StructTy);
|
||||
if (destSize < srcSize)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t destSize = DL->getTypeAllocSize(StructTy);
|
||||
if (destSize < srcSize)
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user