AMDGPU: Cleanup checking when spills need emergency slots

Address fixme, which should no longer be a problem since r363757.

llvm-svn: 364182
diff --git a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
index 11d4177..c288024 100644
--- a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
@@ -721,10 +721,13 @@
   }
 }
 
-static bool allStackObjectsAreDead(const MachineFrameInfo &MFI) {
+// Note SGPRSpill stack IDs should only be used for SGPR spilling to VGPRs, not
+// memory.
+static bool allStackObjectsAreDeadOrSGPR(const MachineFrameInfo &MFI) {
   for (int I = MFI.getObjectIndexBegin(), E = MFI.getObjectIndexEnd();
        I != E; ++I) {
-    if (!MFI.isDeadObjectIndex(I))
+    if (!MFI.isDeadObjectIndex(I) &&
+        MFI.getStackID(I) != TargetStackID::SGPRSpill)
       return false;
   }
 
@@ -786,11 +789,7 @@
 
   FuncInfo->removeSGPRToVGPRFrameIndices(MFI);
 
-  // FIXME: The other checks should be redundant with allStackObjectsAreDead,
-  // but currently hasNonSpillStackObjects is set only from source
-  // allocas. Stack temps produced from legalization are not counted currently.
-  if (FuncInfo->hasNonSpillStackObjects() || FuncInfo->hasSpilledVGPRs() ||
-      !AllSGPRSpilledToVGPRs || !allStackObjectsAreDead(MFI)) {
+  if (!allStackObjectsAreDeadOrSGPR(MFI)) {
     assert(RS && "RegScavenger required if spilling");
 
     if (FuncInfo->isEntryFunction()) {