LLParser: Handle BlockAddresses on-the-fly
[oota-llvm.git] / lib / Transforms / Scalar / MemCpyOptimizer.cpp
index b6bc79228824839eec03c17bf516d6d822daaaae..7c184a4ad2c379c193f15d787811293d3d3021c0 100644 (file)
@@ -684,6 +684,12 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy,
     }
   }
 
+  // Check that src isn't captured by the called function since the
+  // transformation can cause aliasing issues in that case.
+  for (unsigned i = 0, e = CS.arg_size(); i != e; ++i)
+    if (CS.getArgument(i) == cpySrc && !CS.doesNotCapture(i))
+      return false;
+
   // Since we're changing the parameter to the callsite, we need to make sure
   // that what would be the new parameter dominates the callsite.
   DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();