This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinterDwarf] Add support for .cfi_restore directive
ClosedPublic

Authored by thegameg on Jul 31 2017, 2:59 PM.

Details

Summary

As of today we only use .cfi_offset to specify the offset of a CSR, but we never use .cfi_restore when the CSR is restored.

If we want to perform a more advanced type of shrink-wrapping, we need to use .cfi_restore in order to switch the CFI state between blocks.

This patch only aims at adding support for the directive.

Diff Detail

Event Timeline

thegameg created this revision.Jul 31 2017, 2:59 PM
aprantl edited edge metadata.Jul 31 2017, 3:02 PM

Do you have a testcase for this?

thegameg updated this revision to Diff 109023.Jul 31 2017, 4:05 PM
  • Add MIR support (printing and parsing).
  • Add MIR test.
  • Update and rename CodeGen test.
  • Add MC test.
probinson added inline comments.
lib/CodeGen/MIRPrinter.cpp
1214

I didn't see a test for this bit here.

test/CodeGen/AArch64/cfi_restore.mir
5

Using CHECK-LABEL would seem to be unnecessary.
If it is necessary, using it with such a short name and no punctuation or other context is prone to matching something you didn't expect.

test/CodeGen/MIR/AArch64/cfi.mir
23

CHECK-LABEL: name: trivial_fp_func

39

CHECK-LABEL: name: trivial_fp_func_restore

test/MC/AArch64/cfi.s
5

Remove unnecessary CHECK-LABEL

thegameg updated this revision to Diff 109154.Aug 1 2017, 10:38 AM
thegameg marked an inline comment as done.

Add / remove CHECK-LABELs.

thegameg marked 4 inline comments as done.Aug 1 2017, 11:11 AM
thegameg added inline comments.
lib/CodeGen/MIRPrinter.cpp
1214

The MIRParser doesn't attach any symbols to the MCCFIInstructions it creates (lib/CodeGen/MIRParser/MIParser.cpp:MIParser::parseCFIOperand, and since we don't emit any .cfi_restore directives yet, I can't add a test for this.

probinson accepted this revision.Aug 2 2017, 7:38 AM

I'm happy with the test changes and the code looks straightforward enough. LGTM.

This revision is now accepted and ready to land.Aug 2 2017, 7:38 AM
This revision was automatically updated to reflect the committed changes.
test/CodeGen/AArch64/cfi_restore.mir