In order to generate correct debug frame information, it needs to generate CFI information in prologue and epilog.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi Kai,
Other codegen test cases will generate .cfi directive with the patch. So other codegen test cases may need to update.
Better to modify the tests to add nounwind. I have a patch that does that sitting around (I added CFI directives downstream but didn't clean it up for submission). Let me apply the test suite patch upstream, then can you rebase on that.
Hi @HsiangKai - it seems I applied an old/wip version of my nounwind patch upstream. I've now fixed that in rL361493. With that, there should be no test changes when implementing this feature.
Please take a look at the two minor suggestions I had on updating frame-info.ll.
test/CodeGen/RISCV/frame-info.ll | ||
---|---|---|
1 ↗ | (On Diff #199958) | For completeness, please add a riscv64 RUN line too. |
2 ↗ | (On Diff #199958) | I think it would be worth generating this with update_llc_test_checks.py. Then you can also see the generated instructions in the CHECK lines which makes it easy to check that the cfi directives match up to the generated stack layout. |
lib/Target/RISCV/RISCVFrameLowering.cpp | ||
---|---|---|
125 ↗ | (On Diff #199958) | It should be ".cfi_def_cfa_offset StackSize". This directive is put after "addi sp, sp, -StackSize". CFA should be a fixed point. So, after updating stack pointer to lower address, we should update CFA as current stack pointer plus StackSize. |
Hi Kai,
We could also generate .cfi_restore for epilogue by:
unsigned CFIIndex = MF->addFrameInst(MCCFIInstruction::createRestore( nullptr, MRI->getDwarfRegNum(Reg, 1))); BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex);
I'm happy this is a big improvement over what we have (which is no CFI directive emission :)), so please go ahead and commit this. Thanks!