Use DwarfWriter to record dbg variables.
authorDevang Patel <dpatel@apple.com>
Tue, 13 Jan 2009 21:44:10 +0000 (21:44 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 13 Jan 2009 21:44:10 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62185 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
include/llvm/CodeGen/DwarfWriter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfWriter.cpp

index 9d7ff15ffcb2df9a65c2543c313bba1a0373a77f..cdc795162579e0043a349d75876e807df7b1edfe 100644 (file)
@@ -32,7 +32,7 @@ namespace llvm {
   class GlobalVariable;
   class MachineConstantPoolEntry;
   class MachineConstantPoolValue;
-  class MachineModuleInfo;
+  class DwarfWriter;
   class Mangler;
   class Section;
   class TargetAsmInfo;
@@ -51,10 +51,10 @@ namespace llvm {
     ///
     unsigned FunctionNumber;
 
-    /// MachineModuleInfo - This is needed because printDeclare() has to insert
-    /// DebugVariable entries into the dwarf table. This is a short term hack
+    /// DW -This is needed because printDeclare() has to insert
+    /// DbgVariable entries into the dwarf table. This is a short term hack
     /// that ought be fixed soon.
-    MachineModuleInfo *MMI;
+    DwarfWriter *DW;
     
     // GCMetadataPrinters - The garbage collection metadata printer table.
     typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type;
index 24b0f97dfcebe5c43db9dfe292fb0af0c6fbd8f9..19601a4d9c955095a77b447624c231be2fa5c174 100644 (file)
@@ -93,6 +93,10 @@ public:
   /// getRecordSourceLineCount - Count source lines.
   unsigned getRecordSourceLineCount();
 
+  /// RecordVariable - Indicate the declaration of  a local variable.
+  ///
+  void RecordVariable(GlobalVariable *GV, unsigned FrameIndex);
+
   /// hasDebugInfo - Return true if debug info intrinsics are seen in 
   /// this module.
   bool hasDebugInfo();
index 47a19dd893528fa107e469de33a5cc341041e0eb..6627543a85695a6bad039330a63fbd6660126e55 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetAsmInfo.h"
@@ -162,9 +163,9 @@ bool AsmPrinter::doInitialization(Module &M) {
 
   SwitchToDataSection("");   // Reset back to no section.
   
-  MMI = getAnalysisToUpdate<MachineModuleInfo>();
+  MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>();
   if (MMI) MMI->AnalyzeModule(M);
-  
+  DW = getAnalysisToUpdate<DwarfWriter>();
   return false;
 }
 
@@ -1419,9 +1420,9 @@ void AsmPrinter::printLabel(unsigned Id) const {
 /// FIXME: It doesn't really print anything rather it inserts a DebugVariable
 /// entry into dwarf table.
 void AsmPrinter::printDeclare(const MachineInstr *MI) const {
-  int FI = MI->getOperand(0).getIndex();
+  unsigned FI = MI->getOperand(0).getIndex();
   GlobalValue *GV = MI->getOperand(1).getGlobal();
-  MMI->RecordVariable(GV, FI);
+  DW->RecordVariable(cast<GlobalVariable>(GV), FI);
 }
 
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
index d79e6aa77831cb3c5fabcb20728a7ee099eaa213..675ae983f70b19c3ce7e5022192e3d15e1d335e9 100644 (file)
@@ -4985,6 +4985,12 @@ unsigned DwarfWriter::getRecordSourceLineCount() {
   return DD->getRecordSourceLineCount();
 }
 
+/// RecordVariable - Indicate the declaration of  a local variable.
+///
+void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
+  DD->RecordVariable(GV, FrameIndex);
+}
+
 /// hasDebugInfo - Return true if debug info intrinsics are seen in 
 /// this module.
 bool DwarfWriter::hasDebugInfo() {