Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions llvm/include/llvm/CodeGen/MachineBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ template <> struct ilist_traits<MachineInstr> {
MachineBasicBlock *Parent;

using instr_iterator =
simple_ilist<MachineInstr, ilist_sentinel_tracking<true>>::iterator;
simple_ilist<MachineInstr, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>::iterator;

public:
LLVM_ABI void addNodeToList(MachineInstr *N);
Expand Down Expand Up @@ -144,7 +144,7 @@ class MachineBasicBlock
};

private:
using Instructions = ilist<MachineInstr, ilist_sentinel_tracking<true>>;
using Instructions = ilist<MachineInstr, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>;

const BasicBlock *BB;
int Number;
Expand Down Expand Up @@ -1314,6 +1314,16 @@ class MachineBasicBlock
/// unless you know what you're doing, because it doesn't update Pred's
/// successors list. Use Pred->removeSuccessor instead.
void removePredecessor(MachineBasicBlock *Pred);

public:
DbgMachineMarker *getNextMarker(MachineInstr *I);
DbgMachineMarker *getMarker(iterator It);
void setTrailingDbgRecords(DbgMachineMarker *M);
DbgMachineMarker *getTrailingDbgRecords();
void deleteTrailingDbgRecords();
void flushTerminatorDbgRecords();
DbgMachineMarker *createMarker(MachineInstr *I);
DbgMachineMarker *createMarker(iterator I);
};

LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const MachineBasicBlock &MBB);
Expand Down
11 changes: 11 additions & 0 deletions llvm/include/llvm/CodeGen/MachineFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ class LLVM_ABI MachineFunction {
/// enough information for every DBG_INSTR_REF to point at an instruction
/// (or DBG_PHI).
void finalizeDebugInstrRefs();
std::optional<std::pair<unsigned, unsigned>> finalizeDebugInstrRefRef(Register R, DenseMap<Register, DebugInstrOperandPair> &ArgDbgPHIs);

/// Determine whether, in the current machine configuration, we should use
/// instruction referencing or not.
Expand Down Expand Up @@ -1469,6 +1470,16 @@ class LLVM_ABI MachineFunction {
unsigned getNewDebugInstrNum() {
return ++DebugInstrNumberingCount;
}

SmallDenseMap<MachineBasicBlock *, DbgMachineMarker *> MachineTrailingDbgRecords;
void setTrailingDbgRecords(MachineBasicBlock *B, DbgMachineMarker *M) {
assert(!MachineTrailingDbgRecords.count(B));
MachineTrailingDbgRecords[B] = M;
}
DbgMachineMarker *getTrailingDbgRecords(MachineBasicBlock *B) {
return MachineTrailingDbgRecords.lookup(B);
}
void deleteTrailingDbgRecords(MachineBasicBlock *B) { MachineTrailingDbgRecords.erase(B); }
};

//===--------------------------------------------------------------------===//
Expand Down
26 changes: 26 additions & 0 deletions llvm/include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class StringRef;
class TargetInstrInfo;
class TargetRegisterClass;
class TargetRegisterInfo;
class DbgMachineMarker;
class DbgMachineRecord;

LLVM_ABI iterator_range<simple_ilist<DbgMachineRecord>::iterator>
getDbgRecordRange(DbgMachineMarker *);

//===----------------------------------------------------------------------===//
/// Representation of each machine instruction.
Expand All @@ -69,9 +74,12 @@ class TargetRegisterInfo;
///
class MachineInstr
: public ilist_node_with_parent<MachineInstr, MachineBasicBlock,
ilist_iterator_bits<true>,
ilist_sentinel_tracking<true>> {
public:
using mmo_iterator = ArrayRef<MachineMemOperand *>::iterator;
using instr_iterator =
simple_ilist<MachineInstr, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>::iterator;

/// Flags to specify different kinds of comments to output in
/// assembly code. These flags carry semantic information not
Expand Down Expand Up @@ -304,6 +312,8 @@ class MachineInstr

DebugLoc DbgLoc; // Source line information.

private:

/// Unique instruction number. Used by DBG_INSTR_REFs to refer to the values
/// defined by this instruction.
unsigned DebugInstrNum;
Expand Down Expand Up @@ -359,6 +369,7 @@ class MachineInstr

/// Move the instruction before \p MovePos.
LLVM_ABI void moveBefore(MachineInstr *MovePos);
LLVM_ABI void moveBefore(instr_iterator MovePos);

/// Return the function that contains the basic block that this instruction
/// belongs to.
Expand Down Expand Up @@ -1388,6 +1399,11 @@ class MachineInstr
return false;
}

/// Return a range over the DbgRecords attached to this instruction.
iterator_range<simple_ilist<DbgMachineRecord>::iterator> getDbgRecordRange() const {
return llvm::getDbgRecordRange(DebugMarker);
}

bool isJumpTableDebugInfo() const {
return getOpcode() == TargetOpcode::JUMP_TABLE_DEBUG_INFO;
}
Expand Down Expand Up @@ -2079,6 +2095,16 @@ class MachineInstr
MCSymbol *PreInstrSymbol, MCSymbol *PostInstrSymbol,
MDNode *HeapAllocMarker, MDNode *PCSections,
uint32_t CFIType, MDNode *MMRAs);

public:
DbgMachineMarker *DebugMarker = nullptr;
void handleMarkerRemoval();
/// Transfer any DbgRecords on the position \p It onto this instruction,
/// by simply adopting the sequence of DbgRecords (which is efficient) if
/// possible, by merging two sequences otherwise.
LLVM_ABI void adoptDbgRecords(MachineBasicBlock *BB, instr_iterator It,
bool InsertAtHead);

};

/// Special DenseMapInfo traits to compare MachineInstr* by *value* of the
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/CodeGen/MachineInstrBundleIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ namespace llvm {

template <class T, bool IsReverse> struct MachineInstrBundleIteratorTraits;
template <class T> struct MachineInstrBundleIteratorTraits<T, false> {
using list_type = simple_ilist<T, ilist_sentinel_tracking<true>>;
using list_type = simple_ilist<T, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>;
using instr_iterator = typename list_type::iterator;
using nonconst_instr_iterator = typename list_type::iterator;
using const_instr_iterator = typename list_type::const_iterator;
};
template <class T> struct MachineInstrBundleIteratorTraits<T, true> {
using list_type = simple_ilist<T, ilist_sentinel_tracking<true>>;
using list_type = simple_ilist<T, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>;
using instr_iterator = typename list_type::reverse_iterator;
using nonconst_instr_iterator = typename list_type::reverse_iterator;
using const_instr_iterator = typename list_type::const_reverse_iterator;
};
template <class T> struct MachineInstrBundleIteratorTraits<const T, false> {
using list_type = simple_ilist<T, ilist_sentinel_tracking<true>>;
using list_type = simple_ilist<T, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>;
using instr_iterator = typename list_type::const_iterator;
using nonconst_instr_iterator = typename list_type::iterator;
using const_instr_iterator = typename list_type::const_iterator;
};
template <class T> struct MachineInstrBundleIteratorTraits<const T, true> {
using list_type = simple_ilist<T, ilist_sentinel_tracking<true>>;
using list_type = simple_ilist<T, ilist_iterator_bits<true>, ilist_sentinel_tracking<true>>;
using instr_iterator = typename list_type::const_reverse_iterator;
using nonconst_instr_iterator = typename list_type::reverse_iterator;
using const_instr_iterator = typename list_type::const_reverse_iterator;
Expand Down
Loading