[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Evan Cheng evan.cheng at apple.com
Thu Feb 16 15:11:54 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.163 -> 1.164
---
Log message:

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.


---
Diffs of the changes:  (+10 -4)

 SelectionDAGISel.cpp |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.163 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.164
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.163	Thu Feb 16 02:27:55 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Thu Feb 16 17:11:42 2006
@@ -1658,9 +1658,10 @@
       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 @@
                  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 @@
           unsigned VTSize = getSizeInBits(VT) / 8;
           SDOperand Value, Chain, Store;
 
-          if (!Str.empty()) {
+          if (CopyFromStr) {
             Value = getMemsetStringVal(VT, DAG, TLI, Str, SrcOff);
             Chain = getRoot();
             Store =






More information about the llvm-commits mailing list