[llvm] 8597458 - [regalloc] Fix assertion error when LiveInterval is empty
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 22:08:40 PST 2022
Author: wangpc
Date: 2022-01-26T14:06:57+08:00
New Revision: 8597458278027047c06a1a81579893335e761a33
URL: https://github.com/llvm/llvm-project/commit/8597458278027047c06a1a81579893335e761a33
DIFF: https://github.com/llvm/llvm-project/commit/8597458278027047c06a1a81579893335e761a33.diff
LOG: [regalloc] Fix assertion error when LiveInterval is empty
When evicting interference, it causes an asseertion error
since LiveIntervals::intervalIsInOneMBB assumes that input
is not empty.
This patch fixed bug mentioned in D118020.
Reviewed By: MatzeB
Differential Revision: https://reviews.llvm.org/D118124
Added:
Modified:
llvm/lib/CodeGen/LiveIntervals.cpp
llvm/lib/CodeGen/RegAllocGreedy.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index 2f97386b6d189..9571afa434c12 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -827,6 +827,8 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) {
MachineBasicBlock*
LiveIntervals::intervalIsInOneMBB(const LiveInterval &LI) const {
+ assert(!LI.empty() && "LiveInterval is empty.");
+
// A local live range must be fully contained inside the block, meaning it is
// defined and killed at instructions, not at block boundaries. It is not
// live in or out of any block.
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 79314874093fb..6ea6dbcbbb743 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -497,7 +497,7 @@ bool DefaultEvictionAdvisor::canEvictInterferenceBasedOnCost(
if (Matrix->checkInterference(VirtReg, PhysReg) > LiveRegMatrix::IK_VirtReg)
return false;
- bool IsLocal = LIS->intervalIsInOneMBB(VirtReg);
+ bool IsLocal = VirtReg.empty() || LIS->intervalIsInOneMBB(VirtReg);
// Find VirtReg's cascade number. This will be unassigned if VirtReg was never
// involved in an eviction before. If a cascade number was assigned, deny
More information about the llvm-commits
mailing list