summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorShuxin Yang <shuxin.llvm@gmail.com>2013-06-07 22:45:21 +0000
committerShuxin Yang <shuxin.llvm@gmail.com>2013-06-07 22:45:21 +0000
commitbd254f26012752426104588640bccb85d086d660 (patch)
treec8e4df92ff941c3333bef721f4fa4407302d2171 /llvm/lib/Transforms
parentf60b8ceb7ee526a4d74ff01ac98cff6089543ac4 (diff)
downloadbcm5719-llvm-bd254f26012752426104588640bccb85d086d660.tar.gz
bcm5719-llvm-bd254f26012752426104588640bccb85d086d660.zip
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 llvm-svn: 183584
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index be0f0e8a25f..8600c9ebf79 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -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 {
OpenPOWER on IntegriCloud