summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-31 04:39:22 +0000
committerChris Lattner <sabre@nondot.org>2012-01-31 04:39:22 +0000
commit983005f51b224448b59dee765ea99aa4fa5a1735 (patch)
tree66fa1f0a3c5c8b0fa8e45a85a78f4b69413846f7 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent236b357361331b0bbdd5402d4e97784a4d2808e6 (diff)
downloadbcm5719-llvm-983005f51b224448b59dee765ea99aa4fa5a1735.tar.gz
bcm5719-llvm-983005f51b224448b59dee765ea99aa4fa5a1735.zip
rework this logic to not depend on the last argument to GetConstantStringInfo,
which is going away. llvm-svn: 149348
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 18de13dc0a9..6b6f7bf10d7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3323,7 +3323,10 @@ static SDValue getMemsetStringVal(EVT VT, DebugLoc dl, SelectionDAG &DAG,
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 @@ static bool isMemSrcFromString(SDValue Src, std::string &Str) {
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;
}
OpenPOWER on IntegriCloud