diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-11-18 06:41:51 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-11-18 06:41:51 +0000 |
| commit | ac5701319b417ec8d3f81f2312d9bf8c26ec6e86 (patch) | |
| tree | b5d53175bf84ffb035398d6df8033d0d52cbae59 /llvm/lib | |
| parent | 7decc9e4ea6c56ffce14d25f542f5eda3eeba97a (diff) | |
| download | bcm5719-llvm-ac5701319b417ec8d3f81f2312d9bf8c26ec6e86.tar.gz bcm5719-llvm-ac5701319b417ec8d3f81f2312d9bf8c26ec6e86.zip | |
allow eliminating an alloca that is just copied from an constant global
if it is passed as a byval argument. The byval argument will just be a
read, so it is safe to read from the original global instead. This allows
us to promote away the %agg.tmp alloca in PR8582
llvm-svn: 119686
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index fe40bcc22d5..1bec443513b 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1811,11 +1811,18 @@ static bool isOnlyCopiedFromConstantGlobal(Value *V, MemTransferInst *&TheCopy, continue; } - // If this is a readonly/readnone call site, then we know it is just a load - // and we can ignore it. - if (CallSite CS = U) + if (CallSite CS = U) { + // If this is a readonly/readnone call site, then we know it is just a + // load and we can ignore it. if (CS.onlyReadsMemory()) continue; + + // If this is being passed as a byval argument, the caller is making a + // copy, so it is only a read of the alloca. + unsigned ArgNo = CS.getArgumentNo(UI); + if (CS.paramHasAttr(ArgNo+1, Attribute::ByVal)) + continue; + } // If this is isn't our memcpy/memmove, reject it as something we can't // handle. |

