A handler for a function in the Win64 EH scheme can be both an unwind handler
authorCharles Davis <cdavis@mines.edu>
Sat, 21 May 2011 15:57:49 +0000 (15:57 +0000)
committerCharles Davis <cdavis@mines.edu>
Sat, 21 May 2011 15:57:49 +0000 (15:57 +0000)
and an exception handler. Handle that case.

Also, add an 'Emitted' member to the MCWin64EHUnwindInfo struct. It will be
needed later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131791 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCWin64EH.h
lib/MC/MCStreamer.cpp

index de1e24767a1515d7d8470510f43e9eb8f17e21b5..a88b5040b8bfb80a50f70f140da6b8d8b4e2ae26 100644 (file)
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file contains the declaration of the MCDwarfFile to support the dwarf
-// .file directive and the .loc directive.
+// This file contains declarations to support the Win64 Exception Handling
+// scheme in MC.
 //
 //===----------------------------------------------------------------------===//
 
@@ -59,26 +59,29 @@ namespace llvm {
 
   struct MCWin64EHUnwindInfo {
     MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0),
-                            Function(0), PrologEnd(0), UnwindOnly(false),
-                            LastFrameInst(-1), ChainedParent(0),
-                            Instructions() {}
+                            Function(0), PrologEnd(0), HandlesUnwind(false),
+                            HandlesExceptions(false), LastFrameInst(-1),
+                            ChainedParent(0), Instructions(), Emitted(false) {}
     MCSymbol *Begin;
     MCSymbol *End;
     const MCSymbol *ExceptionHandler;
     const MCSymbol *Function;
     MCSymbol *PrologEnd;
-    bool UnwindOnly;
+    bool HandlesUnwind;
+    bool HandlesExceptions;
     int LastFrameInst;
     MCWin64EHUnwindInfo *ChainedParent;
     std::vector<MCWin64EHInstruction> Instructions;
+    bool Emitted;
   };
 
   class MCWin64EHUnwindEmitter {
   public:
     //
-    // This emits the unwind info section (.xdata in PE/COFF).
+    // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
     //
     static void Emit(MCStreamer &streamer);
+    static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info);
   };
 } // end namespace llvm
 
index ab7c798198a4e28bf16c13d233f263e0b9d565d5..1ec7688a5ed8b04e30f99f0620b09b057ba79f73 100644 (file)
@@ -362,10 +362,12 @@ void MCStreamer::EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
   EnsureValidW64UnwindInfo();
   MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
   CurFrame->ExceptionHandler = Sym;
-  if (Unwind)
-    CurFrame->UnwindOnly = true;
-  else if (!Except)
+  if (!Except && !Unwind)
     report_fatal_error("Don't know what kind of handler this is!");
+  if (Unwind)
+    CurFrame->HandlesUnwind = true;
+  if (Except)
+    CurFrame->HandlesExceptions = true;
 }
 
 void MCStreamer::EmitWin64EHHandlerData() {