[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h DwarfWriter.h MachineDebugInfo.h SelectionDAG.h

Jim Laskey jlaskey at apple.com
Wed Jan 4 14:28:38 PST 2006



Changes in directory llvm/include/llvm/CodeGen:

AsmPrinter.h updated: 1.24 -> 1.25
DwarfWriter.h updated: 1.4 -> 1.5
MachineDebugInfo.h updated: 1.3 -> 1.4
SelectionDAG.h updated: 1.82 -> 1.83
---
Log message:

Applied some recommend changes from sabre.  The dominate one beginning "let the
pass manager do it's thing."  Fixes crash when compiling -g files and suppresses
dwarf statements if no debug info is present.


---
Diffs of the changes:  (+88 -112)

 AsmPrinter.h       |   45 ++------------------
 DwarfWriter.h      |  119 ++++++++++++++++++++++++++++-------------------------
 MachineDebugInfo.h |   30 +++++--------
 SelectionDAG.h     |    6 ++
 4 files changed, 88 insertions(+), 112 deletions(-)


Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.24 llvm/include/llvm/CodeGen/AsmPrinter.h:1.25
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.24	Wed Jan  4 07:52:30 2006
+++ llvm/include/llvm/CodeGen/AsmPrinter.h	Wed Jan  4 16:28:25 2006
@@ -36,7 +36,7 @@
     ///
     unsigned FunctionNumber;
 
-  protected:
+  public:
     /// Output stream on which we're printing assembly code.
     ///
     std::ostream &O;
@@ -162,7 +162,8 @@
     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
     /// directives, this is true for most ELF targets.
     bool HasDotTypeDotSizeDirective;     // Defaults to true.
-
+  
+  protected:
     AsmPrinter(std::ostream &o, TargetMachine &TM);
     
   public:
@@ -194,7 +195,7 @@
     /// doFinalization - Shut down the asmprinter.  If you override this in your
     /// pass, you must make sure to call it explicitly.
     bool doFinalization(Module &M);
-
+    
     /// SetupMachineFunction - This should be called when a new MachineFunction
     /// is being processed from runOnMachineFunction.
     void SetupMachineFunction(MachineFunction &MF);
@@ -231,43 +232,7 @@
     
   private:
     void EmitXXStructorList(Constant *List);
-    
-  public:
-    /// getCommentString - get the comment string.
-    ///
-    const char *getCommentString() {
-      return CommentString;
-    }
-    
-    /// getData8bitsDirective - get the 8-bit data directive string.
-    ///
-    const char *getData8bitsDirective() {
-      return Data8bitsDirective;
-    }
-    
-    /// getData16bitsDirective - get the 16-bit data directive string.
-    ///
-    const char *getData16bitsDirective() {
-      return Data16bitsDirective;
-    }
-    
-    /// getData32bitsDirective - get the 32-bit data directive string.
-    ///
-    const char *getData32bitsDirective() {
-      return Data32bitsDirective;
-    }
-    
-    /// getData64bitsDirective - get the 64-bit data directive string.
-    ///
-    const char *getData64bitsDirective() {
-      return Data64bitsDirective;
-    }
-    
-    /// getPrivateGlobalPrefix - get private label prefix.
-    ///
-    const char *getPrivateGlobalPrefix() {
-      return PrivateGlobalPrefix;
-    }
+
   };
 }
 


Index: llvm/include/llvm/CodeGen/DwarfWriter.h
diff -u llvm/include/llvm/CodeGen/DwarfWriter.h:1.4 llvm/include/llvm/CodeGen/DwarfWriter.h:1.5
--- llvm/include/llvm/CodeGen/DwarfWriter.h:1.4	Wed Jan  4 07:52:30 2006
+++ llvm/include/llvm/CodeGen/DwarfWriter.h	Wed Jan  4 16:28:25 2006
@@ -14,8 +14,7 @@
 #ifndef LLVM_CODEGEN_DWARFPRINTER_H
 #define LLVM_CODEGEN_DWARFPRINTER_H
 
