[PATCH] D36114: [AsmPrinterDwarf] Add support for .cfi_restore directive

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 14:59:23 PDT 2017


thegameg created this revision.

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.


https://reviews.llvm.org/D36114

Files:
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  lib/MC/MCAsmStreamer.cpp


Index: lib/MC/MCAsmStreamer.cpp
===================================================================
--- lib/MC/MCAsmStreamer.cpp
+++ lib/MC/MCAsmStreamer.cpp
@@ -256,6 +256,7 @@
   void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) override;
   void EmitCFIRememberState() override;
   void EmitCFIRestoreState() override;
+  void EmitCFIRestore(int64_t Register) override;
   void EmitCFISameValue(int64_t Register) override;
   void EmitCFIRelOffset(int64_t Register, int64_t Offset) override;
   void EmitCFIAdjustCfaOffset(int64_t Adjustment) override;
@@ -1353,6 +1354,13 @@
   EmitEOL();
 }
 
+void MCAsmStreamer::EmitCFIRestore(int64_t Register) {
+  MCStreamer::EmitCFIRestore(Register);
+  OS << "\t.cfi_restore ";
+  EmitRegisterName(Register);
+  EmitEOL();
+}
+
 void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
   MCStreamer::EmitCFISameValue(Register);
   OS << "\t.cfi_same_value ";
Index: lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -212,6 +212,9 @@
   case MCCFIInstruction::OpEscape:
     OutStreamer->EmitCFIEscape(Inst.getValues());
     break;
+  case MCCFIInstruction::OpRestore:
+    OutStreamer->EmitCFIRestore(Inst.getRegister());
+    break;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36114.109005.patch
Type: text/x-patch
Size: 1356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/eda39834/attachment.bin>


More information about the llvm-commits mailing list