diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 002821d0a6..f1c2ecf19d 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Constants.h" -#include "llvm/Analysis/ValueTracking.h" #include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/Intrinsics.h" @@ -2578,7 +2577,8 @@ static SDOperand getMemBasePlusOffset(SDOperand Base, unsigned Offset, /// isMemSrcFromString - Returns true if memcpy source is a string constant. /// -static bool isMemSrcFromString(SDOperand Src, std::string &Str) { +static bool isMemSrcFromString(SDOperand Src, std::string &Str, + uint64_t &SrcOff) { unsigned SrcDelta = 0; GlobalAddressSDNode *G = NULL; if (Src.getOpcode() == ISD::GlobalAddress) @@ -2593,8 +2593,13 @@ static bool isMemSrcFromString(SDOperand Src, std::string &Str) { return false; GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getGlobal()); - if (GV && GetConstantStringInfo(GV, Str, SrcDelta, false)) - return true; + if (GV && GV->isConstant()) { + Str = GV->getStringValue(false); + if (!Str.empty()) { + SrcOff += SrcDelta; + return true; + } + } return false; } @@ -2611,7 +2616,8 @@ bool MeetsMaxMemopRequirement(std::vector<MVT> &MemOps, bool AllowUnalign = TLI.allowsUnalignedMemoryAccesses(); std::string Str; - bool isSrcStr = isMemSrcFromString(Src, Str); + uint64_t SrcOff = 0; + bool isSrcStr = isMemSrcFromString(Src, Str, SrcOff); bool isSrcConst = isa<ConstantSDNode>(Src); MVT VT= TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr); if (VT != MVT::iAny) { @@ -2706,11 +2712,11 @@ static SDOperand getMemcpyLoadsAndStores(SelectionDAG &DAG, return SDOperand(); std::string Str; - bool CopyFromStr = isMemSrcFromString(Src, Str); + uint64_t SrcOff = 0, DstOff = 0; + bool CopyFromStr = isMemSrcFromString(Src, Str, SrcOff); SmallVector<SDOperand, 8> OutChains; unsigned NumMemOps = MemOps.size(); - uint64_t SrcOff = 0, DstOff = 0; for (unsigned i = 0; i < NumMemOps; i++) { MVT VT = MemOps[i]; unsigned VTSize = VT.getSizeInBits() / 8; |