Index: lib/Target/X86/X86FrameLowering.cpp =================================================================== --- lib/Target/X86/X86FrameLowering.cpp +++ lib/Target/X86/X86FrameLowering.cpp @@ -1850,6 +1850,9 @@ bool X86FrameLowering::adjustStackWithPops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, DebugLoc DL, int Offset) const { + if (Offset <= 0) + return false; + if (Offset % SlotSize) return false; @@ -1870,9 +1873,11 @@ unsigned FoundRegs = 0; auto RegMask = Prev->getOperand(1); - - // Try to find up to NumPops free registers. - for (auto Candidate : X86::GR32_NOREX_NOSPRegClass) { + + auto &RegClass = + Is64Bit ? X86::GR64_NOREX_NOSPRegClass : X86::GR32_NOREX_NOSPRegClass; + // Try to find up to NumPops free registers. + for (auto Candidate : RegClass) { // Poor man's liveness: // Since we're immediately after a call, any register that is clobbered