[llvm] [RISCV][WIP] Let RA do the CSR saves. (PR #90819)
Mikhail Gudim via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 02:23:49 PST 2024
================
@@ -1164,6 +1170,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
void PEI::insertPrologEpilogCode(MachineFunction &MF) {
const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
+ TFI.emitCFIsForCSRsHandledByRA(MF, RDA);
----------------
mgudim wrote:
suppose we had the following code (before block layout is finalized):
```
ENTRY:
save x1
.cfi_offset x1, ...
...
beq ... %RET
BB:
...
RET:
ld x1, ...
.cfi_register x1, x1
...
ret
```
after the block layout the code may look like this (now `%RET` is layout successor of `%ENTRY`):
```
ENTRY:
save x1
.cfi_offset x1, ...
...
bne ... %BB
RET:
ld x1, ...
.cfi_register x1, x1
BB:
...
j %RET
...
ret
```
The cfi directives apply to all the code below it in the layout, so the cfi's are wrong now. The CFIInserter compares the CFI info from the layout successor to what it has to be and corrects it if necessary.
I basically copied that pass from the existing one `CodeGen/ CFIInstrInserter.cpp` and modified it.
https://github.com/llvm/llvm-project/pull/90819
More information about the llvm-commits
mailing list