mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Fix an assertion in MemCpyOpt pass.
The MemCpyOpt pass is capable of optimizing: callee(&S); copy N bytes from S to D. into: callee(&D); subject to some legality constraints. Assertion is triggered when the compiler tries to evalute "sizeof(typeof(D))", while D is an opaque-typed, 'sret' formal argument of function being compiled. i.e. the signature of the func being compiled is something like this: T caller(...,%opaque* noalias nocapture sret %D, ...) The fix is that when come across such situation, instead of calling some utility functions to get the size of D's type (which will crash), we simply assume D has at least N bytes as implified by the copy-instruction. rdar://14073661 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183584 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -626,8 +626,10 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy,
|
||||
return false;
|
||||
|
||||
Type *StructTy = cast<PointerType>(A->getType())->getElementType();
|
||||
uint64_t destSize = TD->getTypeAllocSize(StructTy);
|
||||
|
||||
// If StructTy is an opaque type, it should have at least <cpyLen> bytes,
|
||||
// as implified by the copy-instruction.
|
||||
uint64_t destSize = StructTy->isSized() ?
|
||||
TD->getTypeAllocSize(StructTy) : cpyLen;
|
||||
if (destSize < srcSize)
|
||||
return false;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user