diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 12 |
2 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 5419a10f4f9..61b2c7e6584 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -86,7 +86,7 @@ bool DwarfExpression::AddMachineRegIndirect(const TargetRegisterInfo &TRI, } bool DwarfExpression::AddMachineReg(const TargetRegisterInfo &TRI, - unsigned MachineReg) { + unsigned MachineReg, unsigned MaxSize) { if (!TRI.isPhysicalRegister(MachineReg)) return false; @@ -137,10 +137,12 @@ bool DwarfExpression::AddMachineReg(const TargetRegisterInfo &TRI, // its range, emit a DWARF piece for it. if (Reg >= 0 && Intersection.any()) { AddReg(Reg, "sub-register"); + if (Offset >= MaxSize) + break; // Emit a piece for the any gap in the coverage. if (Offset > CurPos) AddOpPiece(Offset - CurPos); - AddOpPiece(Size); + AddOpPiece(std::min<unsigned>(Size, MaxSize - Offset)); CurPos = Offset + Size; // Mark it as emitted. @@ -196,9 +198,12 @@ bool DwarfExpression::AddMachineRegExpression(const TargetRegisterInfo &TRI, bool ValidReg = false; auto Op = ExprCursor.peek(); switch (Op->getOp()) { - default: - ValidReg = AddMachineReg(TRI, MachineReg); + default: { + auto Fragment = ExprCursor.getFragmentInfo(); + ValidReg = AddMachineReg(TRI, MachineReg, + Fragment ? Fragment->SizeInBits : ~1U); break; + } case dwarf::DW_OP_plus: case dwarf::DW_OP_minus: { // [DW_OP_reg,Offset,DW_OP_plus, DW_OP_deref] --> [DW_OP_breg, Offset]. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 96d9f09faf0..fd90fa05bc3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -72,6 +72,11 @@ public: } /// Determine whether there are any operations left in this expression. operator bool() const { return Start != End; } + + /// Retrieve the fragment information, if any. + Optional<DIExpression::FragmentInfo> getFragmentInfo() const { + return DIExpression::getFragmentInfo(Start, End); + } }; /// Base class containing the logic for constructing DWARF expressions @@ -145,6 +150,10 @@ public: /// Emit a partial DWARF register operation. /// /// \param MachineReg The register number. + /// \param MaxSize If the register must be composed from + /// sub-registers this is an upper bound + /// for how many bits the emitted DW_OP_piece + /// may cover. /// /// 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 @@ -153,7 +162,8 @@ public: /// multiple subregisters that alias the register. /// /// \return false if no DWARF register exists for MachineReg. - bool AddMachineReg(const TargetRegisterInfo &TRI, unsigned MachineReg); + bool AddMachineReg(const TargetRegisterInfo &TRI, unsigned MachineReg, + unsigned MaxSize = ~1U); /// Emit a signed constant. void AddSignedConstant(int64_t Value); |

