The problem and testcase is described in https://llvm.org/bugs/show_bug.cgi?id=26374.
The cause of the problem is:
LiveRangeEdit::eliminateDeadDef is used to remove dead define instructions after rematerialization. To remove a VNI for a vreg from its LiveInterval, LiveIntervals::removeVRegDefAt is used. However, after non-PHI VNIs are all removed, PHI VNI are still left in the LiveInterval. Such unused vregs will be kept in RegsToSpill at the end of InlineSpiller::reMaterializeAll and spiller will allocate stackslot for them.
The fix is to get rid of unused reg by checking whether it has non-dbg reference instead of whether it has non-empty interval.
For the 1.c testcase in PR26374, the stack allocated for function GetSkipCostMB dropped from 408 to 344.