summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DIBuilder.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-08-04 01:19:54 +0000
committerAdrian Prantl <aprantl@apple.com>2017-08-04 01:19:54 +0000
commitfd8c8e9fe68a8cdae41f8d932802877259b64cd3 (patch)
treec2178343d367682f93b945c7b0b964d0ec5bf624 /llvm/lib/IR/DIBuilder.cpp
parent00755362b9cd830a46446cf362b4ecb283ebb179 (diff)
downloadbcm5719-llvm-fd8c8e9fe68a8cdae41f8d932802877259b64cd3.tar.gz
bcm5719-llvm-fd8c8e9fe68a8cdae41f8d932802877259b64cd3.zip
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 llvm-svn: 310014
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 972b6a22324..f4702b377f9 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/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>
OpenPOWER on IntegriCloud