aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/MemCpyOptimizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/MemCpyOptimizer.cpp')
-rw-r--r--lib/Transforms/Scalar/MemCpyOptimizer.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 9a39c8fd29..d6e5f3964b 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -668,18 +668,24 @@ bool MemCpyOpt::processMemCpy(MemCpyInst* M) {
CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M);
+
+ // If C and M don't interfere, then this is a valid transformation. If they
+ // did, this would mean that the two sources overlap, which would be bad.
if (MD.getDependency(C) == MDep) {
MD.dropInstruction(M);
M->eraseFromParent();
+
+ NumMemCpyInstr++;
+
return true;
}
+ // Otherwise, there was no point in doing this, so we remove the call we
+ // inserted and act like nothing happened.
MD.removeInstruction(C);
C->eraseFromParent();
- NumMemCpyInstr++;
-
- return true;
+ return false;
}
// MemCpyOpt::runOnFunction - This is the main transformation entry point for a