It's a little tricky to make this issue show up because prologue/epilogue emission normally likes to push at least two registers... but it doesn't when lr is force-spilled due to function length. Not sure if that really makes sense, but I decided not to touch it for now.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I don't pretend to know a huge amount about the frame lowering code, but this looks fine to me.
When I tried your example it was pushing r7 and popping r3. I presume this is OK, providing r7 isn't modified?
There are now machine verifier checks for these illegal push/pops, right? Please add -verify-machineinstrs to the tests.
When I tried your example it was pushing r7 and popping r3. I presume this is OK, providing r7 isn't modified?
Yes; the entire point of tryFoldSPUpdateIntoPushPop is to fold a stack adjustment into a preceding push, possibly using the "wrong" register, to save an instruction.
I'll post a new version with the test fixed.
Update test to use -verify-machineinstrs, and to use CHECK-LABEL in a way that's less likely to cause confusion.