llvm.org GIT mirror llvm / db48bda
Debug Info: Emitting a register in DwarfExpression may fail. Report the status in a bool and let the users deal with the error. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225899 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 5 years ago
3 changed file(s) with 26 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
243243 "nop (could not find a dwarf register number)");
244244
245245 // Attempt to find a valid super- or sub-register.
246 return Expr.AddMachineRegPiece(MLoc.getReg());
246 if (!Expr.AddMachineRegPiece(MLoc.getReg()))
247 Expr.EmitOp(dwarf::DW_OP_nop,
248 "nop (could not find a dwarf register number)");
249 return;
247250 }
248251
249252 if (MLoc.isIndirect())
8888 return true;
8989 }
9090
91 void DwarfExpression::AddMachineRegPiece(unsigned MachineReg,
91 bool DwarfExpression::AddMachineRegPiece(unsigned MachineReg,
9292 unsigned PieceSizeInBits,
9393 unsigned PieceOffsetInBits) {
9494 const TargetRegisterInfo *TRI = getTRI();
9999 AddReg(Reg);
100100 if (PieceSizeInBits)
101101 AddOpPiece(PieceSizeInBits, PieceOffsetInBits);
102 return;
102 return true;
103103 }
104104
105105 // Walk up the super-register chain until we find a valid number.
122122 AddShr(RegOffset);
123123 AddOpPiece(Size, PieceOffsetInBits);
124124 }
125 return;
125 return true;
126126 }
127127 }
128128
161161 }
162162 }
163163
164 if (CurPos == PieceOffsetInBits)
165 // FIXME: We have no reasonable way of handling errors in here.
166 EmitOp(dwarf::DW_OP_nop, "nop (could not find a dwarf register number)");
164 return CurPos > PieceOffsetInBits;
167165 }
168166
169167 void DwarfExpression::AddSignedConstant(int Value) {
199197 return OffsetInBits;
200198 }
201199
202 void DwarfExpression::AddMachineRegExpression(DIExpression Expr,
200 bool DwarfExpression::AddMachineRegExpression(DIExpression Expr,
203201 unsigned MachineReg,
204202 unsigned PieceOffsetInBits) {
205203 unsigned N = Expr.getNumElements();
206204 unsigned I = 0;
205 bool ValidReg = false;
207206 // Pattern-match combinations for which more efficient representations exist
208207 // first.
209208 if (N >= 3 && Expr.getElement(0) == dwarf::DW_OP_piece) {
210209 unsigned SizeOfByte = 8;
211210 unsigned OffsetInBits = Expr.getElement(1) * SizeOfByte;
212211 unsigned SizeInBits = Expr.getElement(2) * SizeOfByte;
213 AddMachineRegPiece(MachineReg, SizeInBits,
214 getOffsetOrZero(OffsetInBits, PieceOffsetInBits));
212 ValidReg =
213 AddMachineRegPiece(MachineReg, SizeInBits,
214 getOffsetOrZero(OffsetInBits, PieceOffsetInBits));
215215 I = 3;
216216 } else if (N >= 3 && Expr.getElement(0) == dwarf::DW_OP_plus &&
217217 Expr.getElement(2) == dwarf::DW_OP_deref) {
218218 // [DW_OP_reg,Offset,DW_OP_plus,DW_OP_deref] --> [DW_OP_breg,Offset].
219219 unsigned Offset = Expr.getElement(1);
220 AddMachineRegIndirect(MachineReg, Offset);
220 ValidReg = AddMachineRegIndirect(MachineReg, Offset);
221221 I = 3;
222222 } else if (N >= 1 && Expr.getElement(0) == dwarf::DW_OP_deref) {
223223 // [DW_OP_reg,DW_OP_deref] --> [DW_OP_breg].
224 AddMachineRegIndirect(MachineReg);
224 ValidReg = AddMachineRegIndirect(MachineReg);
225225 I = 1;
226226 } else
227 AddMachineRegPiece(MachineReg);
227 ValidReg = AddMachineRegPiece(MachineReg);
228
229 if (!ValidReg)
230 return false;
228231
229232 // Emit remaining elements of the expression.
230233 AddExpression(Expr, I);
234 return true;
231235 }
232236
233237 void DwarfExpression::AddExpression(DIExpression Expr, unsigned I,
6161 void AddShr(unsigned ShiftBy);
6262
6363 /// Emit an indirect dwarf register operation for the given machine register.
64 /// Returns false if no DWARF register exists for MachineReg.
64 /// \return false if no DWARF register exists for MachineReg.
6565 bool AddMachineRegIndirect(unsigned MachineReg, int Offset = 0);
6666
6767 /// \brief Emit a partial DWARF register operation.
7676 /// function will attempt to emit a DWARF register by emitting a
7777 /// piece of a super-register or by piecing together multiple
7878 /// subregisters that alias the register.
79 void AddMachineRegPiece(unsigned MachineReg, unsigned PieceSizeInBits = 0,
79 ///
80 /// \return false if no DWARF register exists for MachineReg.
81 bool AddMachineRegPiece(unsigned MachineReg, unsigned PieceSizeInBits = 0,
8082 unsigned PieceOffsetInBits = 0);
8183
8284 /// Emit a signed constant.
8789 /// Emit an entire DIExpression on top of a machine register location.
8890 /// \param PieceOffsetInBits If this is one piece out of a fragmented
8991 /// location, this is the offset of the piece inside the entire variable.
90 void AddMachineRegExpression(DIExpression Expr, unsigned MachineReg,
92 /// \return false if no DWARF register exists for MachineReg.
93 bool AddMachineRegExpression(DIExpression Expr, unsigned MachineReg,
9194 unsigned PieceOffsetInBits = 0);
9295 /// Emit a the operations in a DIExpression, starting from element I.
9396 /// \param PieceOffsetInBits If this is one piece out of a fragmented