diff options
author | Duncan Sands <baldrick@free.fr> | 2012-10-05 07:29:46 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-10-05 07:29:46 +0000 |
commit | 933db779a260c59d016450ea5468ede05413573a (patch) | |
tree | 94b133467bb372926ec3066d73dfbd917431d3df /llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | |
parent | abf3febad3957cf647d5344f8b4f0aa59927a1bb (diff) | |
download | bcm5719-llvm-933db779a260c59d016450ea5468ede05413573a.tar.gz bcm5719-llvm-933db779a260c59d016450ea5468ede05413573a.zip |
Move this test a bit later, after the point at which we know that we either
have an alloca or a parameter, since then the alloca test should make sense
to readers, while before it probably appears too specific. No functionality
change.
llvm-svn: 165306
Diffstat (limited to 'llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index c02d4cec4cf..fba4aae0dae 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -605,16 +605,6 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy, if (cpyLen < srcSize) return false; - // Check that dest points to memory that is at least as aligned as src. - unsigned srcAlign = srcAlloca->getAlignment(); - if (!srcAlign) - srcAlign = TD->getABITypeAlignment(srcAlloca->getAllocatedType()); - bool isDestSufficientlyAligned = srcAlign <= cpyAlign; - // If dest is not aligned enough and we can't increase its alignment then - // bail out. - if (!isDestSufficientlyAligned && !isa<AllocaInst>(cpyDest)) - return false; - // Check that accessing the first srcSize bytes of dest will not cause a // trap. Otherwise the transform is invalid since it might cause a trap // to occur earlier than it otherwise would. @@ -644,6 +634,16 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy, return false; } + // Check that dest points to memory that is at least as aligned as src. + unsigned srcAlign = srcAlloca->getAlignment(); + if (!srcAlign) + srcAlign = TD->getABITypeAlignment(srcAlloca->getAllocatedType()); + bool isDestSufficientlyAligned = srcAlign <= cpyAlign; + // If dest is not aligned enough and we can't increase its alignment then + // bail out. + if (!isDestSufficientlyAligned && !isa<AllocaInst>(cpyDest)) + return false; + // Check that src is not accessed except via the call and the memcpy. This // guarantees that it holds only undefined values when passed in (so the final // memcpy can be dropped), that it is not read or written between the call and |