NaCl's sandbox doesn't allow PUSHF/POPF out of security concerns (priviledged emulators have forgotten to mask system bits in the past, and EFLAGS's DF bit is a constant source of hilarity). Commit r220529 fixed PR20376 by saving cmpxchg's flags result using EFLAGS, this commit now generated LAHF/SAHF instead, for all of x86 (not just NaCl) because it leads to an overall performance gain over PUSHF/POPF.
As with the previous patch this code generation is pretty bad because it occurs very later, after register allocation, and in many cases it rematerializes flags which were already available (e.g. already in a register through SETE). Fortunately it's somewhat rare that this code needs to fire.
I did a bit of benchmarking, the results on an Intel Haswell E5-2690 CPU at 2.9GHz are:
|Time per call (ms)||Runtime (ms)||Benchmark|
Clearly PUSHF/POPF are suboptimal. It doesn't really seems to be worth teaching LLVM about individual flags, at least not for this purpose.