[llvm] r214663 - MC: rename Win64EHFrameInfo to WinEH::FrameInfo

Saleem Abdulrasool compnerd at compnerd.org
Sun Aug 3 11:51:18 PDT 2014


Author: compnerd
Date: Sun Aug  3 13:51:17 2014
New Revision: 214663

URL: http://llvm.org/viewvc/llvm-project?rev=214663&view=rev
Log:
MC: rename Win64EHFrameInfo to WinEH::FrameInfo

The frame information stored in this structure is driven by the requirements for
Windows NT unwinding rather than Windows 64 specifically.  As a result, this
type can be shared across multiple architectures (ARM, AXP, MIPS, PPC, SH).
Rename this class in preparation for adding support for supporting unwinding
information for Windows on ARM.

Take the opportunity to constify the members as everything except the
ChainedParent is read-only.  This required some adjustment to the label
handling.

Modified:
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/include/llvm/MC/MCWin64EH.h
    llvm/trunk/include/llvm/MC/MCWinEH.h
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/MC/MCStreamer.cpp
    llvm/trunk/lib/MC/MCWin64EH.cpp

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Sun Aug  3 13:51:17 2014
@@ -181,8 +181,8 @@ class MCStreamer {
 
   MCSymbol *EmitCFICommon();
 
-  std::vector<MCWinFrameInfo *> WinFrameInfos;
-  MCWinFrameInfo *CurrentWinFrameInfo;
+  std::vector<WinEH::FrameInfo *> WinFrameInfos;
+  WinEH::FrameInfo *CurrentWinFrameInfo;
   void EnsureValidWinFrameInfo();
 
   // SymbolOrdering - Tracks an index to represent the order
@@ -204,7 +204,7 @@ protected:
   virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
   virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
 
-  MCWinFrameInfo *getCurrentWinFrameInfo() {
+  WinEH::FrameInfo *getCurrentWinFrameInfo() {
     return CurrentWinFrameInfo;
   }
 
@@ -238,7 +238,7 @@ public:
   }
 
   unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
-  ArrayRef<MCWinFrameInfo *> getWinFrameInfos() const {
+  ArrayRef<WinEH::FrameInfo *> getWinFrameInfos() const {
     return WinFrameInfos;
   }
 

Modified: llvm/trunk/include/llvm/MC/MCWin64EH.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWin64EH.h?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCWin64EH.h (original)
+++ llvm/trunk/include/llvm/MC/MCWin64EH.h Sun Aug  3 13:51:17 2014
@@ -54,25 +54,6 @@ struct Instruction {
 };
 }
 
-  struct MCWinFrameInfo {
-    MCWinFrameInfo()
-      : Begin(nullptr), End(nullptr),ExceptionHandler(nullptr),
-        Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
-        HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
-        ChainedParent(nullptr), Instructions() {}
-    MCSymbol *Begin;
-    MCSymbol *End;
-    const MCSymbol *ExceptionHandler;
-    const MCSymbol *Function;
-    MCSymbol *PrologEnd;
-    MCSymbol *Symbol;
-    bool HandlesUnwind;
-    bool HandlesExceptions;
-    int LastFrameInst;
-    MCWinFrameInfo *ChainedParent;
-    std::vector<WinEH::Instruction> Instructions;
-  };
-
   class MCWin64EHUnwindEmitter {
   public:
     static StringRef GetSectionSuffix(const MCSymbol *func);
@@ -80,7 +61,7 @@ struct Instruction {
     // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
     //
     static void Emit(MCStreamer &streamer);
-    static void EmitUnwindInfo(MCStreamer &streamer, MCWinFrameInfo *info);
+    static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info);
   };
 } // end namespace llvm
 

Modified: llvm/trunk/include/llvm/MC/MCWinEH.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWinEH.h?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCWinEH.h (original)
+++ llvm/trunk/include/llvm/MC/MCWinEH.h Sun Aug  3 13:51:17 2014
@@ -10,6 +10,8 @@
 #ifndef LLVM_MC_MCWINEH_H
 #define LLVM_MC_MCWINEH_H
 
