diff options
Diffstat (limited to 'lldb/source/Expression/IRForTarget.cpp')
-rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index db0cdba463a..26b522d0fb2 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -1551,6 +1551,12 @@ IRForTarget::MaterializeInternalVariable (GlobalVariable *global_variable) llvm::Type *initializer_type = initializer->getType(); size_t size = m_target_data->getTypeAllocSize(initializer_type); + size_t align = m_target_data->getPrefTypeAlignment(initializer_type); + + const size_t mask = (align - 1); + uint64_t aligned_offset = (offset + mask) & ~mask; + m_data_allocator->GetStream().PutNHex8(aligned_offset - offset, 0); + offset = aligned_offset; lldb_private::DataBufferHeap data(size, '\0'); @@ -2060,6 +2066,7 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block) llvm::Instruction *inst = *user_iter; ConstantFP *operand_constant_fp = dyn_cast<ConstantFP>(operand_val); + Type *operand_type = operand_constant_fp->getType(); if (operand_constant_fp) { @@ -2105,6 +2112,13 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block) uint64_t offset = m_data_allocator->GetStream().GetSize(); + size_t align = m_target_data->getPrefTypeAlignment(operand_type); + + const size_t mask = (align - 1); + uint64_t aligned_offset = (offset + mask) & ~mask; + m_data_allocator->GetStream().PutNHex8(aligned_offset - offset, 0); + offset = aligned_offset; + m_data_allocator->GetStream().Write(data.GetBytes(), operand_data_size); llvm::Type *fp_ptr_ty = operand_constant_fp->getType()->getPointerTo(); |