This reorganizes comments slightly (to make the key difference between two big blocks more obvious), and adds some clarifying asserts. This is motivated by me trying to wrap my head around the code enough to usefully review D125787
Details
Diff Detail
Event Timeline
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
718 | The whole point of getFrameRegister is to avoid hard-coding, and this would be a pain for us downstream in CHERI LLVM where pure-capability code uses capability register C8 not the X8 integer sub-register. I mean, I'd just delete the assert downstream rather than repeat the condition... so don't like this assert. |
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
718 | Would having a RISCVABI::getFPReg() and using that in the assert make life easier for you? It would still give me the property I want to assert (e.g. we are using FP if hasFP is true), but maybe be a bit easier to merge? |
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
718 | We already have getFP/SPReg functions in this file that take the subtarget. Using those for this would be fine by me. |
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
718 | I also don't like this assertion and IMO we need to avoid this trivial assertion. I call it a trivial assertion since getFrameRegister would return the frame register according to the result of hasFP, this assertion would always succeed unless the compiler generates the wrong code. | |
719 | Does if present means if the BP exists? But If both realignment and VarSize objects exist, then BP must be present. |
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
718 | Unless you can point me to a comment that says that's the document semantics of getFrameRegister, I disagree this is a trivial assert. Going even further, it's not clear to me that the getFrameRegister actually even implements the contract its supposed to. Per the header comment in TargetRegisterInfo.h, it seems this should be returning BP in the cases that's the register we index off. However, that's *definitely* a separate patch. | |
719 | Please see the code immediately below this. If you have a suggestion on the comment wording, feel free to suggest something. |
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
696 | We generally prefer consistency between if and else. The else block requires the bracket. |
Rebase, and drop frame register asserts. I'll move those into a separate commit, but they're slowing down the more useful part of the patch.
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
696 | Makes sense to me. |
Remove the curly bracket?