Skip to content
Merged
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
9 changes: 5 additions & 4 deletions llvm/include/llvm/CodeGen/LivePhysRegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,15 @@ void computeAndAddLiveIns(LivePhysRegs &LiveRegs,
/// any changes were made.
static inline bool recomputeLiveIns(MachineBasicBlock &MBB) {
LivePhysRegs LPR;
auto oldLiveIns = MBB.getLiveIns();
std::vector<MachineBasicBlock::RegisterMaskPair> OldLiveIns;

MBB.clearLiveIns();
MBB.clearLiveIns(OldLiveIns);
computeAndAddLiveIns(LPR, MBB);
MBB.sortUniqueLiveIns();

auto newLiveIns = MBB.getLiveIns();
return oldLiveIns != newLiveIns;
const std::vector<MachineBasicBlock::RegisterMaskPair> &NewLiveIns =
MBB.getLiveIns();
return OldLiveIns != NewLiveIns;
}

/// Convenience function for recomputing live-in's for a set of MBBs until the
Expand Down
6 changes: 5 additions & 1 deletion llvm/include/llvm/CodeGen/MachineBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ class MachineBasicBlock
/// Clear live in list.
void clearLiveIns();

/// Clear the live in list, and return the removed live in's in \p OldLiveIns.
/// Requires that the vector \p OldLiveIns is empty.
void clearLiveIns(std::vector<RegisterMaskPair> &OldLiveIns);

/// Add PhysReg as live in to this block, and ensure that there is a copy of
/// PhysReg to a virtual register of class RC. Return the virtual register
/// that is a copy of the live in PhysReg.
Expand Down Expand Up @@ -477,7 +481,7 @@ class MachineBasicBlock
/// Remove entry from the livein set and return iterator to the next.
livein_iterator removeLiveIn(livein_iterator I);

std::vector<RegisterMaskPair> getLiveIns() const { return LiveIns; }
const std::vector<RegisterMaskPair> &getLiveIns() const { return LiveIns; }

class liveout_iterator {
public:
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/CodeGen/MachineBasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,12 @@ void MachineBasicBlock::clearLiveIns() {
LiveIns.clear();
}

void MachineBasicBlock::clearLiveIns(
std::vector<RegisterMaskPair> &OldLiveIns) {
assert(OldLiveIns.empty() && "Vector must be empty");
std::swap(LiveIns, OldLiveIns);
}

MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
assert(getParent()->getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness) &&
Expand Down