This is an archive of the discontinued LLVM Phabricator instance.

RegScavenger: Fix !AllowSpill if no regs are available
AbandonedPublic

Authored by arsenm on Mar 26 2019, 1:47 PM.

Details

Summary

Fixes option added in r354816.

Diff Detail

Event Timeline

arsenm created this revision.Mar 26 2019, 1:47 PM

I would have a slight preference for just:

diff --git a/llvm/lib/CodeGen/RegisterScavenging.cpp b/llvm/lib/CodeGen/RegisterScavenging.cpp
index bb19110e6d70..b9e30c579e65 100644
--- a/llvm/lib/CodeGen/RegisterScavenging.cpp
+++ b/llvm/lib/CodeGen/RegisterScavenging.cpp
@@ -554,6 +554,11 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC,
   if (Available.any())
     Candidates = Available;

+  if (Candidates.none()) {
+    assert(!AllowSpill && "No candidates for scavenging");
+    return 0;
+  }
+
   // Find the register whose use is furthest away.
   MachineBasicBlock::iterator UseMI;
   unsigned SReg = findSurvivorReg(I, Candidates, 25, UseMI);

with maybe a comment on when this can happen.

Also maybe a MIR test with $reg = IMPLICIT_DEF instead of the inline asm would be nicer?

When I rebased the patches, I found I didn't hit this anymore on the testcase. It still looks like this could happen, so I'm going to try to break it again

arsenm abandoned this revision.Nov 18 2022, 5:40 PM

Can't reproduce, although I suspect this is still broken

Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2022, 5:40 PM