diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h | 12 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 31 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 16 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 10 |
7 files changed, 46 insertions, 49 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 57d6fae0fbd..7fb84605071 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -656,9 +656,9 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { OS << V.getName(); DIExpression Expr = MI->getDebugExpression(); - if (Expr.isVariablePiece()) - OS << " [piece offset=" << Expr.getPieceOffset() - << " size=" << Expr.getPieceSize() << "]"; + if (Expr.isBitPiece()) + OS << " [bit_piece offset=" << Expr.getBitPieceOffset() + << " size=" << Expr.getBitPieceSize() << "]"; OS << " <- "; // The second operand is only an offset if it's an immediate. diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h index b4fcada59ec..6d55c038541 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h +++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h @@ -74,7 +74,7 @@ public: MachineLocation getLoc() const { return Loc; } const MDNode *getVariableNode() const { return Variable; } DIVariable getVariable() const { return DIVariable(Variable); } - bool isVariablePiece() const { return getExpression().isVariablePiece(); } + bool isBitPiece() const { return getExpression().isBitPiece(); } DIExpression getExpression() const { return DIExpression(Expression); } friend bool operator==(const Value &, const Value &); friend bool operator<(const Value &, const Value &); @@ -101,8 +101,8 @@ public: DIVariable Var(Values[0].Variable); DIExpression NextExpr(Next.Values[0].Expression); DIVariable NextVar(Next.Values[0].Variable); - if (Var == NextVar && Expr.isVariablePiece() && - NextExpr.isVariablePiece()) { + if (Var == NextVar && Expr.isBitPiece() && + NextExpr.isBitPiece()) { addValues(Next.Values); End = Next.End; return true; @@ -131,7 +131,7 @@ public: Values.append(Vals.begin(), Vals.end()); sortUniqueValues(); assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value V){ - return V.isVariablePiece(); + return V.isBitPiece(); }) && "value must be a piece"); } @@ -176,8 +176,8 @@ inline bool operator==(const DebugLocEntry::Value &A, /// Compare two pieces based on their offset. inline bool operator<(const DebugLocEntry::Value &A, const DebugLocEntry::Value &B) { - return A.getExpression().getPieceOffset() < - B.getExpression().getPieceOffset(); + return A.getExpression().getBitPieceOffset() < + B.getExpression().getBitPieceOffset(); } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e8bcf0b856b..8cb033a175e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -818,12 +818,12 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { /// Determine whether two variable pieces overlap. static bool piecesOverlap(DIExpression P1, DIExpression P2) { - if (!P1.isVariablePiece() || !P2.isVariablePiece()) + if (!P1.isBitPiece() || !P2.isBitPiece()) return true; - unsigned l1 = P1.getPieceOffset(); - unsigned l2 = P2.getPieceOffset(); - unsigned r1 = l1 + P1.getPieceSize(); - unsigned r2 = l2 + P2.getPieceSize(); + unsigned l1 = P1.getBitPieceOffset(); + unsigned l2 = P2.getBitPieceOffset(); + unsigned r1 = l1 + P1.getBitPieceSize(); + unsigned r2 = l2 + P2.getBitPieceSize(); // True where [l1,r1[ and [r1,r2[ overlap. return (l1 < r2) && (l2 < r1); } @@ -894,7 +894,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, bool couldMerge = false; // If this is a piece, it may belong to the current DebugLocEntry. - if (DIExpr.isVariablePiece()) { + if (DIExpr.isBitPiece()) { // Add this value to the list of open ranges. OpenRanges.push_back(Value); @@ -1193,7 +1193,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { if (DIVar.isVariable() && DIVar.getTag() == dwarf::DW_TAG_arg_variable && getDISubprogram(DIVar.getContext()).describes(MF->getFunction())) { LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym; - if (Ranges.front().first->getDebugExpression().isVariablePiece()) { + if (Ranges.front().first->getDebugExpression().isBitPiece()) { // Mark all non-overlapping initial pieces. for (auto I = Ranges.begin(); I != Ranges.end(); ++I) { DIExpression Piece = I->first->getDebugExpression(); @@ -1661,21 +1661,20 @@ void DwarfDebug::emitLocPieces(ByteStreamer &Streamer, const DITypeIdentifierMap &Map, ArrayRef<DebugLocEntry::Value> Values) { assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value P) { - return P.isVariablePiece(); + return P.isBitPiece(); }) && "all values are expected to be pieces"); assert(std::is_sorted(Values.begin(), Values.end()) && "pieces are expected to be sorted"); unsigned Offset = 0; for (auto Piece : Values) { - const unsigned SizeOfByte = 8; DIExpression Expr = Piece.getExpression(); - unsigned PieceOffset = Expr.getPieceOffset(); - unsigned PieceSize = Expr.getPieceSize(); + unsigned PieceOffset = Expr.getBitPieceOffset(); + unsigned PieceSize = Expr.getBitPieceSize(); assert(Offset <= PieceOffset && "overlapping or duplicate pieces"); if (Offset < PieceOffset) { // The DWARF spec seriously mandates pieces with no locations for gaps. - Asm->EmitDwarfOpPiece(Streamer, (PieceOffset-Offset)*SizeOfByte); + Asm->EmitDwarfOpPiece(Streamer, PieceOffset-Offset); Offset += PieceOffset-Offset; } Offset += PieceSize; @@ -1683,12 +1682,12 @@ void DwarfDebug::emitLocPieces(ByteStreamer &Streamer, #ifndef NDEBUG DIVariable Var = Piece.getVariable(); unsigned VarSize = Var.getSizeInBits(Map); - assert(PieceSize+PieceOffset <= VarSize/SizeOfByte + assert(PieceSize+PieceOffset <= VarSize && "piece is larger than or outside of variable"); - assert(PieceSize*SizeOfByte != VarSize + assert(PieceSize != VarSize && "piece covers entire variable"); #endif - emitDebugLocValue(Streamer, Piece, PieceOffset*SizeOfByte); + emitDebugLocValue(Streamer, Piece, PieceOffset); } } @@ -1696,7 +1695,7 @@ void DwarfDebug::emitLocPieces(ByteStreamer &Streamer, void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry) { const DebugLocEntry::Value Value = Entry.getValues()[0]; - if (Value.isVariablePiece()) + if (Value.isBitPiece()) // Emit all pieces that belong to the same variable and range. return emitLocPieces(Streamer, TypeIdentifierMap, Entry.getValues()); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 7c5c879289b..3d1e3822c51 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -211,10 +211,9 @@ bool DwarfExpression::AddMachineRegExpression(DIExpression Expr, bool ValidReg = false; switch (*I) { - case dwarf::DW_OP_piece: { - unsigned SizeOfByte = 8; - unsigned OffsetInBits = I->getArg(1) * SizeOfByte; - unsigned SizeInBits = I->getArg(2) * SizeOfByte; + case dwarf::DW_OP_bit_piece: { + unsigned OffsetInBits = I->getArg(1); + unsigned SizeInBits = I->getArg(2); // Piece always comes at the end of the expression. return AddMachineRegPiece(MachineReg, SizeInBits, getOffsetOrZero(OffsetInBits, PieceOffsetInBits)); @@ -249,10 +248,9 @@ void DwarfExpression::AddExpression(DIExpression::iterator I, unsigned PieceOffsetInBits) { for (; I != DIExpression::iterator(); ++I) { switch (*I) { - case dwarf::DW_OP_piece: { - unsigned SizeOfByte = 8; - unsigned OffsetInBits = I->getArg(1) * SizeOfByte; - unsigned SizeInBits = I->getArg(2) * SizeOfByte; + case dwarf::DW_OP_bit_piece: { + unsigned OffsetInBits = I->getArg(1); + unsigned SizeInBits = I->getArg(2); AddOpPiece(SizeInBits, getOffsetOrZero(OffsetInBits, PieceOffsetInBits)); break; } diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index a1af40546b7..9649d773d5a 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -961,9 +961,9 @@ DIExpression DIBuilder::createExpression(ArrayRef<int64_t> Signed) { return createExpression(Addr); } -DIExpression DIBuilder::createPieceExpression(unsigned OffsetInBytes, - unsigned SizeInBytes) { - uint64_t Addr[] = {dwarf::DW_OP_piece, OffsetInBytes, SizeInBytes}; +DIExpression DIBuilder::createBitPieceExpression(unsigned OffsetInBits, + unsigned SizeInBits) { + int64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBits, SizeInBits}; return createExpression(Addr); } diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index ad661c5c435..31f1e19a945 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -147,18 +147,18 @@ uint64_t DIExpression::getElement(unsigned Idx) const { return getHeaderFieldAs<int64_t>(I); } -bool DIExpression::isVariablePiece() const { +bool DIExpression::isBitPiece() const { unsigned N = getNumElements(); - return N >=3 && getElement(N-3) == dwarf::DW_OP_piece; + return N >=3 && getElement(N-3) == dwarf::DW_OP_bit_piece; } -uint64_t DIExpression::getPieceOffset() const { - assert(isVariablePiece() && "not a piece"); +uint64_t DIExpression::getBitPieceOffset() const { + assert(isBitPiece() && "not a piece"); return getElement(getNumElements()-2); } -uint64_t DIExpression::getPieceSize() const { - assert(isVariablePiece() && "not a piece"); +uint64_t DIExpression::getBitPieceSize() const { + assert(isBitPiece() && "not a piece"); return getElement(getNumElements()-1); } @@ -612,7 +612,7 @@ bool DIExpression::Verify() const { for (auto Op : *this) switch (Op) { - case DW_OP_piece: + case DW_OP_bit_piece: // Must be the last element of the expression. return std::distance(Op.getBase(), DIHeaderFieldIterator()) == 3; case DW_OP_plus: @@ -1417,7 +1417,7 @@ void DIExpression::printInternal(raw_ostream &OS) const { OS << " " << Op.getArg(1); break; } - case DW_OP_piece: { + case DW_OP_bit_piece: { OS << " offset=" << Op.getArg(1) << ", size=" << Op.getArg(2); break; } diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 6faf905f9b3..eaf73ee5e68 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4175,15 +4175,15 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { // Create a piece expression describing the new partition or reuse AI's // expression if there is only one partition. DIExpression PieceExpr = Expr; - if (IsSplit || Expr.isVariablePiece()) { + if (IsSplit || Expr.isBitPiece()) { // If this alloca is already a scalar replacement of a larger aggregate, // Piece.Offset describes the offset inside the scalar. - unsigned Offset = Expr.isVariablePiece() ? Expr.getPieceOffset() : 0; + unsigned Offset = Expr.isBitPiece() ? Expr.getBitPieceOffset() : 0; assert((Offset == 0 || - Offset+Piece.Offset+Piece.Size <= - Expr.getPieceOffset()+Expr.getPieceSize()) && + Offset+Piece.Offset+Piece.Size*8 <= + Expr.getBitPieceOffset()+Expr.getBitPieceSize()) && "inner piece is not inside original alloca"); - PieceExpr = DIB.createPieceExpression(Offset+Piece.Offset, Piece.Size); + PieceExpr = DIB.createBitPieceExpression(Offset+Piece.Offset*8, Piece.Size*8); } // Remove any existing dbg.declare intrinsic describing the same alloca. |