diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-02-16 23:11:42 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-02-16 23:11:42 +0000 |
commit | cffbb5174f283d123d6bfc582292f4a9c84cb3ed (patch) | |
tree | 8907b04ad78593613e4b3b75d7565b554e8ef190 /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | |
parent | fe5cb19405794e478b944581c3a7be5c29cbaa0e (diff) |
Dumb bug. Code sees a memcpy from X+c so it increments src offset. But it
turns out not to point to a constant string but it forgot change the offset
back.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26242 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 78f5623aed..0da19dfe57 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -1658,9 +1658,10 @@ void SelectionDAGLowering::visitMemIntrinsic(CallInst &I, unsigned Op) { if (MeetsMaxMemopRequirement(MemOps, TLI.getMaxStoresPerMemcpy(), Size->getValue(), Align, TLI)) { unsigned NumMemOps = MemOps.size(); - unsigned SrcOff = 0, DstOff = 0; + unsigned SrcOff = 0, DstOff = 0, SrcDelta = 0; GlobalAddressSDNode *G = NULL; std::string Str; + bool CopyFromStr = false; if (Op2.getOpcode() == ISD::GlobalAddress) G = cast<GlobalAddressSDNode>(Op2); @@ -1668,12 +1669,17 @@ void SelectionDAGLowering::visitMemIntrinsic(CallInst &I, unsigned Op) { Op2.getOperand(0).getOpcode() == ISD::GlobalAddress && Op2.getOperand(1).getOpcode() == ISD::Constant) { G = cast<GlobalAddressSDNode>(Op2.getOperand(0)); - SrcOff += cast<ConstantSDNode>(Op2.getOperand(1))->getValue(); + SrcDelta = cast<ConstantSDNode>(Op2.getOperand(1))->getValue(); } if (G) { GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getGlobal()); - if (GV) + if (GV) { Str = getStringValue(GV); + if (!Str.empty()) { + CopyFromStr = true; + SrcOff += SrcDelta; + } + } } for (unsigned i = 0; i < NumMemOps; i++) { @@ -1681,7 +1687,7 @@ void SelectionDAGLowering::visitMemIntrinsic(CallInst &I, unsigned Op) { unsigned VTSize = getSizeInBits(VT) / 8; SDOperand Value, Chain, Store; - if (!Str.empty()) { + if (CopyFromStr) { Value = getMemsetStringVal(VT, DAG, TLI, Str, SrcOff); Chain = getRoot(); Store = |