[llvm] a68d72a - MachineVerifier: Don't crash in LiveIntervals checks on generic vregs
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 1 05:47:20 PDT 2023
Author: Matt Arsenault
Date: 2023-09-01T08:32:02-04:00
New Revision: a68d72a9950f01b7ed7e8be98eabab5f69d254be
URL: https://github.com/llvm/llvm-project/commit/a68d72a9950f01b7ed7e8be98eabab5f69d254be
DIFF: https://github.com/llvm/llvm-project/commit/a68d72a9950f01b7ed7e8be98eabab5f69d254be.diff
LOG: MachineVerifier: Don't crash in LiveIntervals checks on generic vregs
If llvm-reduce is going to unconditionally verify functions with
LiveIntervals, it needs to be tolerant of generic vregs.
https://reviews.llvm.org/D133813
Added:
Modified:
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/lib/CodeGen/MachineVerifier.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
index 496224a85c52c3..9bca74a1d4fc82 100644
--- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -229,7 +229,8 @@ class MachineRegisterInfo {
}
bool shouldTrackSubRegLiveness(Register VReg) const {
assert(VReg.isVirtual() && "Must pass a VReg");
- return shouldTrackSubRegLiveness(*getRegClass(VReg));
+ const TargetRegisterClass *RC = getRegClassOrNull(VReg);
+ return LLVM_LIKELY(RC) ? shouldTrackSubRegLiveness(*RC) : false;
}
bool subRegLivenessEnabled() const {
return TracksSubRegLiveness;
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index c626b41feafac1..cfca2d4ba6798f 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -3383,26 +3383,28 @@ void MachineVerifier::verifyLiveInterval(const LiveInterval &LI) {
assert(Reg.isVirtual());
verifyLiveRange(LI, Reg);
- LaneBitmask Mask;
- LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg);
- for (const LiveInterval::SubRange &SR : LI.subranges()) {
- if ((Mask & SR.LaneMask).any()) {
- report("Lane masks of sub ranges overlap in live interval", MF);
- report_context(LI);
- }
- if ((SR.LaneMask & ~MaxMask).any()) {
- report("Subrange lanemask is invalid", MF);
- report_context(LI);
- }
- if (SR.empty()) {
- report("Subrange must not be empty", MF);
- report_context(SR, LI.reg(), SR.LaneMask);
- }
- Mask |= SR.LaneMask;
- verifyLiveRange(SR, LI.reg(), SR.LaneMask);
- if (!LI.covers(SR)) {
- report("A Subrange is not covered by the main range", MF);
- report_context(LI);
+ if (LI.hasSubRanges()) {
+ LaneBitmask Mask;
+ LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg);
+ for (const LiveInterval::SubRange &SR : LI.subranges()) {
+ if ((Mask & SR.LaneMask).any()) {
+ report("Lane masks of sub ranges overlap in live interval", MF);
+ report_context(LI);
+ }
+ if ((SR.LaneMask & ~MaxMask).any()) {
+ report("Subrange lanemask is invalid", MF);
+ report_context(LI);
+ }
+ if (SR.empty()) {
+ report("Subrange must not be empty", MF);
+ report_context(SR, LI.reg(), SR.LaneMask);
+ }
+ Mask |= SR.LaneMask;
+ verifyLiveRange(SR, LI.reg(), SR.LaneMask);
+ if (!LI.covers(SR)) {
+ report("A Subrange is not covered by the main range", MF);
+ report_context(LI);
+ }
}
}
More information about the llvm-commits
mailing list