diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-14 22:08:54 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-14 22:08:54 -0800 |
commit | 0eed9563513b2e5c2f6494253c6affa2104c5da3 (patch) | |
tree | 56df83e0a5e9009e0c941209c425100cc23f4edb /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 1b775c416b31a0991cb380f398208b3de278e6f9 (diff) |
fix ptr+offset in global constant
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 6338456ad6..9d84eab161 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -2596,17 +2596,17 @@ void CppWriter::parseConstant(std::string name, const Constant* CV, bool calcula GlobalData->push_back(0); } } else { - unsigned Offset = 0; + unsigned Data = 0; if (CE->getOpcode() == Instruction::Add) { - Offset = cast<ConstantInt>(CE->getOperand(1))->getZExtValue(); + Data = cast<ConstantInt>(CE->getOperand(1))->getZExtValue(); CE = dyn_cast<ConstantExpr>(CE->getOperand(0)); } assert(CE->isCast()); - Offset += getRelativeGlobalAddress(name); Value *V = CE->getOperand(0); - unsigned Data = getConstAsOffset(V, getGlobalAddress(name)); + Data += getConstAsOffset(V, getGlobalAddress(name)); union { unsigned i; unsigned char b[sizeof(unsigned)]; } integer; integer.i = Data; + unsigned Offset = getRelativeGlobalAddress(name); assert(Offset+4 <= GlobalData64.size()); for (unsigned i = 0; i < 4; ++i) { GlobalData64[Offset++] = integer.b[i]; |