]> granicus.if.org Git - llvm/commitdiff
Move the EH symbol to the asm printer and use it for the SJLJ case too.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Mar 2015 13:57:48 +0000 (13:57 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Mar 2015 13:57:48 +0000 (13:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232475 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/ARMException.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
lib/CodeGen/AsmPrinter/EHStreamer.cpp
lib/CodeGen/AsmPrinter/EHStreamer.h
lib/CodeGen/AsmPrinter/Win64Exception.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
test/CodeGen/ARM/2009-08-31-LSDA-Name.ll

index 382f91f8f07e1dea85c49eb00386a8b32df653c5..dd20fdd748f9184f836ca4ebd2d6146a3d3ebb32 100644 (file)
@@ -108,6 +108,7 @@ public:
 private:
   MCSymbol *CurrentFnBegin;
   MCSymbol *CurrentFnEnd;
+  MCSymbol *CurExceptionSym;
 
   // The garbage collection metadata printer table.
   void *GCMetadataPrinters; // Really a DenseMap.
@@ -154,6 +155,7 @@ public:
 
   MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
   MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
+  MCSymbol *getCurExceptionSym();
 
   /// Return information about object file lowering.
   const TargetLoweringObjectFile &getObjFileLowering() const;
index 034e34a95732f35fefdeaa3b5ff4dae166f2fa17..9a16e15ecf774f5f9ae5be6b4cb1dd801a970698 100644 (file)
@@ -53,8 +53,6 @@ void ARMException::endModule() {
 }
 
 void ARMException::beginFunction(const MachineFunction *MF) {
-  DwarfCFIExceptionBase::beginFunction(MF);
-
   if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM)
     getTargetStreamer().emitFnStart();
   // See if we need call frame info.
index b2919f2301e3b9c41153d7542ab8d647eec86c2a..5b4a5cc644de3faf2cfe174dfb2b79b811d1b61c 100644 (file)
@@ -108,7 +108,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
   MMI = nullptr;
   LI = nullptr;
   MF = nullptr;
-  CurrentFnSym = CurrentFnSymForSize = nullptr;
+  CurExceptionSym = CurrentFnSym = CurrentFnSymForSize = nullptr;
   CurrentFnBegin = nullptr;
   CurrentFnEnd = nullptr;
   GCMetadataPrinters = nullptr;
@@ -1129,12 +1129,19 @@ bool AsmPrinter::doFinalization(Module &M) {
   return false;
 }
 
+MCSymbol *AsmPrinter::getCurExceptionSym() {
+  if (!CurExceptionSym)
+    CurExceptionSym = createTempSymbol("exception", getFunctionNumber());
+  return CurExceptionSym;
+}
+
 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
   this->MF = &MF;
   // Get the function symbol.
   CurrentFnSym = getSymbol(MF.getFunction());
   CurrentFnSymForSize = CurrentFnSym;
   CurrentFnBegin = nullptr;
+  CurExceptionSym = nullptr;
   bool NeedsLocalForSize = MAI->needsLocalForSize();
   if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
       NeedsLocalForSize) {
index 5263a2afd0f406e221207fbc97799baa64048d5d..1bee367996dd9cf2a9a67be1aff393cbcc29f35f 100644 (file)
@@ -88,8 +88,6 @@ void DwarfCFIException::endModule() {
 }
 
 void DwarfCFIException::beginFunction(const MachineFunction *MF) {
-  DwarfCFIExceptionBase::beginFunction(MF);
-
   shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
 
   // If any landing pads survive, we need an EH table.
@@ -133,7 +131,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
   if (!shouldEmitLSDA)
     return;
 
-  Asm->OutStreamer.EmitCFILsda(getCurExceptionSym(), LSDAEncoding);
+  Asm->OutStreamer.EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding);
 }
 
 /// endFunction - Gather and emit post-function exception information.
index 8a040d92aeebc8c7239e4deb2e79405328c25438..14df4c916252088181ed00e7ecb56a45e73bd784 100644 (file)
 
 using namespace llvm;
 
-EHStreamer::EHStreamer(AsmPrinter *A)
-    : CurExceptionSym(nullptr), Asm(A), MMI(Asm->MMI) {}
+EHStreamer::EHStreamer(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {}
 
 EHStreamer::~EHStreamer() {}
 
-MCSymbol *EHStreamer::getCurExceptionSym() {
-  if (!CurExceptionSym)
-    CurExceptionSym = Asm->OutContext.createTempSymbol(
-        "exception" + Twine(Asm->getFunctionNumber()));
-  return CurExceptionSym;
-}
-
-void EHStreamer::beginFunction(const MachineFunction *MF) {
-  CurExceptionSym = nullptr;
-}
-
 /// How many leading type ids two landing pads have in common.
 unsigned EHStreamer::sharedTypeIDs(const LandingPadInfo *L,
                                    const LandingPadInfo *R) {
@@ -448,11 +436,7 @@ void EHStreamer::emitExceptionTable() {
     Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
                                       Twine(Asm->getFunctionNumber()));
   Asm->OutStreamer.EmitLabel(GCCETSym);
-  Asm->OutStreamer.EmitLabel(getCurExceptionSym());
-
-  if (IsSJLJ)
-    Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
-                                                  Asm->getFunctionNumber()));
+  Asm->OutStreamer.EmitLabel(Asm->getCurExceptionSym());
 
   // Emit the LSDA header.
   Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
index 8cb7a31a1addb4c0e914a216f6232a321c03f501..94d0585347e862c5e50a3eb0f5e9a1870d04eebe 100644 (file)
@@ -31,8 +31,6 @@ class SmallVectorImpl;
 
 /// Emits exception handling directives.
 class EHStreamer : public AsmPrinterHandler {
-  MCSymbol *CurExceptionSym;
-
 protected:
   /// Target of directive emission.
   AsmPrinter *Asm;
@@ -127,9 +125,6 @@ public:
   EHStreamer(AsmPrinter *A);
   virtual ~EHStreamer();
 
-  MCSymbol *getCurExceptionSym();
-  void beginFunction(const MachineFunction *MF) override;
-
   // Unused.
   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
   void beginInstruction(const MachineInstr *MI) override {}
index abf16f79a427834902c00e4548e7d57f4dcfc646..7d76eaddb5653944e03896d8ebcc0fb8a2090399 100644 (file)
@@ -49,8 +49,6 @@ void Win64Exception::endModule() {
 }
 
 void Win64Exception::beginFunction(const MachineFunction *MF) {
-  EHStreamer::beginFunction(MF);
-
   shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
 
   // If any landing pads survive, we need an EH table.
index 2544a01fa7f8e214dfb108bd4f61eb971e2d7d25..2c9f32b23fb611f6920614cc80176cfca4040677 100644 (file)
@@ -960,10 +960,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
 
   MCSymbol *MCSym;
   if (ACPV->isLSDA()) {
-    SmallString<128> Str;
-    raw_svector_ostream OS(Str);
-    OS << DL->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
-    MCSym = OutContext.GetOrCreateSymbol(OS.str());
+    MCSym = getCurExceptionSym();
   } else if (ACPV->isBlockAddress()) {
     const BlockAddress *BA =
       cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
index d6babb6c55dca3d069487531fe917dedbc0753c6..2f6e428351d75058eb4f1a7a1598549ab487ab87 100644 (file)
@@ -1,7 +1,9 @@
 ; RUN: llc < %s -mtriple=arm-apple-darwin9 -march=arm | FileCheck %s
 
-; CHECK: L_LSDA_0:
-
+; CHECK: .cfi_lsda 16, [[LABEL:.*]]
+; CHECK: .long  [[LABEL]]-
+; CHECK: [[LABEL]]:
+; CHECK: .byte   255                     @ @LPStart Encoding = omit
 
 %struct.A = type { i32* }