summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-12-05 18:04:47 +0000
committerAdrian Prantl <aprantl@apple.com>2016-12-05 18:04:47 +0000
commit941fa7588bbee856a8d3f634c5b88f101089d30f (patch)
treea27a566046fe17ba1ab5691911b2468395a91e52 /llvm/lib/IR
parentfc78d7cb8e5c0c849950fca7d69d81485f3513e1 (diff)
downloadbcm5719-llvm-941fa7588bbee856a8d3f634c5b88f101089d30f.tar.gz
bcm5719-llvm-941fa7588bbee856a8d3f634c5b88f101089d30f.zip
[DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation
so we can stop using DW_OP_bit_piece with the wrong semantics. The entire back story can be found here: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20161114/405934.html The gist is that in LLVM we've been misinterpreting DW_OP_bit_piece's offset field to mean the offset into the source variable rather than the offset into the location at the top the DWARF expression stack. In order to be able to fix this in a subsequent patch, this patch introduces a dedicated DW_OP_LLVM_fragment operation with the semantics that we used to apply to DW_OP_bit_piece, which is what we actually need while inside of LLVM. This patch is complete with a bitcode upgrade for expressions using the old format. It does not yet fix the DWARF backend to use DW_OP_bit_piece correctly. Implementation note: We discussed several options for implementing this, including reserving a dedicated field in DIExpression for the fragment size and offset, but using an custom operator at the end of the expression works just fine and is more efficient because we then only pay for it when we need it. Differential Revision: https://reviews.llvm.org/D27361 rdar://problem/29335809 llvm-svn: 288683
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp4
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp18
-rw-r--r--llvm/lib/IR/Verifier.cpp18
3 files changed, 20 insertions, 20 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index aa67da2a3e0..650a255b6df 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -616,9 +616,9 @@ DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
return createExpression(Addr);
}
-DIExpression *DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
+DIExpression *DIBuilder::createFragmentExpression(unsigned OffsetInBytes,
unsigned SizeInBytes) {
- uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
+ uint64_t Addr[] = {dwarf::DW_OP_LLVM_fragment, OffsetInBytes, SizeInBytes};
return DIExpression::get(VMContext, Addr);
}
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 278eb898966..fe61c279778 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -559,7 +559,7 @@ DIExpression *DIExpression::getImpl(LLVMContext &Context,
unsigned DIExpression::ExprOperand::getSize() const {
switch (getOp()) {
- case dwarf::DW_OP_bit_piece:
+ case dwarf::DW_OP_LLVM_fragment:
return 3;
case dwarf::DW_OP_constu:
case dwarf::DW_OP_plus:
@@ -580,9 +580,9 @@ bool DIExpression::isValid() const {
switch (I->getOp()) {
default:
return false;
- case dwarf::DW_OP_bit_piece:
+ case dwarf::DW_OP_LLVM_fragment:
case dwarf::DW_OP_stack_value:
- // We only support bit piece and stack value expressions which appear at
+ // We only support fragment and stack value expressions which appear at
// the end.
return I->get() + I->getSize() == E->get();
case dwarf::DW_OP_constu:
@@ -595,21 +595,21 @@ bool DIExpression::isValid() const {
return true;
}
-bool DIExpression::isBitPiece() const {
+bool DIExpression::isFragment() const {
assert(isValid() && "Expected valid expression");
if (unsigned N = getNumElements())
if (N >= 3)
- return getElement(N - 3) == dwarf::DW_OP_bit_piece;
+ return getElement(N - 3) == dwarf::DW_OP_LLVM_fragment;
return false;
}
-uint64_t DIExpression::getBitPieceOffset() const {
- assert(isBitPiece() && "Expected bit piece");
+uint64_t DIExpression::getFragmentOffsetInBits() const {
+ assert(isFragment() && "Expected fragment");
return getElement(getNumElements() - 2);
}
-uint64_t DIExpression::getBitPieceSize() const {
- assert(isBitPiece() && "Expected bit piece");
+uint64_t DIExpression::getFragmentSizeInBits() const {
+ assert(isFragment() && "Expected fragment");
return getElement(getNumElements() - 1);
}
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 2f819f78c21..6f7e344b1b3 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -483,7 +483,7 @@ private:
void verifyFrameRecoverIndices();
void verifySiblingFuncletUnwinds();
- void verifyBitPieceExpression(const DbgInfoIntrinsic &I);
+ void verifyFragmentExpression(const DbgInfoIntrinsic &I);
/// Module-level debug info verification...
void verifyCompileUnits();
@@ -3826,7 +3826,7 @@ void Verifier::visitInstruction(Instruction &I) {
}
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&I))
- verifyBitPieceExpression(*DII);
+ verifyFragmentExpression(*DII);
InstsInThisBlock.insert(&I);
}
@@ -4307,7 +4307,7 @@ static uint64_t getVariableSize(const DILocalVariable &V) {
return 0;
}
-void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I) {
+void Verifier::verifyFragmentExpression(const DbgInfoIntrinsic &I) {
DILocalVariable *V;
DIExpression *E;
if (auto *DVI = dyn_cast<DbgValueInst>(&I)) {
@@ -4324,7 +4324,7 @@ void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I) {
return;
// Nothing to do if this isn't a bit piece expression.
- if (!E->isBitPiece())
+ if (!E->isFragment())
return;
// The frontend helps out GDB by emitting the members of local anonymous
@@ -4342,11 +4342,11 @@ void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I) {
if (!VarSize)
return;
- unsigned PieceSize = E->getBitPieceSize();
- unsigned PieceOffset = E->getBitPieceOffset();
- AssertDI(PieceSize + PieceOffset <= VarSize,
- "piece is larger than or outside of variable", &I, V, E);
- AssertDI(PieceSize != VarSize, "piece covers entire variable", &I, V, E);
+ unsigned FragSize = E->getFragmentSizeInBits();
+ unsigned FragOffset = E->getFragmentOffsetInBits();
+ AssertDI(FragSize + FragOffset <= VarSize,
+ "fragment is larger than or outside of variable", &I, V, E);
+ AssertDI(FragSize != VarSize, "fragment covers entire variable", &I, V, E);
}
void Verifier::verifyCompileUnits() {
OpenPOWER on IntegriCloud