llvm.org GIT mirror llvm / 460dd60
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288683 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 3 years ago
52 changed file(s) with 323 addition(s) and 280 deletion(s). Raw diff Collapse all Expand all
516516 ///
517517 /// \param OffsetInBits Offset of the piece in bits.
518518 /// \param SizeInBits Size of the piece in bits.
519 DIExpression *createBitPieceExpression(unsigned OffsetInBits,
519 DIExpression *createFragmentExpression(unsigned OffsetInBits,
520520 unsigned SizeInBits);
521521
522522 /// Create an expression for a variable that does not have an address, but
19541954 }
19551955
19561956 /// Return whether this is a piece of an aggregate variable.
1957 bool isBitPiece() const;
1958
1959 /// Return the offset of this piece in bits.
1960 uint64_t getBitPieceOffset() const;
1961
1962 /// Return the size of this piece in bits.
1963 uint64_t getBitPieceSize() const;
1957 bool isFragment() const;
1958
1959 /// Return the offset of this fragment in bits.
1960 uint64_t getFragmentOffsetInBits() const;
1961
1962 /// Return the size of this fragment in bits.
1963 uint64_t getFragmentSizeInBits() const;
19641964
19651965 typedef ArrayRef::iterator element_iterator;
19661966 element_iterator elements_begin() const { return getElements().begin(); }
107107 #define HANDLE_DW_OP(ID, NAME) DW_OP_##NAME = ID,
108108 #include "llvm/Support/Dwarf.def"
109109 DW_OP_lo_user = 0xe0,
110 DW_OP_hi_user = 0xff
110 DW_OP_hi_user = 0xff,
111 DW_OP_LLVM_fragment = 0x1000 ///< Only used in LLVM metadata.
111112 };
112113
113114 enum TypeKind {
29992999 if (Record.size() < 1)
30003000 return error("Invalid record");
30013001
3002 IsDistinct = Record[0];
3002 IsDistinct = Record[0] & 1;
3003 bool HasOpFragment = Record[0] & 2;
3004 auto Elts = MutableArrayRef(Record).slice(1);
3005 if (!HasOpFragment)
3006 if (unsigned N = Elts.size())
3007 if (N >= 3 && Elts[N - 3] == dwarf::DW_OP_bit_piece)
3008 Elts[N-3] = dwarf::DW_OP_LLVM_fragment;
3009
30033010 MetadataList.assignValue(
30043011 GET_OR_DISTINCT(DIExpression,
30053012 (Context, makeArrayRef(Record).slice(1))),
17261726 unsigned Abbrev) {
17271727 Record.reserve(N->getElements().size() + 1);
17281728
1729 Record.push_back(N->isDistinct());
1729 const uint64_t HasOpFragmentFlag = 1 << 1;
1730 Record.push_back(N->isDistinct() | HasOpFragmentFlag);
17301731 Record.append(N->elements_begin(), N->elements_end());
17311732
17321733 Stream.EmitRecord(bitc::METADATA_EXPRESSION, Record, Abbrev);
712712 OS << V->getName();
713713
714714 const DIExpression *Expr = MI->getDebugExpression();
715 if (Expr->isBitPiece())
716 OS << " [bit_piece offset=" << Expr->getBitPieceOffset()
717 << " size=" << Expr->getBitPieceSize() << "]";
715 if (Expr->isFragment())
716 OS << " [fragment offset=" << Expr->getFragmentOffsetInBits()
717 << " size=" << Expr->getFragmentSizeInBits() << "]";
718718 OS << " <- ";
719719
720720 // The second operand is only an offset if it's an immediate.
723723
724724 for (unsigned i = 0; i < Expr->getNumElements(); ++i) {
725725 uint64_t Op = Expr->getElement(i);
726 if (Op == dwarf::DW_OP_bit_piece) {
726 if (Op == dwarf::DW_OP_LLVM_fragment) {
727727 // There can't be any operands after this in a valid expression
728728 break;
729729 } else if (Deref) {
190190 "nop (could not find a dwarf register number)");
191191
192192 // Attempt to find a valid super- or sub-register.
193 if (!Expr.AddMachineRegPiece(*MF->getSubtarget().getRegisterInfo(),
194 MLoc.getReg()))
193 if (!Expr.AddMachineRegFragment(*MF->getSubtarget().getRegisterInfo(),
194 MLoc.getReg()))
195195 Expr.EmitOp(dwarf::DW_OP_nop,
196196 "nop (could not find a dwarf register number)");
197197 return;
942942 bool IsSubfield = false;
943943 unsigned StructOffset = 0;
944944
945 // Handle bitpieces.
946 if (DIExpr && DIExpr->isBitPiece()) {
945 // Handle fragments.
946 if (DIExpr && DIExpr->isFragment()) {
947947 IsSubfield = true;
948 StructOffset = DIExpr->getBitPieceOffset() / 8;
948 StructOffset = DIExpr->getFragmentOffsetInBits() / 8;
949949 } else if (DIExpr && DIExpr->getNumElements() > 0) {
950950 continue; // Ignore unrecognized exprs.
951951 }
984984 // This range is valid until the next overlapping bitpiece. In the
985985 // common case, ranges will not be bitpieces, so they will overlap.
986986 auto J = std::next(I);
987 while (J != E && !piecesOverlap(DIExpr, J->first->getDebugExpression()))
987 while (J != E &&
988 !fragmentsOverlap(DIExpr, J->first->getDebugExpression()))
988989 ++J;
989990 if (J != E)
990991 End = getLabelBeforeInsn(J->first);
6262 return LabelsAfterInsn.lookup(MI);
6363 }
6464
65 // Determine the relative position of the pieces described by P1 and P2.
66 // Returns -1 if P1 is entirely before P2, 0 if P1 and P2 overlap,
67 // 1 if P1 is entirely after P2.
68 int DebugHandlerBase::pieceCmp(const DIExpression *P1, const DIExpression *P2) {
69 unsigned l1 = P1->getBitPieceOffset();
70 unsigned l2 = P2->getBitPieceOffset();
71 unsigned r1 = l1 + P1->getBitPieceSize();
72 unsigned r2 = l2 + P2->getBitPieceSize();
65 int DebugHandlerBase::fragmentCmp(const DIExpression *P1,
66 const DIExpression *P2) {
67 unsigned l1 = P1->getFragmentOffsetInBits();
68 unsigned l2 = P2->getFragmentOffsetInBits();
69 unsigned r1 = l1 + P1->getFragmentSizeInBits();
70 unsigned r2 = l2 + P2->getFragmentSizeInBits();
7371 if (r1 <= l2)
7472 return -1;
7573 else if (r2 <= l1)
7876 return 0;
7977 }
8078
81 /// Determine whether two variable pieces overlap.
82 bool DebugHandlerBase::piecesOverlap(const DIExpression *P1, const DIExpression *P2) {
83 if (!P1->isBitPiece() || !P2->isBitPiece())
79 bool DebugHandlerBase::fragmentsOverlap(const DIExpression *P1,
80 const DIExpression *P2) {
81 if (!P1->isFragment() || !P2->isFragment())
8482 return true;
85 return pieceCmp(P1, P2) == 0;
83 return fragmentCmp(P1, P2) == 0;
8684 }
8785
8886 /// If this type is derived from a base type then return base type size.
141139 if (DIVar->isParameter() &&
142140 getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) {
143141 LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
144 if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
145 // Mark all non-overlapping initial pieces.
142 if (Ranges.front().first->getDebugExpression()->isFragment()) {
143 // Mark all non-overlapping initial fragments.
146144 for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
147 const DIExpression *Piece = I->first->getDebugExpression();
145 const DIExpression *Fragment = I->first->getDebugExpression();
148146 if (std::all_of(Ranges.begin(), I,
149147 [&](DbgValueHistoryMap::InstrRange Pred) {
150 return !piecesOverlap(Piece, Pred.first->getDebugExpression());
151 }))
148 return !fragmentsOverlap(
149 Fragment, Pred.first->getDebugExpression());
150 }))
152151 LabelsBeforeInsn[I->first] = Asm->getFunctionBegin();
153152 else
154153 break;
9191 /// Return Label immediately following the instruction.
9292 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
9393
94 /// Determine the relative position of the pieces described by P1 and P2.
95 /// Returns -1 if P1 is entirely before P2, 0 if P1 and P2 overlap,
96 /// 1 if P1 is entirely after P2.
97 static int pieceCmp(const DIExpression *P1, const DIExpression *P2);
94 /// Determine the relative position of the fragments described by P1 and P2.
95 /// Returns -1 if P1 is entirely before P2, 0 if P1 and P2 overlap, 1 if P1 is
96 /// entirely after P2.
97 static int fragmentCmp(const DIExpression *P1, const DIExpression *P2);
9898
99 /// Determine whether two variable pieces overlap.
100 static bool piecesOverlap(const DIExpression *P1, const DIExpression *P2);
99 /// Determine whether two variable fragments overlap.
100 static bool fragmentsOverlap(const DIExpression *P1, const DIExpression *P2);
101101
102102 /// If this type is derived from a base type then return base type size.
103103 static uint64_t getBaseTypeSize(const DITypeRef TyRef);
7171 const ConstantFP *getConstantFP() const { return Constant.CFP; }
7272 const ConstantInt *getConstantInt() const { return Constant.CIP; }
7373 MachineLocation getLoc() const { return Loc; }
74 bool isBitPiece() const { return getExpression()->isBitPiece(); }
74 bool isFragment() const { return getExpression()->isFragment(); }
7575 const DIExpression *getExpression() const { return Expression; }
7676 friend bool operator==(const Value &, const Value &);
7777 friend bool operator<(const Value &, const Value &);
128128 Values.append(Vals.begin(), Vals.end());
129129 sortUniqueValues();
130130 assert(all_of(Values, [](DebugLocEntry::Value V) {
131 return V.isBitPiece();
131 return V.isFragment();
132132 }) && "value must be a piece");
133133 }
134134
171171 llvm_unreachable("unhandled EntryKind");
172172 }
173173
174 /// \brief Compare two pieces based on their offset.
174 /// Compare two fragments based on their offset.
175175 inline bool operator<(const DebugLocEntry::Value &A,
176176 const DebugLocEntry::Value &B) {
177 return A.getExpression()->getBitPieceOffset() <
178 B.getExpression()->getBitPieceOffset();
177 return A.getExpression()->getFragmentOffsetInBits() <
178 B.getExpression()->getFragmentOffsetInBits();
179179 }
180180
181181 }
729729
730730 bool validReg;
731731 if (Location.isReg())
732 validReg = addRegisterOpPiece(*Loc, Location.getReg());
732 validReg = addRegisterFragment(*Loc, Location.getReg());
733733 else
734734 validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset());
735735
775775 llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!");
776776 }
777777
778 /// \brief If this and Next are describing different pieces of the same
778 /// \brief If this and Next are describing different fragments of the same
779779 /// variable, merge them by appending Next's values to the current
780780 /// list of values.
781781 /// Return true if the merge was successful.
783783 if (Begin == Next.Begin) {
784784 auto *FirstExpr = cast(Values[0].Expression);
785785 auto *FirstNextExpr = cast(Next.Values[0].Expression);
786 if (!FirstExpr->isBitPiece() || !FirstNextExpr->isBitPiece())
786 if (!FirstExpr->isFragment() || !FirstNextExpr->isFragment())
787787 return false;
788788
789 // We can only merge entries if none of the pieces overlap any others.
789 // We can only merge entries if none of the fragments overlap any others.
790790 // In doing so, we can take advantage of the fact that both lists are
791791 // sorted.
792792 for (unsigned i = 0, j = 0; i < Values.size(); ++i) {
793793 for (; j < Next.Values.size(); ++j) {
794 int res = DebugHandlerBase::pieceCmp(
794 int res = DebugHandlerBase::fragmentCmp(
795795 cast(Values[i].Expression),
796796 cast(Next.Values[j].Expression));
797797 if (res == 0) // The two expressions overlap, we can't merge.
814814
815815 /// Build the location list for all DBG_VALUEs in the function that
816816 /// describe the same variable. If the ranges of several independent
817 /// pieces of the same variable overlap partially, split them up and
817 /// fragments of the same variable overlap partially, split them up and
818818 /// combine the ranges. The resulting DebugLocEntries are will have
819819 /// strict monotonically increasing begin addresses and will never
820820 /// overlap.
821821 //
822822 // Input:
823823 //
824 // Ranges History [var, loc, piece ofs size]
825 // 0 | [x, (reg0, piece 0, 32)]
826 // 1 | | [x, (reg1, piece 32, 32)] <- IsPieceOfPrevEntry
824 // Ranges History [var, loc, fragment ofs size]
825 // 0 | [x, (reg0, fragment 0, 32)]
826 // 1 | | [x, (reg1, fragment 32, 32)] <- IsFragmentOfPrevEntry
827827 // 2 | | ...
828828 // 3 | [clobber reg0]
829 // 4 [x, (mem, piece 0, 64)] <- overlapping with both previous pieces of
829 // 4 [x, (mem, fragment 0, 64)] <- overlapping with both previous fragments of
830830 // x.
831831 //
832832 // Output:
833833 //
834 // [0-1] [x, (reg0, piece 0, 32)]
835 // [1-3] [x, (reg0, piece 0, 32), (reg1, piece 32, 32)]
836 // [3-4] [x, (reg1, piece 32, 32)]
837 // [4- ] [x, (mem, piece 0, 64)]
834 // [0-1] [x, (reg0, fragment 0, 32)]
835 // [1-3] [x, (reg0, fragment 0, 32), (reg1, fragment 32, 32)]
836 // [3-4] [x, (reg1, fragment 32, 32)]
837 // [4- ] [x, (mem, fragment 0, 64)]
838838 void
839839 DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc,
840840 const DbgValueHistoryMap::InstrRanges &Ranges) {
852852 continue;
853853 }
854854
855 // If this piece overlaps with any open ranges, truncate them.
855 // If this fragment overlaps with any open ranges, truncate them.
856856 const DIExpression *DIExpr = Begin->getDebugExpression();
857857 auto Last = remove_if(OpenRanges, [&](DebugLocEntry::Value R) {
858 return piecesOverlap(DIExpr, R.getExpression());
858 return fragmentsOverlap(DIExpr, R.getExpression());
859859 });
860860 OpenRanges.erase(Last, OpenRanges.end());
861861
877877 DebugLocEntry Loc(StartLabel, EndLabel, Value);
878878 bool couldMerge = false;
879879
880 // If this is a piece, it may belong to the current DebugLocEntry.
881 if (DIExpr->isBitPiece()) {
880 // If this is a fragment, it may belong to the current DebugLocEntry.
881 if (DIExpr->isFragment()) {
882882 // Add this value to the list of open ranges.
883883 OpenRanges.push_back(Value);
884884
885 // Attempt to add the piece to the last entry.
885 // Attempt to add the fragment to the last entry.
886886 if (!DebugLoc.empty())
887887 if (DebugLoc.back().MergeValues(Loc))
888888 couldMerge = true;
890890
891891 if (!couldMerge) {
892892 // Need to add a new DebugLocEntry. Add all values from still
893 // valid non-overlapping pieces.
893 // valid non-overlapping fragments.
894894 if (OpenRanges.size())
895895 Loc.addValues(OpenRanges);
896896
14121412 static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
14131413 ByteStreamer &Streamer,
14141414 const DebugLocEntry::Value &Value,
1415 unsigned PieceOffsetInBits) {
1415 unsigned FragmentOffsetInBits) {
14161416 DIExpressionCursor ExprCursor(Value.getExpression());
14171417 DebugLocDwarfExpression DwarfExpr(AP.getDwarfVersion(), Streamer);
14181418 // Regular entry.
14341434 DwarfExpr.AddMachineRegIndirect(TRI, Loc.getReg(), Loc.getOffset());
14351435 else
14361436 DwarfExpr.AddMachineRegExpression(TRI, ExprCursor, Loc.getReg(),
1437 PieceOffsetInBits);
1437 FragmentOffsetInBits);
14381438 }
14391439 } else if (Value.isConstantFP()) {
14401440 APInt RawBytes = Value.getConstantFP()->getValueAPF().bitcastToAPInt();
14411441 DwarfExpr.AddUnsignedConstant(RawBytes);
14421442 }
1443 DwarfExpr.AddExpression(std::move(ExprCursor), PieceOffsetInBits);
1443 DwarfExpr.AddExpression(std::move(ExprCursor), FragmentOffsetInBits);
14441444 }
14451445
14461446 void DebugLocEntry::finalize(const AsmPrinter &AP,
14491449 DebugLocStream::EntryBuilder Entry(List, Begin, End);
14501450 BufferByteStreamer Streamer = Entry.getStreamer();
14511451 const DebugLocEntry::Value &Value = Values[0];
1452 if (Value.isBitPiece()) {
1453 // Emit all pieces that belong to the same variable and range.
1452 if (Value.isFragment()) {
1453 // Emit all fragments that belong to the same variable and range.
14541454 assert(all_of(Values, [](DebugLocEntry::Value P) {
1455 return P.isBitPiece();
1456 }) && "all values are expected to be pieces");
1455 return P.isFragment();
1456 }) && "all values are expected to be fragments");
14571457 assert(std::is_sorted(Values.begin(), Values.end()) &&
1458 "pieces are expected to be sorted");
1458 "fragments are expected to be sorted");
14591459
14601460 unsigned Offset = 0;
1461 for (auto Piece : Values) {
1462 const DIExpression *Expr = Piece.getExpression();
1463 unsigned PieceOffset = Expr->getBitPieceOffset();
1464 unsigned PieceSize = Expr->getBitPieceSize();
1465 assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
1466 if (Offset < PieceOffset) {
1467 // The DWARF spec seriously mandates pieces with no locations for gaps.
1461 for (auto Fragment : Values) {
1462 const DIExpression *Expr = Fragment.getExpression();
1463 unsigned FragmentOffset = Expr->getFragmentOffsetInBits();
1464 unsigned FragmentSize = Expr->getFragmentSizeInBits();
1465 assert(Offset <= FragmentOffset && "overlapping or duplicate fragments");
1466 if (Offset < FragmentOffset) {
1467 // DWARF represents gaps as pieces with no locations.
14681468 DebugLocDwarfExpression Expr(AP.getDwarfVersion(), Streamer);
1469 Expr.AddOpPiece(PieceOffset-Offset, 0);
1470 Offset += PieceOffset-Offset;
1469 Expr.AddOpPiece(FragmentOffset-Offset, 0);
1470 Offset += FragmentOffset-Offset;
14711471 }
1472 Offset += PieceSize;
1473
1474 emitDebugLocValue(AP, BT, Streamer, Piece, PieceOffset);
1472 Offset += FragmentSize;
1473
1474 emitDebugLocValue(AP, BT, Streamer, Fragment, FragmentOffset);
14751475 }
14761476 } else {
1477 assert(Values.size() == 1 && "only pieces may have >1 value");
1477 assert(Values.size() == 1 && "only fragments may have >1 value");
14781478 emitDebugLocValue(AP, BT, Streamer, Value, 0);
14791479 }
14801480 }
134134 Expr.append(V.Expr.begin(), V.Expr.end());
135135 FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end());
136136 assert(all_of(Expr, [](const DIExpression *E) {
137 return E && E->isBitPiece();
137 return E && E->isFragment();
138138 }) && "conflicting locations for variable");
139139 }
140140
8181 return true;
8282 }
8383
84 bool DwarfExpression::AddMachineRegPiece(const TargetRegisterInfo &TRI,
85 unsigned MachineReg,
86 unsigned PieceSizeInBits,
87 unsigned PieceOffsetInBits) {
84 bool DwarfExpression::AddMachineRegFragment(const TargetRegisterInfo &TRI,
85 unsigned MachineReg,
86 unsigned FragmentSizeInBits,
87 unsigned FragmentOffsetInBits) {
8888 if (!TRI.isPhysicalRegister(MachineReg))
8989 return false;
9090
9393 // If this is a valid register number, emit it.
9494 if (Reg >= 0) {
9595 AddReg(Reg);
96 if (PieceSizeInBits)
97 AddOpPiece(PieceSizeInBits, PieceOffsetInBits);
96 if (FragmentSizeInBits)
97 AddOpPiece(FragmentSizeInBits, FragmentOffsetInBits);
9898 return true;
9999 }
100100
101101 // Walk up the super-register chain until we find a valid number.
102 // For example, EAX on x86_64 is a 32-bit piece of RAX with offset 0.
102 // For example, EAX on x86_64 is a 32-bit fragment of RAX with offset 0.
103103 for (MCSuperRegIterator SR(MachineReg, &TRI); SR.isValid(); ++SR) {
104104 Reg = TRI.getDwarfRegNum(*SR, false);
105105 if (Reg >= 0) {
107107 unsigned Size = TRI.getSubRegIdxSize(Idx);
108108 unsigned RegOffset = TRI.getSubRegIdxOffset(Idx);
109109 AddReg(Reg, "super-register");
110 if (PieceOffsetInBits == RegOffset) {
110 if (FragmentOffsetInBits == RegOffset) {
111111 AddOpPiece(Size, RegOffset);
112112 } else {
113 // If this is part of a variable in a sub-register at a
114 // non-zero offset, we need to manually shift the value into
115 // place, since the DW_OP_piece describes the part of the
116 // variable, not the position of the subregister.
113 // If this is part of a variable in a sub-register at a non-zero offset,
114 // we need to manually shift the value into place, since the
115 // DW_OP_LLVM_fragment describes the part of the variable, not the
116 // position of the subregister.
117117 if (RegOffset)
118118 AddShr(RegOffset);
119 AddOpPiece(Size, PieceOffsetInBits);
119 AddOpPiece(Size, FragmentOffsetInBits);
120120 }
121121 return true;
122122 }
124124
125125 // Otherwise, attempt to find a covering set of sub-register numbers.
126126 // For example, Q0 on ARM is a composition of D0+D1.
127 //
128 // Keep track of the current position so we can emit the more
129 // efficient DW_OP_piece.
130 unsigned CurPos = PieceOffsetInBits;
127 unsigned CurPos = FragmentOffsetInBits;
131128 // The size of the register in bits, assuming 8 bits per byte.
132129 unsigned RegSize = TRI.getMinimalPhysRegClass(MachineReg)->getSize() * 8;
133130 // Keep track of the bits in the register we already emitted, so we
157154 }
158155 }
159156
160 return CurPos > PieceOffsetInBits;
157 return CurPos > FragmentOffsetInBits;
161158 }
162159
163160 void DwarfExpression::AddStackValue() {
194191 }
195192
196193 static unsigned getOffsetOrZero(unsigned OffsetInBits,
197 unsigned PieceOffsetInBits) {
198 if (OffsetInBits == PieceOffsetInBits)
194 unsigned FragmentOffsetInBits) {
195 if (OffsetInBits == FragmentOffsetInBits)
199196 return 0;
200 assert(OffsetInBits >= PieceOffsetInBits && "overlapping pieces");
197 assert(OffsetInBits >= FragmentOffsetInBits && "overlapping fragments");
201198 return OffsetInBits;
202199 }
203200
204201 bool DwarfExpression::AddMachineRegExpression(const TargetRegisterInfo &TRI,
205202 DIExpressionCursor &ExprCursor,
206203 unsigned MachineReg,
207 unsigned PieceOffsetInBits) {
204 unsigned FragmentOffsetInBits) {
208205 if (!ExprCursor)
209 return AddMachineRegPiece(TRI, MachineReg);
206 return AddMachineRegFragment(TRI, MachineReg);
210207
211208 // Pattern-match combinations for which more efficient representations exist
212209 // first.
213210 bool ValidReg = false;
214211 auto Op = ExprCursor.peek();
215212 switch (Op->getOp()) {
216 case dwarf::DW_OP_bit_piece: {
213 case dwarf::DW_OP_LLVM_fragment: {
217214 unsigned OffsetInBits = Op->getArg(0);
218215 unsigned SizeInBits = Op->getArg(1);
219216 // Piece always comes at the end of the expression.
220 AddMachineRegPiece(TRI, MachineReg, SizeInBits,
221 getOffsetOrZero(OffsetInBits, PieceOffsetInBits));
217 AddMachineRegFragment(TRI, MachineReg, SizeInBits,
218 getOffsetOrZero(OffsetInBits, FragmentOffsetInBits));
222219 ExprCursor.take();
223220 break;
224221 }
233230 TRI, MachineReg, Op->getOp() == dwarf::DW_OP_plus ? Offset : -Offset);
234231 ExprCursor.consume(2);
235232 } else
236 ValidReg = AddMachineRegPiece(TRI, MachineReg);
233 ValidReg = AddMachineRegFragment(TRI, MachineReg);
237234 break;
238235 }
239236 case dwarf::DW_OP_deref:
247244 }
248245
249246 void DwarfExpression::AddExpression(DIExpressionCursor &&ExprCursor,
250 unsigned PieceOffsetInBits) {
247 unsigned FragmentOffsetInBits) {
251248 while (ExprCursor) {
252249 auto Op = ExprCursor.take();
253250 switch (Op->getOp()) {
254 case dwarf::DW_OP_bit_piece: {
251 case dwarf::DW_OP_LLVM_fragment: {
255252 unsigned OffsetInBits = Op->getArg(0);
256253 unsigned SizeInBits = Op->getArg(1);
257 AddOpPiece(SizeInBits, getOffsetOrZero(OffsetInBits, PieceOffsetInBits));
254 AddOpPiece(SizeInBits,
255 getOffsetOrZero(OffsetInBits, FragmentOffsetInBits));
258256 break;
259257 }
260258 case dwarf::DW_OP_plus:
7575 /// entry.
7676 class DwarfExpression {
7777 protected:
78 // Various convenience accessors that extract things out of AsmPrinter.
7978 unsigned DwarfVersion;
8079
8180 public:
9796 /// Emit an (double-)indirect dwarf register operation.
9897 void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false);
9998
100 /// Emit DW_OP_piece operation.
99 /// Emit a DW_OP_piece operation for a variable fragment.
100 /// \param OffsetInBits This is the offset where the fragment appears
101 /// inside the *source variable*.
101102 void AddOpPiece(unsigned SizeInBits, unsigned OffsetInBits = 0);
103
102104 /// Emit a shift-right dwarf expression.
103105 void AddShr(unsigned ShiftBy);
106
104107 /// Emit a DW_OP_stack_value, if supported.
105108 ///
106109 /// The proper way to describe a constant value is DW_OP_constu ,
120123 int Offset = 0);
121124
122125 /// Emit a partial DWARF register operation.
123 /// \param MachineReg the register
124 /// \param PieceSizeInBits size and
125 /// \param PieceOffsetInBits offset of the piece in bits, if this is one
126 /// piece of an aggregate value.
127 ///
128 /// If size and offset is zero an operation for the entire
129 /// register is emitted: Some targets do not provide a DWARF
130 /// register number for every register. If this is the case, this
131 /// function will attempt to emit a DWARF register by emitting a
132 /// piece of a super-register or by piecing together multiple
133 /// subregisters that alias the register.
126 ///
127 /// \param MachineReg the register,
128 /// \param FragmentSizeInBits size and
129 /// \param FragmentOffsetInBits offset of the fragment in bits, if this is
130 /// a fragment of an aggregate value.
131 ///
132 /// If size and offset is zero an operation for the entire register is
133 /// emitted: Some targets do not provide a DWARF register number for every
134 /// register. If this is the case, this function will attempt to emit a DWARF
135 /// register by emitting a fragment of a super-register or by piecing together
136 /// multiple subregisters that alias the register.
134137 ///
135138 /// \return false if no DWARF register exists for MachineReg.
136 bool AddMachineRegPiece(const TargetRegisterInfo &TRI, unsigned MachineReg,
137 unsigned PieceSizeInBits = 0,
138 unsigned PieceOffsetInBits = 0);
139 bool AddMachineRegFragment(const TargetRegisterInfo &TRI, unsigned MachineReg,
140 unsigned FragmentSizeInBits = 0,
141 unsigned FragmentOffsetInBits = 0);
139142
140143 /// Emit a signed constant.
141144 void AddSignedConstant(int64_t Value);
148151 /// the prefix of a DwarfExpression if a more efficient representation for
149152 /// combining the register location and the first operation exists.
150153 ///
151 /// \param PieceOffsetInBits If this is one piece out of a fragmented
152 /// location, this is the offset of the piece inside the entire variable.
153 /// \return false if no DWARF register exists for MachineReg.
154 /// \param FragmentOffsetInBits If this is one fragment out of a fragmented
155 /// location, this is the offset of the
156 /// fragment inside the entire variable.
157 /// \return false if no DWARF register exists
158 /// for MachineReg.
154159 bool AddMachineRegExpression(const TargetRegisterInfo &TRI,
155160 DIExpressionCursor &Expr, unsigned MachineReg,
156 unsigned PieceOffsetInBits = 0);
161 unsigned FragmentOffsetInBits = 0);
157162 /// Emit all remaining operations in the DIExpressionCursor.
158 /// \param PieceOffsetInBits If this is one piece out of a fragmented
159 /// location, this is the offset of the piece inside the entire variable.
163 ///
164 /// \param FragmentOffsetInBits If this is one fragment out of multiple
165 /// locations, this is the offset of the
166 /// fragment inside the entire variable.
160167 void AddExpression(DIExpressionCursor &&Expr,
161 unsigned PieceOffsetInBits = 0);
168 unsigned FragmentOffsetInBits = 0);
162169 };
163170
164171 /// DwarfExpression implementation for .debug_loc entries.
370370 addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
371371 }
372372
373 bool DwarfUnit::addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
374 unsigned SizeInBits, unsigned OffsetInBits) {
373 bool DwarfUnit::addRegisterFragment(DIELoc &TheDie, unsigned Reg,
374 unsigned SizeInBits,
375 unsigned OffsetInBits) {
375376 DIEDwarfExpression Expr(*Asm, *this, TheDie);
376 Expr.AddMachineRegPiece(*Asm->MF->getSubtarget().getRegisterInfo(), Reg,
377 SizeInBits, OffsetInBits);
377 Expr.AddMachineRegFragment(*Asm->MF->getSubtarget().getRegisterInfo(), Reg,
378 SizeInBits, OffsetInBits);
378379 return true;
379380 }
380381
480481
481482 bool validReg;
482483 if (Location.isReg())
483 validReg = addRegisterOpPiece(*Loc, Location.getReg());
484 validReg = addRegisterFragment(*Loc, Location.getReg());
484485 else
485486 validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset());
486487
234234 /// Add template parameters in buffer.
235235 void addTemplateParams(DIE &Buffer, DINodeArray TParams);
236236
237 /// Add register operand.
237 /// Add register operand for a source variable fragment of the specified size
238 /// and offset.
239 ///
238240 /// \returns false if the register does not exist, e.g., because it was never
239 /// materialized.
240 bool addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
241 unsigned SizeInBits = 0, unsigned OffsetInBits = 0);
241 /// materialized.
242 bool addRegisterFragment(DIELoc &TheDie, unsigned Reg,
243 unsigned SizeInBits = 0, unsigned OffsetInBits = 0);
242244
243245 /// Add register offset.
244246 /// \returns false if the register does not exist, e.g., because it was never
615615 return createExpression(Addr);
616616 }
617617
618 DIExpression *DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
618 DIExpression *DIBuilder::createFragmentExpression(unsigned OffsetInBytes,
619619 unsigned SizeInBytes) {
620 uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
620 uint64_t Addr[] = {dwarf::DW_OP_LLVM_fragment, OffsetInBytes, SizeInBytes};
621621 return DIExpression::get(VMContext, Addr);
622622 }
623623
558558
559559 unsigned DIExpression::ExprOperand::getSize() const {
560560 switch (getOp()) {
561 case dwarf::DW_OP_bit_piece:
561 case dwarf::DW_OP_LLVM_fragment:
562562 return 3;
563563 case dwarf::DW_OP_constu:
564564 case dwarf::DW_OP_plus:
579579 switch (I->getOp()) {
580580 default:
581581 return false;
582 case dwarf::DW_OP_bit_piece:
582 case dwarf::DW_OP_LLVM_fragment:
583583 case dwarf::DW_OP_stack_value:
584 // We only support bit piece and stack value expressions which appear at
584 // We only support fragment and stack value expressions which appear at
585585 // the end.
586586 return I->get() + I->getSize() == E->get();
587587 case dwarf::DW_OP_constu:
594594 return true;
595595 }
596596
597 bool DIExpression::isBitPiece() const {
597 bool DIExpression::isFragment() const {
598598 assert(isValid() && "Expected valid expression");
599599 if (unsigned N = getNumElements())
600600 if (N >= 3)
601 return getElement(N - 3) == dwarf::DW_OP_bit_piece;
601 return getElement(N - 3) == dwarf::DW_OP_LLVM_fragment;
602602 return false;
603603 }
604604
605 uint64_t DIExpression::getBitPieceOffset() const {
606 assert(isBitPiece() && "Expected bit piece");
605 uint64_t DIExpression::getFragmentOffsetInBits() const {
606 assert(isFragment() && "Expected fragment");
607607 return getElement(getNumElements() - 2);
608608 }
609609
610 uint64_t DIExpression::getBitPieceSize() const {
611 assert(isBitPiece() && "Expected bit piece");
610 uint64_t DIExpression::getFragmentSizeInBits() const {
611 assert(isFragment() && "Expected fragment");
612612 return getElement(getNumElements() - 1);
613613 }
614614
482482 void verifyFrameRecoverIndices();
483483 void verifySiblingFuncletUnwinds();
484484
485 void verifyBitPieceExpression(const DbgInfoIntrinsic &I);
485 void verifyFragmentExpression(const DbgInfoIntrinsic &I);
486486
487487 /// Module-level debug info verification...
488488 void verifyCompileUnits();
38253825 }
38263826
38273827 if (auto *DII = dyn_cast(&I))
3828 verifyBitPieceExpression(*DII);
3828 verifyFragmentExpression(*DII);
38293829
38303830 InstsInThisBlock.insert(&I);
38313831 }
43064306 return 0;
43074307 }
43084308
4309 void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I) {
4309 void Verifier::verifyFragmentExpression(const DbgInfoIntrinsic &I) {
43104310 DILocalVariable *V;
43114311 DIExpression *E;
43124312 if (auto *DVI = dyn_cast(&I)) {
43234323 return;
43244324
43254325 // Nothing to do if this isn't a bit piece expression.
4326 if (!E->isBitPiece())
4326 if (!E->isFragment())
43274327 return;
43284328
43294329 // The frontend helps out GDB by emitting the members of local anonymous
43414341 if (!VarSize)
43424342 return;
43434343
4344 unsigned PieceSize = E->getBitPieceSize();
4345 unsigned PieceOffset = E->getBitPieceOffset();
4346 AssertDI(PieceSize + PieceOffset <= VarSize,
4347 "piece is larger than or outside of variable", &I, V, E);
4348 AssertDI(PieceSize != VarSize, "piece covers entire variable", &I, V, E);
4344 unsigned FragSize = E->getFragmentSizeInBits();
4345 unsigned FragOffset = E->getFragmentOffsetInBits();
4346 AssertDI(FragSize + FragOffset <= VarSize,
4347 "fragment is larger than or outside of variable", &I, V, E);
4348 AssertDI(FragSize != VarSize, "fragment covers entire variable", &I, V, E);
43494349 }
43504350
43514351 void Verifier::verifyCompileUnits() {
7373 case DW_OP_##NAME: \
7474 return "DW_OP_" #NAME;
7575 #include "llvm/Support/Dwarf.def"
76 case DW_OP_LLVM_fragment:
77 return "DW_OP_LLVM_fragment";
7678 }
7779 }
7880
8082 return StringSwitch(OperationEncodingString)
8183 #define HANDLE_DW_OP(ID, NAME) .Case("DW_OP_" #NAME, DW_OP_##NAME)
8284 #include "llvm/Support/Dwarf.def"
85 .Case("DW_OP_LLVM_fragment", DW_OP_LLVM_fragment)
8386 .Default(0);
8487 }
8588
39813981 if (!IsSorted)
39823982 std::sort(AS.begin(), AS.end());
39833983
3984 /// \brief Describes the allocas introduced by rewritePartition
3985 /// in order to migrate the debug info.
3986 struct Piece {
3984 /// Describes the allocas introduced by rewritePartition in order to migrate
3985 /// the debug info.
3986 struct Fragment {
39873987 AllocaInst *Alloca;
39883988 uint64_t Offset;
39893989 uint64_t Size;
3990 Piece(AllocaInst *AI, uint64_t O, uint64_t S)
3990 Fragment(AllocaInst *AI, uint64_t O, uint64_t S)
39913991 : Alloca(AI), Offset(O), Size(S) {}
39923992 };
3993 SmallVector<Piece, 4> Pieces;
3993 SmallVector<Fragment, 4> Fragments;
39943994
39953995 // Rewrite each partition.
39963996 for (auto &P : AS.partitions()) {
40014001 uint64_t AllocaSize = DL.getTypeSizeInBits(NewAI->getAllocatedType());
40024002 // Don't include any padding.
40034003 uint64_t Size = std::min(AllocaSize, P.size() * SizeOfByte);
4004 Pieces.push_back(Piece(NewAI, P.beginOffset() * SizeOfByte, Size));
4004 Fragments.push_back(Fragment(NewAI, P.beginOffset() * SizeOfByte, Size));
40054005 }
40064006 }
40074007 ++NumPartitions;
40184018 auto *Expr = DbgDecl->getExpression();
40194019 DIBuilder DIB(*AI.getModule(), /*AllowUnresolved*/ false);
40204020 uint64_t AllocaSize = DL.getTypeSizeInBits(AI.getAllocatedType());
4021 for (auto Piece : Pieces) {
4022 // Create a piece expression describing the new partition or reuse AI's
4021 for (auto Fragment : Fragments) {
4022 // Create a fragment expression describing the new partition or reuse AI's
40234023 // expression if there is only one partition.
4024 auto *PieceExpr = Expr;
4025 if (Piece.Size < AllocaSize || Expr->isBitPiece()) {
4024 auto *FragmentExpr = Expr;
4025 if (Fragment.Size < AllocaSize || Expr->isFragment()) {
40264026 // If this alloca is already a scalar replacement of a larger aggregate,
4027 // Piece.Offset describes the offset inside the scalar.
4028 uint64_t Offset = Expr->isBitPiece() ? Expr->getBitPieceOffset() : 0;
4029 uint64_t Start = Offset + Piece.Offset;
4030 uint64_t Size = Piece.Size;
4031 if (Expr->isBitPiece()) {
4032 uint64_t AbsEnd = Expr->getBitPieceOffset() + Expr->getBitPieceSize();
4027 // Fragment.Offset describes the offset inside the scalar.
4028 uint64_t Offset =
4029 Expr->isFragment() ? Expr->getFragmentOffsetInBits() : 0;
4030 uint64_t Start = Offset + Fragment.Offset;
4031 uint64_t Size = Fragment.Size;
4032 if (Expr->isFragment()) {
4033 uint64_t AbsEnd =
4034 Expr->getFragmentOffsetInBits() + Expr->getFragmentSizeInBits();
40334035 if (Start >= AbsEnd)
40344036 // No need to describe a SROAed padding.
40354037 continue;
40364038 Size = std::min(Size, AbsEnd - Start);
40374039 }
4038 PieceExpr = DIB.createBitPieceExpression(Start, Size);
4040 FragmentExpr = DIB.createFragmentExpression(Start, Size);
40394041 }
40404042
40414043 // Remove any existing dbg.declare intrinsic describing the same alloca.
4042 if (DbgDeclareInst *OldDDI = FindAllocaDbgDeclare(Piece.Alloca))
4044 if (DbgDeclareInst *OldDDI = FindAllocaDbgDeclare(Fragment.Alloca))
40434045 OldDDI->eraseFromParent();
40444046
4045 DIB.insertDeclare(Piece.Alloca, Var, PieceExpr, DbgDecl->getDebugLoc(),
4046 &AI);
4047 DIB.insertDeclare(Fragment.Alloca, Var, FragmentExpr,
4048 DbgDecl->getDebugLoc(), &AI);
40474049 }
40484050 }
40494051 return Changed;
11011101 if (SExtInst *SExt = dyn_cast(SI->getOperand(0)))
11021102 ExtendedArg = dyn_cast(SExt->getOperand(0));
11031103 if (ExtendedArg) {
1104 // We're now only describing a subset of the variable. The piece we're
1104 // We're now only describing a subset of the variable. The fragment we're
11051105 // describing will always be smaller than the variable size, because
11061106 // VariableSize == Size of Alloca described by DDI. Since SI stores
11071107 // to the alloca described by DDI, if it's first operand is an extend,
11081108 // we're guaranteed that before extension, the value was narrower than
11091109 // the size of the alloca, hence the size of the described variable.
11101110 SmallVector Ops;
1111 unsigned PieceOffset = 0;
1112 // If this already is a bit piece, we drop the bit piece from the expression
1113 // and record the offset.
1114 if (DIExpr->isBitPiece()) {
1111 unsigned FragmentOffset = 0;
1112 // If this already is a bit fragment, we drop the bit fragment from the
1113 // expression and record the offset.
1114 if (DIExpr->isFragment()) {
11151115 Ops.append(DIExpr->elements_begin(), DIExpr->elements_end()-3);
1116 PieceOffset = DIExpr->getBitPieceOffset();
1116 FragmentOffset = DIExpr->getFragmentOffsetInBits();
11171117 } else {
11181118 Ops.append(DIExpr->elements_begin(), DIExpr->elements_end());
11191119 }
1120 Ops.push_back(dwarf::DW_OP_bit_piece);
1121 Ops.push_back(PieceOffset); // Offset
1120 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
1121 Ops.push_back(FragmentOffset);
11221122 const DataLayout &DL = DDI->getModule()->getDataLayout();
1123 Ops.push_back(DL.getTypeSizeInBits(ExtendedArg->getType())); // Size
1123 Ops.push_back(DL.getTypeSizeInBits(ExtendedArg->getType()));
11241124 auto NewDIExpr = Builder.createExpression(Ops);
11251125 if (!LdStHasDebugValue(DIVar, NewDIExpr, SI))
11261126 Builder.insertDbgValueIntrinsic(ExtendedArg, 0, DIVar, NewDIExpr,
66 ; CHECK: !0 = !DIExpression()
77 ; CHECK-NEXT: !1 = !DIExpression(DW_OP_deref)
88 ; CHECK-NEXT: !2 = !DIExpression(DW_OP_plus, 3)
9 ; CHECK-NEXT: !3 = !DIExpression(DW_OP_bit_piece, 3, 7)
10 ; CHECK-NEXT: !4 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_bit_piece, 3, 7)
9 ; CHECK-NEXT: !3 = !DIExpression(DW_OP_LLVM_fragment, 3, 7)
10 ; CHECK-NEXT: !4 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_LLVM_fragment, 3, 7)
1111 !0 = !DIExpression()
1212 !1 = !DIExpression(DW_OP_deref)
1313 !2 = !DIExpression(DW_OP_plus, 3)
14 !3 = !DIExpression(DW_OP_bit_piece, 3, 7)
15 !4 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_bit_piece, 3, 7)
14 !3 = !DIExpression(DW_OP_LLVM_fragment, 3, 7)
15 !4 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_LLVM_fragment, 3, 7)
0 ; RUN: llvm-dis -o - %s.bc | FileCheck %s
1
2 @g = common global i32 0, align 4, !dbg !0
3
4 !llvm.dbg.cu = !{!1}
5 !llvm.module.flags = !{!7, !8}
6
7 !0 = distinct !DIGlobalVariable(name: "g", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, expr: !6)
8 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang (llvm/trunk 288154)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)
9 !2 = !DIFile(filename: "a.c", directory: "/")
10 !3 = !{}
11 !4 = !{!0}
12 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
13 ; Old-style DIExpression bitcode records using DW_OP_bit_piece should be
14 ; upgraded to DW_OP_LLVM_fragment.
15 ;
16 ; CHECK: !DIExpression(DW_OP_LLVM_fragment, 8, 32)
17 !6 = !DIExpression(DW_OP_bit_piece, 8, 32)
18 !7 = !{i32 2, !"Dwarf Version", i32 4}
19 !8 = !{i32 2, !"Debug Info Version", i32 3}
5858 !18 = !{!"clang version 3.8.0 (trunk 256088) (llvm/trunk 256097)"}
5959 !19 = !DIExpression()
6060 !20 = !DILocation(line: 4, column: 5, scope: !4)
61 !21 = !DIExpression(DW_OP_bit_piece, 32, 32)
61 !21 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
6262 !22 = !DILocation(line: 6, column: 1, scope: !4)
234234 !73 = !DILocation(line: 17, column: 27, scope: !31)
235235 !74 = !DILocalVariable(name: "p1", line: 17, arg: 1, scope: !31, file: !26, type: !4)
236236 !75 = distinct !DILocation(line: 22, column: 3, scope: !34)
237 !76 = !DIExpression(DW_OP_bit_piece, 8, 120)
237 !76 = !DIExpression(DW_OP_LLVM_fragment, 8, 120)
238238 !77 = !DILocation(line: 17, column: 12, scope: !31, inlinedAt: !75)
239 !78 = !DIExpression(DW_OP_bit_piece, 136, 56)
239 !78 = !DIExpression(DW_OP_LLVM_fragment, 136, 56)
240240 !79 = !DIExpression(DW_OP_deref)
241241 !80 = !DILocation(line: 19, column: 5, scope: !34)
242242 !81 = !DILocation(line: 20, column: 7, scope: !34)
243243 !82 = !DILocation(line: 20, column: 5, scope: !34)
244 !83 = !DIExpression(DW_OP_bit_piece, 0, 8)
245 !84 = !DIExpression(DW_OP_bit_piece, 128, 8)
244 !83 = !DIExpression(DW_OP_LLVM_fragment, 0, 8)
245 !84 = !DIExpression(DW_OP_LLVM_fragment, 128, 8)
246246 !85 = !DILocation(line: 13, column: 12, scope: !25, inlinedAt: !86)
247247 !86 = distinct !DILocation(line: 17, column: 18, scope: !31, inlinedAt: !75)
248248 !87 = !DILocation(line: 14, column: 37, scope: !25, inlinedAt: !86)
9999 !27 = !DILocation(line: 11, scope: !11, inlinedAt: !28)
100100 !28 = distinct !DILocation(line: 26, scope: !4)
101101 !29 = !DILocation(line: 13, scope: !11, inlinedAt: !28)
102 !30 = !DIExpression(DW_OP_bit_piece, 0, 64)
103 !31 = !DIExpression(DW_OP_bit_piece, 0, 32)
102 !30 = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
103 !31 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
104104 !32 = !DILocation(line: 18, scope: !11, inlinedAt: !28)
105105 !33 = !DILocation(line: 27, scope: !4)
5050 !14 = !DILocalVariable(name: "c", arg: 1, scope: !4, file: !5, line: 1, type: !8)
5151 !15 = !DIExpression()
5252 !16 = !DILocation(line: 1, column: 24, scope: !4)
53 !17 = !DIExpression(DW_OP_bit_piece, 0, 64)
54 !18 = !DIExpression(DW_OP_bit_piece, 64, 64)
53 !17 = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
54 !18 = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
5555 !19 = !DILocation(line: 1, column: 36, scope: !4)
2525 ; CHECK-SAME: metadata ![[C]], metadata ![[IMG:.*]])
2626 ret void, !dbg !18
2727 }
28 ; CHECK: ![[REAL]] = !DIExpression(DW_OP_bit_piece, 0, 64)
29 ; CHECK: ![[IMG]] = !DIExpression(DW_OP_bit_piece, 64, 64)
28 ; CHECK: ![[REAL]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
29 ; CHECK: ![[IMG]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
3030
3131 ; Function Attrs: nounwind readnone
3232 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
3434 ; }
3535
3636 ; ASM-LABEL: loop_csr: # @loop_csr
37 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=0 size=32] <- 0
38 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=32 size=32] <- 0
37 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- 0
38 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- 0
3939 ; ASM: # BB#2: # %for.body.preheader
4040 ; ASM: xorl %edi, %edi
4141 ; ASM: xorl %esi, %esi
4242 ; ASM: .p2align 4, 0x90
4343 ; ASM: .LBB0_3: # %for.body
4444 ; ASM: [[ox_start:\.Ltmp[0-9]+]]:
45 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=0 size=32] <- %EDI
45 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- %EDI
4646 ; ASM: .cv_loc 0 1 13 11 # t.c:13:11
4747 ; ASM: movl %edi, %ecx
4848 ; ASM: callq g
4949 ; ASM: movl %eax, %edi
5050 ; ASM: [[oy_start:\.Ltmp[0-9]+]]:
51 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=0 size=32] <- %EDI
52 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=32 size=32] <- %ESI
51 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=0 size=32] <- %EDI
52 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- %ESI
5353 ; ASM: .cv_loc 0 1 14 11 # t.c:14:11
5454 ; ASM: movl %esi, %ecx
5555 ; ASM: callq g
5656 ; ASM: movl %eax, %esi
57 ; ASM: #DEBUG_VALUE: loop_csr:o [bit_piece offset=32 size=32] <- %ESI
57 ; ASM: #DEBUG_VALUE: loop_csr:o [fragment offset=32 size=32] <- %ESI
5858 ; ASM: cmpl n(%rip), %eax
5959 ; ASM: jl .LBB0_3
6060 ; ASM: [[oy_end:\.Ltmp[0-9]+]]:
6363
6464
6565 ; ASM-LABEL: pad_right: # @pad_right
66 ; ASM: #DEBUG_VALUE: pad_right:o [bit_piece offset=32 size=32] <- %ECX
66 ; ASM: #DEBUG_VALUE: pad_right:o [fragment offset=32 size=32] <- %ECX
6767 ; ASM: movl %ecx, %eax
6868 ; ASM: retq
6969
7070
7171 ; ASM-LABEL: pad_left: # @pad_left
72 ; ASM: #DEBUG_VALUE: pad_left:o [bit_piece offset=0 size=32] <- %ECX
72 ; ASM: #DEBUG_VALUE: pad_left:o [fragment offset=0 size=32] <- %ECX
7373 ; ASM: .cv_loc 2 1 24 3 # t.c:24:3
7474 ; ASM: movl %ecx, %eax
7575 ; ASM: retq
7979 ; ASM: #DEBUG_VALUE: nested:o <- [%RCX+0]
8080 ; ASM: movl 12(%rcx), %eax
8181 ; ASM: [[p_start:\.Ltmp[0-9]+]]:
82 ; ASM: #DEBUG_VALUE: nested:p [bit_piece offset=32 size=32] <- %EAX
82 ; ASM: #DEBUG_VALUE: nested:p [fragment offset=32 size=32] <- %EAX
8383 ; ASM: retq
8484
8585 ; ASM-LABEL: bitpiece_spill: # @bitpiece_spill
86 ; ASM: #DEBUG_VALUE: bitpiece_spill:o [bit_piece offset=0 size=32] <- 0
86 ; ASM: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=0 size=32] <- 0
8787 ; ASM: xorl %ecx, %ecx
8888 ; ASM: callq g
8989 ; ASM: movl %eax, [[offset_o_x:[0-9]+]](%rsp) # 4-byte Spill
9090 ; ASM: [[spill_o_x_start:\.Ltmp[0-9]+]]:
91 ; ASM: #DEBUG_VALUE: bitpiece_spill:o [bit_piece offset=32 size=32] <- [%RSP+[[offset_o_x]]]
91 ; ASM: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=32 size=32] <- [%RSP+[[offset_o_x]]]
9292 ; ASM: #APP
9393 ; ASM: #NO_APP
9494 ; ASM: movl [[offset_o_x]](%rsp), %eax # 4-byte Reload
359359 !16 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !13, file: !1, line: 1, baseType: !10, size: 32, align: 32, offset: 32)
360360 !17 = !DIExpression()
361361 !18 = !DILocation(line: 11, column: 18, scope: !7)
362 !19 = !DIExpression(DW_OP_bit_piece, 0, 32)
363 !20 = !DIExpression(DW_OP_bit_piece, 32, 32)
362 !19 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
363 !20 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
364364 !21 = !DILocation(line: 12, column: 23, scope: !22)
365365 !22 = distinct !DILexicalBlock(scope: !23, file: !1, line: 12, column: 3)
366366 !23 = distinct !DILexicalBlock(scope: !7, file: !1, line: 12, column: 3)
4545 !21 = !DILocation(line: 3, scope: !4)
4646 !22 = !DILocalVariable(name: "s", line: 3, arg: 1, scope: !4, file: !5, type: !9)
4747 !23 = !DILocation(line: 4, scope: !4)
48 !24 = !DIExpression(DW_OP_deref, DW_OP_bit_piece, 0, 64)
48 !24 = !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64)
4949 !25 = !{}
50 ; This expression has elements after DW_OP_bit_piece.
50 ; This expression has elements after DW_OP_LLVM_fragment.
5151 ; CHECK: invalid expression
5252 ; CHECK-NEXT: !DIExpression({{[0-9]+}}, 64, 32, {{[0-9]+}})
5353 ; CHECK-NOT: invalid expression
54 !27 = !DIExpression(DW_OP_bit_piece, 64, 32, DW_OP_deref)
54 !27 = !DIExpression(DW_OP_LLVM_fragment, 64, 32, DW_OP_deref)
9494 !27 = !DILocation(line: 5, column: 16, scope: !4)
9595 !28 = !DILocation(line: 6, column: 13, scope: !4)
9696 !29 = !DILocation(line: 6, column: 16, scope: !4)
97 !30 = !DIExpression(DW_OP_bit_piece, 0, 32)
98 !31 = !DIExpression(DW_OP_bit_piece, 32, 32)
99 !32 = !DIExpression(DW_OP_bit_piece, 32, 16)
97 !30 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
98 !31 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
99 !32 = !DIExpression(DW_OP_LLVM_fragment, 32, 16)
100100 !33 = !DILocation(line: 8, column: 9, scope: !4)
101101 !34 = !DILocation(line: 9, column: 1, scope: !4)
102102 !35 = !DILocation(line: 11, column: 14, scope: !17)
1717 ; CHECK: define i32 @main
1818 ; CHECK: call void @llvm.dbg.value(metadata i32 42, i64 0, metadata ![[ARRAY:[0-9]+]], metadata ![[EXPR:[0-9]+]])
1919 ; CHECK: ![[ARRAY]] = !DILocalVariable(name: "array",{{.*}} line: 6
20 ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_bit_piece, 0, 32)
20 ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
2121 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2222 target triple = "x86_64-apple-macosx10.9.0"
2323
4040 !13 = !DISubroutineType(types: !14)
4141 !14 = !{null}
4242 !15 = !DILocalVariable(name: "v", scope: !12, type: !6)
43 !16 = !DIExpression(DW_OP_bit_piece, 32, 32)
43 !16 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
4444 !17 = !DILocation(line: 2755, column: 9, scope: !12)
167167 !30 = !{i32 2, !"Debug Info Version", i32 3}
168168 !31 = !{i32 1, !"PIC Level", i32 2}
169169 !32 = !{!"clang version 3.7.0 (trunk 227088) (llvm/trunk 227091)"}
170 !33 = !DIExpression(DW_OP_bit_piece, 0, 8)
170 !33 = !DIExpression(DW_OP_LLVM_fragment, 0, 8)
171171 !34 = !DILocation(line: 7, column: 42, scope: !11)
172 !35 = !DIExpression(DW_OP_bit_piece, 8, 4)
172 !35 = !DIExpression(DW_OP_LLVM_fragment, 8, 4)
173173 !36 = !DIExpression()
174174 !37 = !DILocation(line: 7, column: 48, scope: !11)
175175 !38 = !DILocation(line: 7, column: 66, scope: !11)
7272 !21 = !DILocation(line: 3, scope: !4)
7373 !22 = !DILocalVariable(name: "s", line: 3, arg: 1, scope: !4, file: !5, type: !9)
7474 !23 = !DILocation(line: 4, scope: !4)
75 !24 = !DIExpression(DW_OP_bit_piece, 0, 64)
75 !24 = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
7676 !25 = !{}
77 !27 = !DIExpression(DW_OP_bit_piece, 64, 32)
77 !27 = !DIExpression(DW_OP_LLVM_fragment, 64, 32)
8989 !26 = !DILocation(line: 10, scope: !4)
9090 !27 = !DILocation(line: 11, scope: !4)
9191 !28 = !DILocalVariable(name: "i1", line: 11, scope: !4, file: !5, type: !14)
92 !29 = !DIExpression(DW_OP_bit_piece, 0, 32)
92 !29 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
9393 !31 = !{i32 3, i32 0, i32 12}
9494 !32 = !DILocation(line: 12, scope: !4)
9898 !22 = !{i32 1, !"Debug Info Version", i32 3}
9999 !23 = !{!"clang version 3.5.0 "}
100100 !24 = !DILocalVariable(name: "outer", line: 10, arg: 1, scope: !4, file: !5, type: !9)
101 !25 = !DIExpression(DW_OP_bit_piece, 0, 64)
101 !25 = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
102102 !26 = !DILocation(line: 10, scope: !4)
103103 !27 = !DILocalVariable(name: "outer", line: 10, arg: 1, scope: !4, file: !5, type: !9)
104 !28 = !DIExpression(DW_OP_bit_piece, 64, 64)
104 !28 = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
105105 !29 = !DILocalVariable(name: "outer", line: 10, arg: 1, scope: !4, file: !5, type: !9)
106 !30 = !DIExpression(DW_OP_bit_piece, 96, 32)
106 !30 = !DIExpression(DW_OP_LLVM_fragment, 96, 32)
107107 !31 = !DILocalVariable(name: "outer", line: 10, arg: 1, scope: !4, file: !5, type: !9)
108 !32 = !DIExpression(DW_OP_bit_piece, 64, 32)
108 !32 = !DIExpression(DW_OP_LLVM_fragment, 64, 32)
109109 !33 = !DILocation(line: 11, scope: !4)
110110 !34 = !DILocalVariable(name: "i1", line: 11, scope: !4, file: !5, type: !14)
111 !35 = !DIExpression(DW_OP_bit_piece, 0, 32)
111 !35 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
112112 !36 = !DILocation(line: 12, scope: !4)
1414 ; CHECK-LABEL: bitpiece_spill: # @bitpiece_spill
1515 ; CHECK: callq g
1616 ; CHECK: movl %eax, [[offs:[0-9]+]](%rsp) # 4-byte Spill
17 ; CHECK: #DEBUG_VALUE: bitpiece_spill:o [bit_piece offset=32 size=32] <- 0
18 ; CHECK: #DEBUG_VALUE: bitpiece_spill:o [bit_piece offset=0 size=32] <- [%RSP+[[offs]]]
17 ; CHECK: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=32 size=32] <- 0
18 ; CHECK: #DEBUG_VALUE: bitpiece_spill:o [fragment offset=0 size=32] <- [%RSP+[[offs]]]
1919 ; CHECK: #APP
2020 ; CHECK: #NO_APP
2121 ; CHECK: movl [[offs]](%rsp), %eax # 4-byte Reload
7676 !17 = !DIExpression()
7777 !18 = !DILocation(line: 4, column: 18, scope: !7)
7878 !19 = !DILocation(line: 4, column: 23, scope: !7)
79 !20 = !DIExpression(DW_OP_bit_piece, 0, 32)
80 !21 = !DIExpression(DW_OP_bit_piece, 32, 32)
79 !20 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
80 !21 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
8181 !22 = !DILocation(line: 6, column: 3, scope: !7)
8282 !23 = !{i32 138}
8383 !24 = !DILocation(line: 8, column: 3, scope: !7)
2525 ; CHECK: ret i32 %[[A]]
2626 ; Read Var and Piece:
2727 ; CHECK: ![[VAR]] = !DILocalVariable(name: "i1",{{.*}} line: 11,
28 ; CHECK: ![[PIECE1]] = !DIExpression(DW_OP_bit_piece, 32, 96)
29 ; CHECK: ![[PIECE2]] = !DIExpression(DW_OP_bit_piece, 0, 32)
28 ; CHECK: ![[PIECE1]] = !DIExpression(DW_OP_LLVM_fragment, 32, 96)
29 ; CHECK: ![[PIECE2]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
3030
3131 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3232 target triple = "x86_64-apple-macosx10.9.0"
2323 ; CHECK: call void @llvm.dbg.value(metadata i64 %outer.coerce1, i64 0, metadata ![[O]], metadata ![[PIECE2:[0-9]+]]),
2424 ; CHECK: call void @llvm.dbg.value({{.*}}, i64 0, metadata ![[I1:[0-9]+]], metadata ![[PIECE3:[0-9]+]]),
2525 ; CHECK-DAG: ![[O]] = !DILocalVariable(name: "outer",{{.*}} line: 10
26 ; CHECK-DAG: ![[PIECE1]] = !DIExpression(DW_OP_bit_piece, 0, 64)
27 ; CHECK-DAG: ![[PIECE2]] = !DIExpression(DW_OP_bit_piece, 64, 64)
26 ; CHECK-DAG: ![[PIECE1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
27 ; CHECK-DAG: ![[PIECE2]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
2828 ; CHECK-DAG: ![[I1]] = !DILocalVariable(name: "i1",{{.*}} line: 11
29 ; CHECK-DAG: ![[PIECE3]] = !DIExpression(DW_OP_bit_piece, 0, 32)
29 ; CHECK-DAG: ![[PIECE3]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
3030
3131 ; ModuleID = 'sroasplit-2.c'
3232 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
55 ; CHECK: call void @llvm.dbg.value(metadata float %s.coerce, i64 0, metadata ![[VAR:[0-9]+]], metadata ![[EXPR:[0-9]+]])
66 ; CHECK: ![[VAR]] = !DILocalVariable(name: "s",{{.*}} line: 3,
77 ; CHECK: ![[EXPR]] = !DIExpression(
8 ; CHECK-NOT: DW_OP_bit_piece
8 ; CHECK-NOT: DW_OP_LLVM_fragment
99
1010 ;
1111 ; struct S { float f; };
66 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], i64 0, metadata ![[Y]], metadata ![[P2:.*]])
77 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T]], i64 0, metadata ![[R:.*]], metadata ![[P3:.*]])
88 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], i64 0, metadata ![[R]], metadata ![[P4:.*]])
9 ; CHECK: ![[P1]] = !DIExpression(DW_OP_bit_piece, 0, 64)
10 ; CHECK: ![[P2]] = !DIExpression(DW_OP_bit_piece, 64, 64)
11 ; CHECK: ![[P3]] = !DIExpression(DW_OP_bit_piece, 192, 64)
12 ; CHECK: ![[P4]] = !DIExpression(DW_OP_bit_piece, 256, 64)
9 ; CHECK: ![[P1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
10 ; CHECK: ![[P2]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
11 ; CHECK: ![[P3]] = !DIExpression(DW_OP_LLVM_fragment, 192, 64)
12 ; CHECK: ![[P4]] = !DIExpression(DW_OP_LLVM_fragment, 256, 64)
1313 ;
1414 ; struct p {
1515 ; __SIZE_TYPE__ s;
1818 ; When SROA is creating new smaller allocas, it may add padding.
1919 ;
2020 ; There should be no debug info for the padding.
21 ; CHECK-NOT: DW_OP_bit_piece, 56
22 ; CHECK: DIExpression(DW_OP_bit_piece, 32, 24)
23 ; CHECK-NOT: DW_OP_bit_piece, 56
24 ; CHECK: DIExpression(DW_OP_bit_piece, 0, 32)
25 ; CHECK-NOT: DW_OP_bit_piece, 56
21 ; CHECK-NOT: DW_OP_LLVM_fragment, 56
22 ; CHECK: DIExpression(DW_OP_LLVM_fragment, 32, 24)
23 ; CHECK-NOT: DW_OP_LLVM_fragment, 56
24 ; CHECK: DIExpression(DW_OP_LLVM_fragment, 0, 32)
25 ; CHECK-NOT: DW_OP_LLVM_fragment, 56
2626 %struct.prog_src_register = type { i32, i24 }
2727
2828 ; Function Attrs: nounwind
9696 !19 = !DIExpression()
9797 !20 = !DILocation(line: 2, column: 9, scope: !7)
9898 !21 = !DILocation(line: 3, column: 5, scope: !7)
99 !22 = !DIExpression(DW_OP_bit_piece, 0, 32)
100 !23 = !DIExpression(DW_OP_bit_piece, 32, 32)
99 !22 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
100 !23 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
101101 !24 = !DILocation(line: 5, column: 1, scope: !7)
102102 !25 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !26, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
103103 !26 = !DISubroutineType(types: !27)
128128 !45 = !DILocation(line: 9, scope: !15)
129129 !46 = !DILocalVariable(name: "p1", line: 6, arg: 1, scope: !15, file: !16, type: !4)
130130 !47 = distinct !DILocation(line: 11, scope: !21)
131 !48 = !DIExpression(DW_OP_bit_piece, 32, 160)
131 !48 = !DIExpression(DW_OP_LLVM_fragment, 32, 160)
132132 !49 = !DILocation(line: 6, scope: !15, inlinedAt: !47)
133133 !50 = !DILocation(line: 11, scope: !21)
134 !51 = !DIExpression(DW_OP_bit_piece, 0, 32)
134 !51 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
135135 !52 = !DILocation(line: 7, scope: !34, inlinedAt: !47)
136136 !53 = !DILocation(line: 7, scope: !15, inlinedAt: !47)
137137 !54 = !DILocation(line: 8, scope: !34, inlinedAt: !47)
1212 ; CHECK-NOT: call void @llvm.dbg.value
1313 ; CHECK: call void @llvm.dbg.value(metadata %foo* undef, i64 0, {{.*}}, metadata ![[BIT_PIECE:[0-9]+]]), !dbg
1414 ; CHECK-NOT: call void @llvm.dbg.value
15 ; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_bit_piece, 64, 64)
15 ; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
1616 %0 = bitcast %foo* %retval to i8*
1717 %1 = getelementptr inbounds i8, i8* %0, i64 8
1818 %2 = bitcast i8* %1 to %foo**
1313 %v2 = alloca i64, align 8
1414 store i32 %hs, i32* %hs.addr, align 4
1515 ; CHECK: call void @llvm.dbg.value(metadata i32 %hs, i64 0, metadata !{{[0-9]+}}, metadata ![[EXPR:[0-9]+]])
16 ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_bit_piece, 0
16 ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_LLVM_fragment, 0
1717 call void @llvm.dbg.declare(metadata i64* %v1, metadata !9, metadata !12), !dbg !13
1818 %0 = load i32, i32* %hs.addr, align 4
1919 %conv = sext i32 %0 to i64
20102010 // Valid constructions.
20112011 EXPECT_VALID(dwarf::DW_OP_plus, 6);
20122012 EXPECT_VALID(dwarf::DW_OP_deref);
2013 EXPECT_VALID(dwarf::DW_OP_bit_piece, 3, 7);
2013 EXPECT_VALID(dwarf::DW_OP_LLVM_fragment, 3, 7);
20142014 EXPECT_VALID(dwarf::DW_OP_plus, 6, dwarf::DW_OP_deref);
20152015 EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_plus, 6);
2016 EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_bit_piece, 3, 7);
2017 EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_plus, 6, dwarf::DW_OP_bit_piece, 3, 7);
2016 EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_LLVM_fragment, 3, 7);
2017 EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_plus, 6,
2018 dwarf::DW_OP_LLVM_fragment, 3, 7);
20182019
20192020 // Invalid constructions.
20202021 EXPECT_INVALID(~0u);
20212022 EXPECT_INVALID(dwarf::DW_OP_plus);
2022 EXPECT_INVALID(dwarf::DW_OP_bit_piece);
2023 EXPECT_INVALID(dwarf::DW_OP_bit_piece, 3);
2024 EXPECT_INVALID(dwarf::DW_OP_bit_piece, 3, 7, dwarf::DW_OP_plus, 3);
2025 EXPECT_INVALID(dwarf::DW_OP_bit_piece, 3, 7, dwarf::DW_OP_deref);
2023 EXPECT_INVALID(dwarf::DW_OP_LLVM_fragment);
2024 EXPECT_INVALID(dwarf::DW_OP_LLVM_fragment, 3);
2025 EXPECT_INVALID(dwarf::DW_OP_LLVM_fragment, 3, 7, dwarf::DW_OP_plus, 3);
2026 EXPECT_INVALID(dwarf::DW_OP_LLVM_fragment, 3, 7, dwarf::DW_OP_deref);
20262027
20272028 #undef EXPECT_VALID
20282029 #undef EXPECT_INVALID