summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
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/CodeGen/AsmPrinter/DwarfExpression.h
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/CodeGen/AsmPrinter/DwarfExpression.h')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h51
1 files changed, 29 insertions, 22 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 06fa59bced1..b24074bc918 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -76,7 +76,6 @@ public:
/// entry.
class DwarfExpression {
protected:
- // Various convenience accessors that extract things out of AsmPrinter.
unsigned DwarfVersion;
public:
@@ -98,10 +97,14 @@ public:
/// Emit an (double-)indirect dwarf register operation.
void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false);
- /// Emit DW_OP_piece operation.
+ /// Emit a DW_OP_piece operation for a variable fragment.
+ /// \param OffsetInBits This is the offset where the fragment appears
+ /// inside the *source variable*.
void AddOpPiece(unsigned SizeInBits, unsigned OffsetInBits = 0);
+
/// Emit a shift-right dwarf expression.
void AddShr(unsigned ShiftBy);
+
/// Emit a DW_OP_stack_value, if supported.
///
/// The proper way to describe a constant value is DW_OP_constu <const>,
@@ -121,22 +124,22 @@ public:
int Offset = 0);
/// Emit a partial DWARF register operation.
- /// \param MachineReg the register
- /// \param PieceSizeInBits size and
- /// \param PieceOffsetInBits offset of the piece in bits, if this is one
- /// piece of an aggregate value.
///
- /// If size and offset is zero an operation for the entire
- /// register is emitted: Some targets do not provide a DWARF
- /// register number for every register. If this is the case, this
- /// function will attempt to emit a DWARF register by emitting a
- /// piece of a super-register or by piecing together multiple
- /// subregisters that alias the register.
+ /// \param MachineReg the register,
+ /// \param FragmentSizeInBits size and
+ /// \param FragmentOffsetInBits offset of the fragment in bits, if this is
+ /// a fragment of an aggregate value.
+ ///
+ /// If size and offset is zero an operation for the entire register is
+ /// emitted: Some targets do not provide a DWARF register number for every
+ /// register. If this is the case, this function will attempt to emit a DWARF
+ /// register by emitting a fragment of a super-register or by piecing together
+ /// multiple subregisters that alias the register.
///
/// \return false if no DWARF register exists for MachineReg.
- bool AddMachineRegPiece(const TargetRegisterInfo &TRI, unsigned MachineReg,
- unsigned PieceSizeInBits = 0,
- unsigned PieceOffsetInBits = 0);
+ bool AddMachineRegFragment(const TargetRegisterInfo &TRI, unsigned MachineReg,
+ unsigned FragmentSizeInBits = 0,
+ unsigned FragmentOffsetInBits = 0);
/// Emit a signed constant.
void AddSignedConstant(int64_t Value);
@@ -149,17 +152,21 @@ public:
/// the prefix of a DwarfExpression if a more efficient representation for
/// combining the register location and the first operation exists.
///
- /// \param PieceOffsetInBits If this is one piece out of a fragmented
- /// location, this is the offset of the piece inside the entire variable.
- /// \return false if no DWARF register exists for MachineReg.
+ /// \param FragmentOffsetInBits If this is one fragment out of a fragmented
+ /// location, this is the offset of the
+ /// fragment inside the entire variable.
+ /// \return false if no DWARF register exists
+ /// for MachineReg.
bool AddMachineRegExpression(const TargetRegisterInfo &TRI,
DIExpressionCursor &Expr, unsigned MachineReg,
- unsigned PieceOffsetInBits = 0);
+ unsigned FragmentOffsetInBits = 0);
/// Emit all remaining operations in the DIExpressionCursor.
- /// \param PieceOffsetInBits If this is one piece out of a fragmented
- /// location, this is the offset of the piece inside the entire variable.
+ ///
+ /// \param FragmentOffsetInBits If this is one fragment out of multiple
+ /// locations, this is the offset of the
+ /// fragment inside the entire variable.
void AddExpression(DIExpressionCursor &&Expr,
- unsigned PieceOffsetInBits = 0);
+ unsigned FragmentOffsetInBits = 0);
};
/// DwarfExpression implementation for .debug_loc entries.
OpenPOWER on IntegriCloud