diff options
author | Duncan Sands <baldrick@free.fr> | 2012-10-04 13:53:21 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-10-04 13:53:21 +0000 |
commit | 7508f946bc4b5022cc4612c8c7492f2e23043976 (patch) | |
tree | cd85fa0a48cf3d8c309f93f60bbbde9b9cccaf2b /lib | |
parent | ffcf6dffee69bd586ab8aa3e24ebbca1d5d279e7 (diff) | |
download | external_llvm-7508f946bc4b5022cc4612c8c7492f2e23043976.zip external_llvm-7508f946bc4b5022cc4612c8c7492f2e23043976.tar.gz external_llvm-7508f946bc4b5022cc4612c8c7492f2e23043976.tar.bz2 |
In my recent change to avoid use of underaligned memory I didn't notice that
cpyDest can be mutated in some cases, which would then cause a crash later if
indeed the memory was underaligned. This brought down several buildbots, so
I guess the underaligned case is much more common than I thought!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/MemCpyOptimizer.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 68be3b7..c02d4ce 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -692,15 +692,15 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy, bool changedArgument = false; for (unsigned i = 0; i < CS.arg_size(); ++i) if (CS.getArgument(i)->stripPointerCasts() == cpySrc) { - if (cpySrc->getType() != cpyDest->getType()) - cpyDest = CastInst::CreatePointerCast(cpyDest, cpySrc->getType(), - cpyDest->getName(), C); + Value *Dest = cpySrc->getType() == cpyDest->getType() ? cpyDest + : CastInst::CreatePointerCast(cpyDest, cpySrc->getType(), + cpyDest->getName(), C); changedArgument = true; - if (CS.getArgument(i)->getType() == cpyDest->getType()) - CS.setArgument(i, cpyDest); + if (CS.getArgument(i)->getType() == Dest->getType()) + CS.setArgument(i, Dest); else - CS.setArgument(i, CastInst::CreatePointerCast(cpyDest, - CS.getArgument(i)->getType(), cpyDest->getName(), C)); + CS.setArgument(i, CastInst::CreatePointerCast(Dest, + CS.getArgument(i)->getType(), Dest->getName(), C)); } if (!changedArgument) |