[PATCH] D133813: MachineVerifier: Don't crash in LiveIntervals checks on generic vregs
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 13 15:22:18 PDT 2022
arsenm created this revision.
arsenm added reviewers: qcolombet, MatzeB.
Herald added a subscriber: hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
If llvm-reduce is going to unconditionally verify functions with
LiveIntervals, it needs to be tolerant of generic vregs.
https://reviews.llvm.org/D133813
Files:
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/lib/CodeGen/MachineVerifier.cpp
Index: llvm/lib/CodeGen/MachineVerifier.cpp
===================================================================
--- llvm/lib/CodeGen/MachineVerifier.cpp
+++ llvm/lib/CodeGen/MachineVerifier.cpp
@@ -3256,26 +3256,28 @@
assert(Register::isVirtualRegister(Reg));
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);
+ }
}
}
Index: llvm/include/llvm/CodeGen/MachineRegisterInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -214,7 +214,8 @@
}
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133813.459896.patch
Type: text/x-patch
Size: 2491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220913/6c42a5d7/attachment.bin>
More information about the llvm-commits
mailing list