+#include <vector>
+
 namespace llvm {
 class MCSymbol;
 
@@ -23,6 +25,39 @@ struct Instruction {
   Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
     : Label(L), Offset(Off), Register(Reg), Operation(Op) {}
 };
+
+struct FrameInfo {
+  const MCSymbol *Begin;
+  const MCSymbol *End;
+  const MCSymbol *ExceptionHandler;
+  const MCSymbol *Function;
+  const MCSymbol *PrologEnd;
+  const MCSymbol *Symbol;
+
+  bool HandlesUnwind;
+  bool HandlesExceptions;
+
+  int LastFrameInst;
+  const FrameInfo *ChainedParent;
+  std::vector<Instruction> Instructions;
+
+  FrameInfo()
+    : Begin(nullptr), End(nullptr), ExceptionHandler(nullptr),
+      Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
+      HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+      ChainedParent(nullptr), Instructions() {}
+  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
+    : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr),
+      Function(Function), PrologEnd(nullptr), Symbol(nullptr),
+      HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+      ChainedParent(nullptr), Instructions() {}
+  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel,
+            const FrameInfo *ChainedParent)
+    : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr),
+      Function(Function), PrologEnd(nullptr), Symbol(nullptr),
+      HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+      ChainedParent(ChainedParent), Instructions() {}
+};
 }
 }
 

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sun Aug  3 13:51:17 2014
@@ -1109,7 +1109,7 @@ void MCAsmStreamer::EmitWinEHHandlerData
   // cause the section switch to be visible in the emitted assembly.
   // We only do this so the section switch that terminates the handler
   // data block is visible.
-  MCWinFrameInfo *CurFrame = getCurrentWinFrameInfo();
+  WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
   StringRef suffix=MCWin64EHUnwindEmitter::GetSectionSuffix(CurFrame->Function);
   const MCSection *xdataSect = getWin64EHTableSection(suffix, getContext());
   if (xdataSect)

Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Sun Aug  3 13:51:17 2014
@@ -429,11 +429,11 @@ void MCStreamer::EnsureValidWinFrameInfo
 void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
   if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
     report_fatal_error("Starting a function before ending the previous one!");
-  MCWinFrameInfo *Frame = new MCWinFrameInfo;
-  Frame->Begin = getContext().CreateTempSymbol();
-  Frame->Function = Symbol;
-  EmitLabel(Frame->Begin);
-  WinFrameInfos.push_back(Frame);
+
+  MCSymbol *StartProc = getContext().CreateTempSymbol();
+  EmitLabel(StartProc);
+
+  WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc));
   CurrentWinFrameInfo = WinFrameInfos.back();
 }
 
@@ -441,18 +441,20 @@ void MCStreamer::EmitWinCFIEndProc() {
   EnsureValidWinFrameInfo();
   if (CurrentWinFrameInfo->ChainedParent)
     report_fatal_error("Not all chained regions terminated!");
-  CurrentWinFrameInfo->End = getContext().CreateTempSymbol();
-  EmitLabel(CurrentWinFrameInfo->End);
+
+  MCSymbol *Label = getContext().CreateTempSymbol();
+  EmitLabel(Label);
+  CurrentWinFrameInfo->End = Label;
 }
 
 void MCStreamer::EmitWinCFIStartChained() {
   EnsureValidWinFrameInfo();
-  MCWinFrameInfo *Frame = new MCWinFrameInfo;
-  Frame->Begin = getContext().CreateTempSymbol();
-  Frame->Function = CurrentWinFrameInfo->Function;
-  Frame->ChainedParent = CurrentWinFrameInfo;
-  EmitLabel(Frame->Begin);
-  WinFrameInfos.push_back(Frame);
+
+  MCSymbol *StartProc = getContext().CreateTempSymbol();
+  EmitLabel(StartProc);
+
+  WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function,
+                                               StartProc, CurrentWinFrameInfo));
   CurrentWinFrameInfo = WinFrameInfos.back();
 }
 
