26 assert(DwarfReg >= 0 &&
"invalid negative dwarf register number");
28 "location description already locked down");
31 emitOp(dwarf::DW_OP_reg0 + DwarfReg, Comment);
33 emitOp(dwarf::DW_OP_regx, Comment);
39 assert(DwarfReg >= 0 &&
"invalid negative dwarf register number");
42 emitOp(dwarf::DW_OP_breg0 + DwarfReg);
44 emitOp(dwarf::DW_OP_bregx);
51 emitOp(dwarf::DW_OP_fbreg);
59 const unsigned SizeOfByte = 8;
60 if (OffsetInBits > 0 || SizeInBits % SizeOfByte) {
61 emitOp(dwarf::DW_OP_bit_piece);
65 emitOp(dwarf::DW_OP_piece);
66 unsigned ByteSize = SizeInBits / SizeOfByte;
69 this->OffsetInBits += SizeInBits;
73 emitOp(dwarf::DW_OP_constu);
79 emitOp(dwarf::DW_OP_constu);
85 unsigned MachineReg,
unsigned MaxSize) {
135 Intersection.
set(Offset, Offset + Size);
136 Intersection ^= Coverage;
140 if (Reg >= 0 && Intersection.
any()) {
143 DwarfRegs.push_back({-1, Offset - CurPos,
nullptr});
145 {
Reg, std::min<unsigned>(
Size, MaxSize -
Offset),
"sub-register"});
146 if (Offset >= MaxSize)
150 Coverage.
set(Offset, Offset + Size);
151 CurPos = Offset +
Size;
160 emitOp(dwarf::DW_OP_stack_value);
166 emitOp(dwarf::DW_OP_consts);
173 emitOp(dwarf::DW_OP_constu);
187 while (Offset < Size) {
189 if (Offset == 0 && Size <= 64)
200 unsigned FragmentOffsetInBits) {
202 if (!
addMachineReg(TRI, MachineReg, Fragment ? Fragment->SizeInBits : ~1U)) {
207 bool HasComplexExpression =
false;
208 auto Op = ExprCursor.
peek();
210 HasComplexExpression =
true;
216 if (HasComplexExpression &&
DwarfRegs.size() > 1) {
225 if (Reg.DwarfRegNo >= 0)
226 addReg(Reg.DwarfRegNo, Reg.Comment);
237 return Op.getOp() == dwarf::DW_OP_stack_value;
247 int SignedOffset = 0;
248 assert(Reg.Size == 0 &&
"subregister has same size as superregister");
252 if (
Op && (
Op->getOp() == dwarf::DW_OP_plus_uconst)) {
253 SignedOffset =
Op->getArg(0);
260 if (
Op &&
Op->getOp() == dwarf::DW_OP_constu) {
262 if (
N && (
N->getOp() == dwarf::DW_OP_plus ||
265 SignedOffset = (
N->getOp() == dwarf::DW_OP_minus) ? -Offset : Offset;
273 addBReg(Reg.DwarfRegNo, SignedOffset);
281 auto Op = ExprCursor.
take();
282 switch (
Op->getOp()) {
283 case dwarf::DW_OP_deref:
294 unsigned FragmentOffsetInBits) {
297 auto N = ExprCursor.peek();
302 auto Op = ExprCursor.take();
303 switch (
Op->getOp()) {
305 unsigned SizeInBits =
Op->getArg(1);
306 unsigned FragmentOffset =
Op->getArg(0);
333 case dwarf::DW_OP_plus_uconst:
335 emitOp(dwarf::DW_OP_plus_uconst);
338 case dwarf::DW_OP_plus:
339 case dwarf::DW_OP_minus:
342 case dwarf::DW_OP_deref: {
349 emitOp(dwarf::DW_OP_deref);
352 case dwarf::DW_OP_constu:
354 emitOp(dwarf::DW_OP_constu);
357 case dwarf::DW_OP_stack_value:
360 case dwarf::DW_OP_swap:
362 emitOp(dwarf::DW_OP_swap);
364 case dwarf::DW_OP_xderef:
366 emitOp(dwarf::DW_OP_xderef);
405 "overlapping or duplicate fragments");
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
void addShr(unsigned ShiftBy)
Emit a shift-right dwarf operation.
DIExpression::expr_op_iterator begin() const
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void addUnsignedConstant(uint64_t Value)
Emit an unsigned constant.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
This class provides various memory handling functions that manipulate MemoryBlock instances...
Optional< DIExpression::ExprOperand > peek() const
Return the current operation.
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const
For a given register pair, return the sub-register index if the second register is a sub-register of ...
MCSuperRegIterator enumerates all super-registers of Reg.
Reg
All possible values of the reg field in the ModR/M byte.
void addBReg(int DwarfReg, int Offset)
Emit a DW_OP_breg operation.
void addFBReg(int Offset)
Emit DW_OP_fbreg <Offset>.
Only used in LLVM metadata.
enum llvm::DwarfExpression::@277 LocationKind
The kind of location description being produced.
Holds a DIExpression and keeps track of how many operands have been consumed so far.
void addReg(int DwarfReg, const char *Comment=nullptr)
Emit a DW_OP_reg operation.
void setSubRegisterPiece(unsigned SizeInBits, unsigned OffsetInBits)
Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed to represent a subregister...
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
void maskSubRegister()
Add masking operations to stencil out a subregister.
bool isFragment() const
Return whether this is a piece of an aggregate variable.
virtual void emitUnsigned(uint64_t Value)=0
Emit a raw unsigned value.
Optional< DIExpression::ExprOperand > take()
Consume one operation.
Optional< DIExpression::FragmentInfo > getFragmentInfo() const
Retrieve the fragment information, if any.
virtual void emitOp(uint8_t Op, const char *Comment=nullptr)=0
Output a dwarf operand and an optional assembler comment.
Optional< DIExpression::ExprOperand > peekNext() const
Return the next operation.
A lightweight wrapper around an expression operand.
uint64_t OffsetInBits
Current Fragment Offset in Bits.
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
unsigned getBitWidth() const
Return the number of bits in the APInt.
virtual void emitSigned(int64_t Value)=0
Emit a raw signed value.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
unsigned SubRegisterOffsetInBits
void addExpression(DIExpressionCursor &&Expr, unsigned FragmentOffsetInBits=0)
Emit all remaining operations in the DIExpressionCursor.
bool addMachineReg(const TargetRegisterInfo &TRI, unsigned MachineReg, unsigned MaxSize=~1U)
Emit a partial DWARF register operation.
void addStackValue()
Emit a DW_OP_stack_value, if supported.
Class for arbitrary precision integers.
void addAnd(unsigned Mask)
Emit a bitwise and dwarf operation.
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
DIExpression::expr_op_iterator end() const
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
unsigned SubRegisterSizeInBits
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
void consume(unsigned N)
Consume N operations.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
void finalize()
This needs to be called last to commit any pending changes.
unsigned getSubRegIdxOffset(unsigned Idx) const
Get the offset of the bit range covered by a sub-register index.
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
Holds information about all subregisters comprising a register location.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool any() const
Returns true if any bit is set.
void addOpPiece(unsigned SizeInBits, unsigned OffsetInBits=0)
Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static bool isMemoryLocation(DIExpressionCursor ExprCursor)
Assuming a well-formed expression, match "DW_OP_deref* DW_OP_LLVM_fragment?".
void addSignedConstant(int64_t Value)
Emit a signed constant.
SmallVector< Register, 2 > DwarfRegs
The register location, if any.
unsigned getSubRegIdxSize(unsigned Idx) const
Get the size of the bit range covered by a sub-register index.
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, unsigned MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg)=0
Return whether the given machine register is the frame register in the current function.