When adjusting the Stack Pointer at the end of the function epilogue,
use a callee-saved register, rather than explicitly using R4 which may
not have been saved.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Do you have a test case for the situation where r4 is not saved?
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp | ||
---|---|---|
552 | Please add an assertion to check that ScratchRegister has been set to something. |
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp | ||
---|---|---|
552 | I'll simplify the assert in the branch which adjusts SP using FP. |
Amended on os the asserts to make the test now match what is being set as the scratch register.
I tried to come up with a suitable additional test which didn't involve the code actually saving R4. I do have a C reproducer but it is quite a number of "fuzzed" c code and trying to turn it into a sensible IR/MIR regression test proved problematic. Also I believe that we have sufficient tests in place to ensure that the scratch register we now used is one of the callee saved registers, thus the additional test is not really required.
No additional asserts were needed to be added as all cases where ScratchRegister is used (including in the function emitPrologueEpilogueSPUpdate()) aleady has asserts in place.
Please add an assertion to check that ScratchRegister has been set to something.