@@ -460,9 +462,13 @@ void MCStreamer::EmitWinCFIEndChained()
   EnsureValidWinFrameInfo();
   if (!CurrentWinFrameInfo->ChainedParent)
     report_fatal_error("End of a chained region outside a chained region!");
-  CurrentWinFrameInfo->End = getContext().CreateTempSymbol();
-  EmitLabel(CurrentWinFrameInfo->End);
-  CurrentWinFrameInfo = CurrentWinFrameInfo->ChainedParent;
+
+  MCSymbol *Label = getContext().CreateTempSymbol();
+  EmitLabel(Label);
+
+  CurrentWinFrameInfo->End = Label;
+  CurrentWinFrameInfo =
+      const_cast<WinEH::FrameInfo *>(CurrentWinFrameInfo->ChainedParent);
 }
 
 void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
@@ -567,8 +573,11 @@ void MCStreamer::EmitWinCFIPushFrame(boo
 
 void MCStreamer::EmitWinCFIEndProlog() {
   EnsureValidWinFrameInfo();
-  CurrentWinFrameInfo->PrologEnd = getContext().CreateTempSymbol();
-  EmitLabel(CurrentWinFrameInfo->PrologEnd);
+
+  MCSymbol *Label = getContext().CreateTempSymbol();
+  EmitLabel(Label);
+
+  CurrentWinFrameInfo->PrologEnd = Label;
 }
 
 void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {

Modified: llvm/trunk/lib/MC/MCWin64EH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCWin64EH.cpp?rev=214663&r1=214662&r2=214663&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCWin64EH.cpp (original)
+++ llvm/trunk/lib/MC/MCWin64EH.cpp Sun Aug  3 13:51:17 2014
@@ -56,7 +56,7 @@ static void EmitAbsDifference(MCStreamer
   Streamer.EmitAbsValue(Diff, 1);
 }
 
-static void EmitUnwindCode(MCStreamer &streamer, MCSymbol *begin,
+static void EmitUnwindCode(MCStreamer &streamer, const MCSymbol *begin,
                            WinEH::Instruction &inst) {
   uint8_t b2;
   uint16_t w;
@@ -136,7 +136,7 @@ static void EmitSymbolRefWithOfs(MCStrea
 }
 
 static void EmitRuntimeFunction(MCStreamer &streamer,
-                                const MCWinFrameInfo *info) {
+                                const WinEH::FrameInfo *info) {
   MCContext &context = streamer.getContext();
 
   streamer.EmitValueToAlignment(4);
@@ -147,14 +147,17 @@ static void EmitRuntimeFunction(MCStream
                                              context), 4);
 }
 
-static void EmitUnwindInfo(MCStreamer &streamer, MCWinFrameInfo *info) {
+static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info) {
   // If this UNWIND_INFO already has a symbol, it's already been emitted.
-  if (info->Symbol) return;
+  if (info->Symbol)
+    return;
 
   MCContext &context = streamer.getContext();
+  MCSymbol *Label = context.CreateTempSymbol();
+
   streamer.EmitValueToAlignment(4);
-  info->Symbol = context.CreateTempSymbol();
-  streamer.EmitLabel(info->Symbol);
+  streamer.EmitLabel(Label);
+  info->Symbol = Label;
 
   // Upper 3 bits are the version number (currently 1).
   uint8_t flags = 0x01;
@@ -256,7 +259,7 @@ static const MCSection *getWin64EHFuncTa
 }
 
 void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
-                                            MCWinFrameInfo *info) {
+                                            WinEH::FrameInfo *info) {
   // Switch sections (the static function above is meant to be called from
   // here and from Emit().
   MCContext &context = streamer.getContext();





More information about the llvm-commits mailing list