[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp

Jim Laskey jlaskey at apple.com
Wed Feb 28 10:38:48 PST 2007



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.128 -> 1.129
---
Log message:

Handle mix of personalities.

---
Diffs of the changes:  (+37 -30)

 DwarfWriter.cpp |   67 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 37 insertions(+), 30 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.128 llvm/lib/CodeGen/DwarfWriter.cpp:1.129
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.128	Thu Feb 22 12:48:52 2007
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Feb 28 12:38:31 2007
@@ -22,6 +22,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/DataTypes.h"
@@ -2667,13 +2668,21 @@
   /// shouldEmit - Flag to indicate if debug information should be emitted.
   ///
   bool shouldEmit;
+  
+  /// FuncCPPPersonality - C++ persoanlity function.
+  ///
+  Function *FuncCPPPersonality;
 
-  /// EmitInitial - Emit the common eh unwind frame.
+  /// EmitCommonEHFrame - Emit the common eh unwind frame.
   ///
-  void EmitInitial() {
+  void EmitCommonEHFrame() {
+    // Only do it once.
+    if (didInitial) return;
+    didInitial = true;
+    
     // If there is a personality present then we need to indicate that
     // in the common eh frame.
-    Function *Personality = MMI->getPersonality();
+    Function *Personality = FuncCPPPersonality;
 
     // Size and sign of stack growth.
     int stackGrowth =
@@ -2755,7 +2764,8 @@
   void EmitEHFrame() {
     // If there is a personality present then we need to indicate that
     // in the common eh frame.
-    Function *Personality = MMI->getPersonality();
+    Function *Personality = FuncCPPPersonality;
+//    Function *Personality = MMI->getPersonality();
     MachineFrameInfo *MFI = MF->getFrameInfo();
 
     Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection());
@@ -2787,12 +2797,19 @@
                      "eh_func_begin", SubprogramCount);
       Asm->EOL("FDE address range");
       
-      // If there is a personality then point to the language specific data
-      // area in the exception table.
+      // If there is a personality and landing pads then point to the language
+      // specific data area in the exception table.
       if (Personality) {
         Asm->EmitULEB128Bytes(4);
         Asm->EOL("Augmentation size");
-        EmitReference("exception", SubprogramCount, true);
+        
+        if (!MMI->getLandingPads().empty()) {
+          EmitReference("exception", SubprogramCount, true);
+        } else if(TAI->getAddressSize() == 8) {
+          Asm->EmitInt64((int)0);
+        } else {
+          Asm->EmitInt32((int)0);
+        }
         Asm->EOL("Language Specific Data Area");
       } else {
         Asm->EmitULEB128Bytes(0);
@@ -2975,41 +2992,27 @@
   : Dwarf(OS, A, T)
   , didInitial(false)
   , shouldEmit(false)
+  , FuncCPPPersonality(NULL)
   {}
   
   virtual ~DwarfException() {}
 
-  /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
-  ///
-  bool ShouldEmitDwarf() const { return shouldEmit; }
-
   /// SetModuleInfo - Set machine module information when it's known that pass
   /// manager has created it.  Set by the target AsmPrinter.
   void SetModuleInfo(MachineModuleInfo *mmi) {
-    // Make sure initial declarations are made.
-    if (!MMI &&
-        ExceptionHandling &&
-        TAI->getSupportsExceptionHandling() &&
-        mmi->getPersonality()) {
-      MMI = mmi;
-      shouldEmit = true;
-      
-      EmitInitial();
-    }
+    MMI = mmi;
   }
 
   /// BeginModule - Emit all exception information that should come prior to the
   /// content.
   void BeginModule(Module *M) {
     this->M = M;
-    
-    if (!ShouldEmitDwarf()) return;
+    FuncCPPPersonality = M->getFunction("__gxx_personality_v0");
   }
 
   /// EndModule - Emit all exception information that should come after the
   /// content.
   void EndModule() {
-    if (!ShouldEmitDwarf()) return;
   }
 
   /// BeginFunction - Gather pre-function exception information.  Assumes being 
@@ -3017,19 +3020,23 @@
   void BeginFunction(MachineFunction *MF) {
     this->MF = MF;
     
-    if (!ShouldEmitDwarf()) return;
-    
-    // Assumes in correct section after the entry point.
-    EmitLabel("eh_func_begin", ++SubprogramCount);
+    if (MMI &&
+        ExceptionHandling &&
+        TAI->getSupportsExceptionHandling()) {
+      shouldEmit = true;
+      // Assumes in correct section after the entry point.
+      EmitLabel("eh_func_begin", ++SubprogramCount);
+    }
   }
 
   /// EndFunction - Gather and emit post-function exception information.
   ///
   void EndFunction() {
-    if (!ShouldEmitDwarf()) return;
+    if (!shouldEmit) return;
 
     EmitLabel("eh_func_end", SubprogramCount);
     EmitExceptionTable();
+    EmitCommonEHFrame();
     EmitEHFrame();
   }
 };
@@ -3376,7 +3383,7 @@
   DD->EndFunction();
   DE->EndFunction();
   
-  if (MachineModuleInfo *MMI = DD->getMMI()) {
+  if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI()) {
     // Clear function debug information.
     MMI->EndFunction();
   }






More information about the llvm-commits mailing list