The root cause of the problem in bz24500 is that the x86 call frame optimization uses iteration over a DenseMap with pointer keys to determine the order in which calls are optimized. The immediate effect is a non-deterministic ordering in the virtual register use-def lists. Ultimately, the different list order results in different behavior in the register allocator.
The fix is to change the DenseMap structure that is currently used to hold the calls to be optimized into a SmallVector, which serves its purpose equally well or better but provides a deterministic iteration order.