diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-08-04 01:19:54 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-08-04 01:19:54 +0000 |
commit | f413d6c7a3b390bead0a65b072c61146234b47cf (patch) | |
tree | 106f89a76d7b9d7278d3dcc05dcdb975879c96c3 /lib/IR/DIBuilder.cpp | |
parent | 1a05d247fa7a220f415a8f7b44ebdc3006f1c88e (diff) |
Teach GlobalSRA to update the debug info for split-up globals.
This is similar to what we are doing in "regular" SROA and creates
DW_OP_LLVM_fragment operations to describe the resulting variables.
rdar://problem/33654891
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310014 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DIBuilder.cpp')
-rw-r--r-- | lib/IR/DIBuilder.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 972b6a22324..f4702b377f9 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -668,10 +668,31 @@ DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) { return createExpression(Addr); } -DIExpression *DIBuilder::createFragmentExpression(unsigned OffsetInBytes, - unsigned SizeInBytes) { - uint64_t Addr[] = {dwarf::DW_OP_LLVM_fragment, OffsetInBytes, SizeInBytes}; - return DIExpression::get(VMContext, Addr); +DIExpression *DIBuilder::createFragmentExpression(unsigned OffsetInBits, + unsigned SizeInBits, + const DIExpression *Expr) { + SmallVector<uint64_t, 8> Ops; + // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment. + if (Expr) { + for (auto Op : Expr->expr_ops()) { + if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) { + // Make the new offset point into the existing fragment. + uint64_t FragmentOffsetInBits = Op.getArg(0); + uint64_t FragmentSizeInBits = Op.getArg(1); + assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) && + "new fragment outside of original fragment"); + OffsetInBits += FragmentOffsetInBits; + break; + } + Ops.push_back(Op.getOp()); + for (unsigned I = 0; I < Op.getNumArgs(); ++I) + Ops.push_back(Op.getArg(I)); + } + } + Ops.push_back(dwarf::DW_OP_LLVM_fragment); + Ops.push_back(OffsetInBits); + Ops.push_back(SizeInBits); + return DIExpression::get(VMContext, Ops); } template <class... Ts> |