When X86FrameLowering::emitEpilogue() looks for where to insert the %esp restore to deallocate stack space for local allocations, it assumes that any sequence of pop instructions that starts from function exit consists purely of restoring callee-save registers.
This may be false, since from some point backward, the pops may be popping arguments, recently pushed to a preceded function call.
This caused a miscompile that was exposed by D12609, and is not easily testable since D12609 was not committed yet.. A test will be committed as part of D12609.
The solution is to introduce "FrameUnsetup" flag (similar to "FrameSetup"), which will be attached to all instructions in the epilogue code. This solution is inspired from r242395.