summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2014-07-14 18:52:02 +0000
committerNick Lewycky <nicholas@mxc.ca>2014-07-14 18:52:02 +0000
commit703e488ed9229ac50a54c69f207074e7ec0715bd (patch)
tree90f71c39d5a340714f87f54c9a7a81c3bf8698bd /llvm/lib
parent0e767b16f92174dfa831fc7bd910394dddbb6016 (diff)
downloadbcm5719-llvm-703e488ed9229ac50a54c69f207074e7ec0715bd.tar.gz
bcm5719-llvm-703e488ed9229ac50a54c69f207074e7ec0715bd.zip
Don't eliminate memcpy's when the address of the pointer may itself be relevant. Fixes PR18304. Patch by David Wiberg!
llvm-svn: 212970
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index b6bc7922882..7c184a4ad2c 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -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();
OpenPOWER on IntegriCloud