-#include <iostream>
-#include "llvm/CodeGen/MachineDebugInfo.h"
+#include <iosfwd>
 
 namespace llvm {
 
@@ -429,6 +428,7 @@
   // Forward declarations.
   //
   class AsmPrinter;
+  class MachineDebugInfo;
   
   //===--------------------------------------------------------------------===//
   // DwarfWriter - emits dwarf debug and exception handling directives.
@@ -447,12 +447,28 @@
     
     /// DebugInfo - Collected debug information.
     ///
-    MachineDebugInfo &DebugInfo;
+    MachineDebugInfo *DebugInfo;
     
+    /// didInitial - Flag to indicate if initial emission has been done.
+    ///
+    bool didInitial;
+    
+    //===------------------------------------------------------------------===//
+    // Properties to be set by the derived class ctor, used to configure the
+    // dwarf writer.
+
     /// hasLEB128 - True if target asm supports leb128 directives.
     ///
     bool hasLEB128; /// Defaults to false.
     
+    /// hasDotLoc - True if target asm supports .loc directives.
+    ///
+    bool hasDotLoc; /// Defaults to false.
+    
+    /// hasDotFile - True if target asm supports .file directives.
+    ///
+    bool hasDotFile; /// Defaults to false.
+    
     /// needsSet - True if target asm can't compute addresses on data
     /// directives.
     bool needsSet; /// Defaults to false.
@@ -469,94 +485,89 @@
     ///
     const char *DwarfLineSection; /// Defaults to ".debug_line".
 
+    //===------------------------------------------------------------------===//
+
   public:
     
     // Ctor.
-    DwarfWriter(std::ostream &o, AsmPrinter *ap, MachineDebugInfo &di)
+    DwarfWriter(std::ostream &o, AsmPrinter *ap)
     : O(o)
     , Asm(ap)
-    , DebugInfo(di)
+    , DebugInfo(NULL)
+    , didInitial(false)
     , hasLEB128(false)
+    , hasDotLoc(false)
+    , hasDotFile(false)
     , needsSet(false)
     , DwarfAbbrevSection(".debug_abbrev")
     , DwarfInfoSection(".debug_info")
     , DwarfLineSection(".debug_line")
     {}
     
+    /// SetDebugInfo - Set DebugInfo at when it's know that pass manager
+    /// has created it.
+    void SetDebugInfo(MachineDebugInfo *di) { DebugInfo = di; }
+    
     /// EmitHex - Emit a hexidecimal string to the output stream.
     ///
-    void EmitHex(unsigned Value) {
-      O << "0x"
-        << std::hex
-        << Value
-        << std::dec;
-    }
+    void EmitHex(unsigned Value) const;
     
     /// EmitComment - Emit a simple string comment.
     ///
-    void EmitComment(const char *Comment) {
-      O << "\t"
-        << Asm->getCommentString()
-        << " "
-        << Comment
-        << "\n";
-    }
+    void EmitComment(const char *Comment) const;
 
     /// EmitULEB128 - Emit a series of hexidecimal values (separated by commas)
     /// representing an unsigned leb128 value.
     ///
-    void EmitULEB128(unsigned Value) {
-      do {
-        unsigned Byte = Value & 0x7f;
-        Value >>= 7;
-        if (Value) Byte |= 0x80;
-        EmitHex(Byte);
-        if (Value) O << ", ";
-      } while (Value);
-    }
+    void EmitULEB128(unsigned Value) const;
 
     /// EmitSLEB128 - Emit a series of hexidecimal values (separated by commas)
     /// representing a signed leb128 value.
     ///
-    void EmitSLEB128(int Value) {
-      int Sign = Value >> (8 * sizeof(Value) - 1);
-      bool IsMore;
-      
-      do {
-        unsigned Byte = Value & 0x7f;
-        Value >>= 7;
-        IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
-        if (IsMore) Byte |= 0x80;
-        EmitHex(Byte);
-        if (IsMore) O << ", ";
-      } while (IsMore);
-    }
+    void EmitSLEB128(int Value) const;
     
     /// EmitLabelName - Emit label name for internal use by dwarf.
     ///
-    void EmitLabelName(const char *Tag, int Num) {
-      O << Asm->getPrivateGlobalPrefix()
-        << "debug_"
-        << Tag
-        << Num;
-    }
+    void EmitLabelName(const char *Tag, int Num) const;
     
     /// EmitLabel - Emit location label for internal use by dwarf.
     ///
-    void EmitLabel(const char *Tag, int Num) {
-      EmitLabelName(Tag, Num);
-      O << ":\n";
-    }
+    void EmitLabel(const char *Tag, int Num) const;
     
-    // Defined elsewhere
-
-    void EmitULEB128Bytes(unsigned Value, std::string Comment);
-    void EmitSLEB128Bytes(int Value, std::string Comment);
+    /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
+    /// unsigned leb128 value.  Comment is added to the end of the directive if
+    /// DwarfVerbose is true (should not contain any newlines.)
+    ///
+    void EmitULEB128Bytes(unsigned Value, const char *Comment) const;
+    
+    /// EmitSLEB128Bytes - Emit an assembler byte data directive to compose a
+    /// signed leb128 value.  Comment is added to the end of the directive if
+    /// DwarfVerbose is true (should not contain any newlines.)
+    ///
+    void EmitSLEB128Bytes(int Value, const char *Comment) const;
+    
+    /// EmitInitial - Emit initial dwarf declarations.
+    ///
+    void EmitInitial() const;
+    
+    /// ShouldEmitDwarf - Determine if dwarf declarations should be made.
+    ///
+    bool ShouldEmitDwarf();
 
+    /// BeginModule - Emit all dwarf sections that should come prior to the
+    /// content.
     void BeginModule();
+    
+    /// EndModule - Emit all dwarf sections that should come after the content.
+    ///
     void EndModule();
     
+    /// BeginFunction - Emit pre-function debug information.
+    ///
     void BeginFunction();
+    
+    /// EndFunction - Emit post-function debug information.
+    ///
     void EndFunction();
   };
   


