[PATCH] D27562: CodeGen: Do not compute liveins when trackLivenessAfterRegalloc() is false
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 18:24:44 PST 2016
MatzeB created this revision.
MatzeB added a reviewer: qcolombet.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a subscriber: mcrosier.
- Do not even bother computing live-in lists if TargetRegisterInfo::trackLivenessAfterRegalloc() is false. This avoids accidentally relying on the information when it is out of date.
- Add an assert to check whether liveness is tracked before giving access to the live-in list.
Repository:
rL LLVM
https://reviews.llvm.org/D27562
Files:
include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp
lib/CodeGen/MachineVerifier.cpp
lib/CodeGen/VirtRegMap.cpp
Index: lib/CodeGen/VirtRegMap.cpp
===================================================================
--- lib/CodeGen/VirtRegMap.cpp
+++ lib/CodeGen/VirtRegMap.cpp
@@ -225,8 +225,11 @@
// Add kill flags while we still have virtual registers.
LIS->addKillFlags(VRM);
- // Live-in lists on basic blocks are required for physregs.
- addMBBLiveIns();
+ if (TRI->trackLivenessAfterRegAlloc(*MF)) {
+ addMBBLiveIns();
+ } else {
+ MRI->invalidateLiveness();
+ }
// Rewrite virtual registers.
rewrite();
Index: lib/CodeGen/MachineVerifier.cpp
===================================================================
--- lib/CodeGen/MachineVerifier.cpp
+++ lib/CodeGen/MachineVerifier.cpp
@@ -565,7 +565,7 @@
FirstTerminator = nullptr;
if (!MF->getProperties().hasProperty(
- MachineFunctionProperties::Property::NoPHIs)) {
+ MachineFunctionProperties::Property::NoPHIs) && MRI->tracksLiveness()) {
// If this block has allocatable physical registers live-in, check that
// it is an entry block or landing pad.
for (const auto &LI : MBB->liveins()) {
@@ -740,14 +740,16 @@
}
regsLive.clear();
- for (const auto &LI : MBB->liveins()) {
- if (!TargetRegisterInfo::isPhysicalRegister(LI.PhysReg)) {
- report("MBB live-in list contains non-physical register", MBB);
- continue;
+ if (MRI->tracksLiveness()) {
+ for (const auto &LI : MBB->liveins()) {
+ if (!TargetRegisterInfo::isPhysicalRegister(LI.PhysReg)) {
+ report("MBB live-in list contains non-physical register", MBB);
+ continue;
+ }
+ for (MCSubRegIterator SubRegs(LI.PhysReg, TRI, /*IncludeSelf=*/true);
+ SubRegs.isValid(); ++SubRegs)
+ regsLive.insert(*SubRegs);
}
- for (MCSubRegIterator SubRegs(LI.PhysReg, TRI, /*IncludeSelf=*/true);
- SubRegs.isValid(); ++SubRegs)
- regsLive.insert(*SubRegs);
}
regsLiveInButUnused = regsLive;
Index: lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- lib/CodeGen/MachineBasicBlock.cpp
+++ lib/CodeGen/MachineBasicBlock.cpp
@@ -1297,3 +1297,11 @@
// care what kind of return it is, putting a mask after it is a no-op.
return isReturnBlock() && !succ_empty() ? TRI->getNoPreservedMask() : nullptr;
}
+
+iterator_range<MachineBasicBlock::livein_iterator>
+MachineBasicBlock::liveins() const {
+ assert(getParent()->getProperties().hasProperty(
+ MachineFunctionProperties::Property::TracksLiveness) &&
+ "Liveness information is accurate");
+ return make_range(livein_begin(), livein_end());
+}
Index: include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- include/llvm/CodeGen/MachineBasicBlock.h
+++ include/llvm/CodeGen/MachineBasicBlock.h
@@ -307,9 +307,7 @@
livein_iterator livein_begin() const { return LiveIns.begin(); }
livein_iterator livein_end() const { return LiveIns.end(); }
bool livein_empty() const { return LiveIns.empty(); }
- iterator_range<livein_iterator> liveins() const {
- return make_range(livein_begin(), livein_end());
- }
+ iterator_range<livein_iterator> liveins() const;
/// Get the clobber mask for the start of this basic block. Funclets use this
/// to prevent register allocation across funclet transitions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27562.80708.patch
Type: text/x-patch
Size: 3354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/e7a55751/attachment.bin>
More information about the llvm-commits
mailing list