[PATCH] D52679: Cache LSDA label for future use (NFC)

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 18:04:22 PDT 2018


aheejin created this revision.
aheejin added reviewers: rnk, majnemer.
Herald added subscribers: llvm-commits, sunfish.
aheejin added a comment.

I couldn't add `setLSDALabel` to `emitCLRExceptionTable` <https://github.com/llvm-mirror/llvm/blob/993ef0ca960f8ffd107c33bfbf1fd603bcf5c66c/lib/CodeGen/AsmPrinter/WinException.cpp#L1063>, because it is unclear which symbol is the per-function LSDA symbol.


This adds `setLSDALabel` and `getLSDALabel` to `EHStreamer`, to cache
per-function LSDA starting label for future use. Currently no EH schemes
need this, but wasm EH scheme needs to this in a follow-up patch, and
because this LSDA label is emitted in a target-independent part of code,
it is not easy to make it as a wasm-only function.


Repository:
  rL LLVM

https://reviews.llvm.org/D52679

Files:
  lib/CodeGen/AsmPrinter/EHStreamer.cpp
  lib/CodeGen/AsmPrinter/EHStreamer.h
  lib/CodeGen/AsmPrinter/WinException.cpp


Index: lib/CodeGen/AsmPrinter/WinException.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/WinException.cpp
+++ lib/CodeGen/AsmPrinter/WinException.cpp
@@ -544,6 +544,7 @@
   // difference and division.
   MCSymbol *TableBegin =
       Ctx.createTempSymbol("lsda_begin", /*AlwaysAddSuffix=*/true);
+  setLSDALabel(TableBegin);
   MCSymbol *TableEnd =
       Ctx.createTempSymbol("lsda_end", /*AlwaysAddSuffix=*/true);
   const MCExpr *LabelDiff = getOffset(TableEnd, TableBegin);
@@ -645,6 +646,7 @@
   } else {
     FuncInfoXData = Asm->OutContext.getOrCreateLSDASymbol(FuncLinkageName);
   }
+  setLSDALabel(FuncInfoXData);
 
   int UnwindHelpOffset = 0;
   if (Asm->MAI->usesWindowsCFI())
@@ -952,6 +954,7 @@
 
   // Emit the __ehtable label that we use for llvm.x86.seh.lsda.
   MCSymbol *LSDALabel = Asm->OutContext.getOrCreateLSDASymbol(FLinkageName);
+  setLSDALabel(LSDALabel);
   OS.EmitValueToAlignment(4);
   OS.EmitLabel(LSDALabel);
 
Index: lib/CodeGen/AsmPrinter/EHStreamer.h
===================================================================
--- lib/CodeGen/AsmPrinter/EHStreamer.h
+++ lib/CodeGen/AsmPrinter/EHStreamer.h
@@ -36,6 +36,9 @@
   /// Collected machine module information.
   MachineModuleInfo *MMI;
 
+  // Starting symbol of an per-function exception table.
+  MCSymbol *LSDALabel = nullptr;
+
   /// How many leading type ids two landing pads have in common.
   static unsigned sharedTypeIDs(const LandingPadInfo *L,
                                 const LandingPadInfo *R);
@@ -119,6 +122,10 @@
   static bool isCleanupEHSelector(int Selector) { return Selector == 0; }
   static bool isCatchEHSelector(int Selector) { return Selector > 0; }
 
+  // Set and get the starting symbol of an per-function exception table.
+  void setLSDALabel(MCSymbol *Sym) { LSDALabel = Sym; }
+  MCSymbol *getLSDALabel() { return LSDALabel; }
+
 public:
   EHStreamer(AsmPrinter *A);
   ~EHStreamer() override;
Index: lib/CodeGen/AsmPrinter/EHStreamer.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -428,6 +428,7 @@
   MCSymbol *GCCETSym =
     Asm->OutContext.getOrCreateSymbol(Twine("GCC_except_table")+
                                       Twine(Asm->getFunctionNumber()));
+  setLSDALabel(GCCETSym);
   Asm->OutStreamer->EmitLabel(GCCETSym);
   Asm->OutStreamer->EmitLabel(Asm->getCurExceptionSym());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52679.167574.patch
Type: text/x-patch
Size: 2487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180929/03276038/attachment.bin>


More information about the llvm-commits mailing list