Index: llvm/include/llvm/CodeGen/MachineDebugInfo.h
diff -u llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.3 llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.4
--- llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.3	Wed Jan  4 08:29:26 2006
+++ llvm/include/llvm/CodeGen/MachineDebugInfo.h	Wed Jan  4 16:28:25 2006
@@ -28,11 +28,7 @@
 ///
 class MachineDebugInfo : public ImmutablePass {
 private:
-  // convenience types
-  typedef std::map<std::string, unsigned> StrIntMap;
-  typedef StrIntMap::iterator StrIntMapIter;
-  
-  StrIntMap SourceMap;                  // Map of source file path to id
+  std::map<std::string, unsigned> SourceMap; // Map of source file path to id
   unsigned SourceCount;                 // Number of source files (used to
                                         // generate id)
   unsigned UniqueID;                    // Number used to unique labels used
@@ -50,25 +46,25 @@
   /// hasInfo - Returns true if debug info is present.
   ///
   // FIXME - need scheme to suppress debug output.
-  bool hasInfo() { return true; }
+  bool hasInfo() const { return SourceCount != 0; }
   
-  /// NextUniqueID - Returns a unique number for labels used by debugger.
+  /// getNextUniqueID - Returns a unique number for labels used by debugger.
   ///
-  unsigned NextUniqueID() { return UniqueID++; }
+  unsigned getNextUniqueID() { return UniqueID++; }
   
   bool doInitialization();
   bool doFinalization();
-  unsigned RecordSource(std::string fname, std::string dirname);
-  std::vector<std::string> getSourceFiles();
+  
+  /// getUniqueSourceID - Register a source file with debug info. Returns an id.
+  ///
+  unsigned getUniqueSourceID(const std::string &fname, 
+                             const std::string &dirname);
+  
+  /// getSourceFiles - Return a vector of files.  Vector index + 1 equals id.
+  ///
+  std::vector<std::string> getSourceFiles() const;
   
 }; // End class MachineDebugInfo
-//===----------------------------------------------------------------------===//
-
-// FIXME - temporary hack until we can find a place to hang debug info from.
-MachineDebugInfo &getMachineDebugInfo();
-
-// FIXME - temporary hack until we can find a place to hand debug info from.
-ModulePass *createDebugInfoPass();
 
 } // End llvm namespace
 


Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.82 llvm/include/llvm/CodeGen/SelectionDAG.h:1.83
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.82	Thu Dec 22 15:16:35 2005
+++ llvm/include/llvm/CodeGen/SelectionDAG.h	Wed Jan  4 16:28:25 2006
@@ -25,6 +25,7 @@
 namespace llvm {
   class TargetLowering;
   class TargetMachine;
+  class MachineDebugInfo;
   class MachineFunction;
 
 /// SelectionDAG class - This is used to represent a portion of an LLVM function
@@ -41,6 +42,7 @@
 class SelectionDAG {
   TargetLowering &TLI;
   MachineFunction &MF;
+  MachineDebugInfo *DI;
 
   // Root - The root of the entire DAG.  EntryNode - The starting token.
   SDOperand Root, EntryNode;
@@ -52,7 +54,8 @@
   std::map<std::pair<const Value*, int>, SDNode*> ValueNodes;
 
 public:
-  SelectionDAG(TargetLowering &tli, MachineFunction &mf) : TLI(tli), MF(mf) {
+  SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineDebugInfo *di)
+  : TLI(tli), MF(mf), DI(di) {
     EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
   }
   ~SelectionDAG();
@@ -60,6 +63,7 @@
   MachineFunction &getMachineFunction() const { return MF; }
   const TargetMachine &getTarget() const;
   TargetLowering &getTargetLoweringInfo() const { return TLI; }
+  MachineDebugInfo *getMachineDebugInfo() const { return DI; }
 
   /// viewGraph - Pop up a ghostview window with the DAG rendered using 'dot'.
   ///






More information about the llvm-commits mailing list