[llvm-commits] [llvm] r149348 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner sabre at nondot.org
Mon Jan 30 20:39:22 PST 2012


Author: lattner
Date: Mon Jan 30 22:39:22 2012
New Revision: 149348

URL: http://llvm.org/viewvc/llvm-project?rev=149348&view=rev
Log:
rework this logic to not depend on the last argument to GetConstantStringInfo,
which is going away.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=149348&r1=149347&r2=149348&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Jan 30 22:39:22 2012
@@ -3323,7 +3323,10 @@
   if (TLI.isLittleEndian())
     Offset = Offset + MSB - 1;
   for (unsigned i = 0; i != MSB; ++i) {
-    Val = (Val << 8) | (unsigned char)Str[Offset];
+    Val = (Val << 8);
+    
+    if (Offset < Str.size())
+      Val |= (unsigned char)Str[Offset];
     Offset += TLI.isLittleEndian() ? -1 : 1;
   }
   return DAG.getConstant(Val, VT);
@@ -3354,9 +3357,12 @@
   if (!G)
     return false;
 
-  const GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getGlobal());
-  if (GV && GetConstantStringInfo(GV, Str, SrcDelta, false))
-    return true;
+  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getGlobal()))
+    if (GetConstantStringInfo(GV, Str, SrcDelta)) {
+      // The nul can also be read.
+      Str.push_back(0);
+      return true;
+    }
 
   return false;
 }





More information about the llvm-commits mailing list