fastisel doesn't need DwarfWriter, remove some tendricles.
authorChris Lattner <sabre@nondot.org>
Mon, 5 Apr 2010 02:19:28 +0000 (02:19 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 5 Apr 2010 02:19:28 +0000 (02:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100381 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/FastISel.h
include/llvm/CodeGen/SelectionDAGISel.h
include/llvm/Target/TargetLowering.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/DwarfWriter.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/Target/X86/X86FastISel.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h

index 9d0f0d9e57b91d2c72d3a3d26e6232e734807760..487031c1990a41994e15bac58c2b1cc1071c91fe 100644 (file)
@@ -28,7 +28,6 @@ class MachineConstantPool;
 class MachineFunction;
 class MachineFrameInfo;
 class MachineModuleInfo;
-class DwarfWriter;
 class MachineRegisterInfo;
 class TargetData;
 class TargetInstrInfo;
@@ -51,7 +50,6 @@ protected:
 #endif
   MachineFunction &MF;
   MachineModuleInfo *MMI;
-  DwarfWriter *DW;
   MachineRegisterInfo &MRI;
   MachineFrameInfo &MFI;
   MachineConstantPool &MCP;
@@ -117,7 +115,6 @@ public:
 protected:
   FastISel(MachineFunction &mf,
            MachineModuleInfo *mmi,
-           DwarfWriter *dw,
            DenseMap<const Value *, unsigned> &vm,
            DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,
            DenseMap<const AllocaInst *, int> &am
index def09c76fcbec9dacea3c4a873466c91a00eab35..a7ce7aa08705f04a7e34c374234c61f483c56d26 100644 (file)
@@ -30,7 +30,6 @@ namespace llvm {
   class MachineFunction;
   class MachineInstr;
   class MachineModuleInfo;
-  class DwarfWriter;
   class TargetLowering;
   class TargetInstrInfo;
   class FunctionLoweringInfo;
@@ -285,7 +284,6 @@ private:
   
   void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
                             MachineModuleInfo *MMI,
-                            DwarfWriter *DW,
                             const TargetInstrInfo &TII);
   void FinishBasicBlock();
 
index 874f840d194e60c67d9cb74c7edc1188a72840ee..862a8bad3daa19235a69576d3bfd06a7f1915233 100644 (file)
@@ -50,7 +50,6 @@ namespace llvm {
   class MachineModuleInfo;
   class MCContext;
   class MCExpr;
-  class DwarfWriter;
   class SDNode;
   class SDValue;
   class SelectionDAG;
@@ -1273,8 +1272,7 @@ public:
   /// createFastISel - This method returns a target specific FastISel object,
   /// or null if the target does not support "fast" ISel.
   virtual FastISel *
-  createFastISel(MachineFunction &,
-                 MachineModuleInfo *, DwarfWriter *,
+  createFastISel(MachineFunction &, MachineModuleInfo *,
                  DenseMap<const Value *, unsigned> &,
                  DenseMap<const BasicBlock *, MachineBasicBlock *> &,
                  DenseMap<const AllocaInst *, int> &
index 539eba0133f388be5ee2954936ef58cf578696cb..3d86bf6fc91302414d95cb68f03ac8ccf1be32fb 100644 (file)
@@ -1793,24 +1793,39 @@ void DwarfDebug::constructSubprogramDIE(MDNode *N) {
 void DwarfDebug::beginModule(Module *M) {
   if (!Asm->MAI->doesSupportDebugInformation())
     return;
+  
+  MMI = Asm->MMI;
 
   TimeRegion Timer(DebugTimer);
-  
+
   DebugInfoFinder DbgFinder;
   DbgFinder.processModule(*M);
 
+  bool HasDebugInfo = false;
+  
+  // Scan all the compile-units to see if there are any marked as the main unit.
+  // if not, we do not generate debug info.
+  for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
+       E = DbgFinder.compile_unit_end(); I != E; ++I) {
+    if (DICompileUnit(*I).isMain()) {
+      HasDebugInfo = true;
+      break;
+    }
+  }
+  
+  if (!HasDebugInfo) return;
+
+  // Tell MMI that we have debug info.
+  MMI->setDebugInfoAvailability(true);
+  
   // Emit initial sections.
-  if (DbgFinder.compile_unit_begin() != DbgFinder.compile_unit_end())
-    EmitSectionLabels();
+  EmitSectionLabels();
   
   // Create all the compile unit DIEs.
   for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
          E = DbgFinder.compile_unit_end(); I != E; ++I)
     constructCompileUnit(*I);
 
-  if (!ModuleCU)
-    return;
-  
   // Create DIEs for each subprogram.
   for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
          E = DbgFinder.subprogram_end(); I != E; ++I)
@@ -1821,10 +1836,6 @@ void DwarfDebug::beginModule(Module *M) {
          E = DbgFinder.global_variable_end(); I != E; ++I)
     constructGlobalVariableDIE(*I);
 
-  MMI = Asm->MMI;
-  shouldEmit = true;
-  MMI->setDebugInfoAvailability(true);
-
   // Prime section data.
   SectionMap.insert(Asm->getObjFileLowering().getTextSection());
 
index 320691b0592e2726948e473f16b901aa783b84eb..b38e485117a02a34ac00e60535e13eaf84fcf5c5 100644 (file)
@@ -60,8 +60,10 @@ public:
 class DwarfDebug {
   /// Asm - Target of Dwarf emission.
   AsmPrinter *Asm;
+public:
   /// MMI - Collected machine module information.
   MachineModuleInfo *MMI;
+private:
 
   //===--------------------------------------------------------------------===//
   // Attributes used to construct specific Dwarf sections.
index 1b019cd294aa6b73491a57cfcd177397611ea601..acc0066937ea6e4a3794fb4803b48d48984e6ebb 100644 (file)
@@ -72,7 +72,7 @@ void DwarfWriter::EndFunction(const MachineFunction *MF) {
 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
 /// be emitted.
 bool DwarfWriter::ShouldEmitDwarfDebug() const {
-  return DD && DD->ShouldEmitDwarfDebug();
+  return DD && DD->MMI->hasDebugInfo();
 }
 
 void DwarfWriter::BeginScope(const MachineInstr *MI) {
index d6f8a205c1f676d4dc027112df1d61dcb2b90a63..fdb3b5c3ad8456ff1b37a2411fb25fe9373cf22b 100644 (file)
@@ -47,7 +47,6 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/Analysis/DebugInfo.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetInstrInfo.h"
@@ -326,8 +325,8 @@ bool FastISel::SelectCall(User *I) {
   default: break;
   case Intrinsic::dbg_declare: {
     DbgDeclareInst *DI = cast<DbgDeclareInst>(I);
-    if (!DIDescriptor::ValidDebugInfo(DI->getVariable(), CodeGenOpt::None)||!DW
-        || !DW->ShouldEmitDwarfDebug())
+    if (!DIDescriptor::ValidDebugInfo(DI->getVariable(), CodeGenOpt::None) ||
+        !MMI->hasDebugInfo())
       return true;
 
     Value *Address = DI->getAddress();
@@ -735,7 +734,6 @@ FastISel::SelectOperator(User *I, unsigned Opcode) {
 
 FastISel::FastISel(MachineFunction &mf,
                    MachineModuleInfo *mmi,
-                   DwarfWriter *dw,
                    DenseMap<const Value *, unsigned> &vm,
                    DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,
                    DenseMap<const AllocaInst *, int> &am
@@ -752,7 +750,6 @@ FastISel::FastISel(MachineFunction &mf,
 #endif
     MF(mf),
     MMI(mmi),
-    DW(dw),
     MRI(MF.getRegInfo()),
     MFI(*MF.getFrameInfo()),
     MCP(*MF.getConstantPool()),
index d54566b8cd3a7bca5b0150bb68b738fdb69482dc..69ff94b28c989b61b30f8dd1f1d26a013db98a87 100644 (file)
@@ -342,7 +342,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
       // Mark landing pad.
       FuncInfo->MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad();
 
-  SelectAllBasicBlocks(Fn, *MF, MMI, DW, TII);
+  SelectAllBasicBlocks(Fn, *MF, MMI, TII);
 
   // If the first basic block in the function has live ins that need to be
   // copied into vregs, emit the copies into the top of the block before
@@ -845,12 +845,11 @@ void SelectionDAGISel::DoInstructionSelection() {
 void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
                                             MachineFunction &MF,
                                             MachineModuleInfo *MMI,
-                                            DwarfWriter *DW,
                                             const TargetInstrInfo &TII) {
   // Initialize the Fast-ISel state, if needed.
   FastISel *FastIS = 0;
   if (EnableFastISel)
-    FastIS = TLI.createFastISel(MF, MMI, DW,
+    FastIS = TLI.createFastISel(MF, MMI,
                                 FuncInfo->ValueMap,
                                 FuncInfo->MBBMap,
                                 FuncInfo->StaticAllocaMap
index c69eeb3e9006c3c69fe9930444f11d709eac833a..536c64f80700cb8ccfae5ccda127574aa24b3a67 100644 (file)
@@ -55,7 +55,6 @@ class X86FastISel : public FastISel {
 public:
   explicit X86FastISel(MachineFunction &mf,
                        MachineModuleInfo *mmi,
-                       DwarfWriter *dw,
                        DenseMap<const Value *, unsigned> &vm,
                        DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,
                        DenseMap<const AllocaInst *, int> &am
@@ -63,7 +62,7 @@ public:
                        , SmallSet<Instruction*, 8> &cil
 #endif
                        )
-    : FastISel(mf, mmi, dw, vm, bm, am
+    : FastISel(mf, mmi, vm, bm, am
 #ifndef NDEBUG
                , cil
 #endif
@@ -1754,7 +1753,6 @@ unsigned X86FastISel::TargetMaterializeAlloca(AllocaInst *C) {
 namespace llvm {
   llvm::FastISel *X86::createFastISel(MachineFunction &mf,
                         MachineModuleInfo *mmi,
-                        DwarfWriter *dw,
                         DenseMap<const Value *, unsigned> &vm,
                         DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,
                         DenseMap<const AllocaInst *, int> &am
@@ -1762,7 +1760,7 @@ namespace llvm {
                         , SmallSet<Instruction*, 8> &cil
 #endif
                         ) {
-    return new X86FastISel(mf, mmi, dw, vm, bm, am
+    return new X86FastISel(mf, mmi, vm, bm, am
 #ifndef NDEBUG
                            , cil
 #endif
index 3eaf64d1de4c0b1456ebb522abd27354e4288d2b..7ac6628236f476e25bfeb7690b29a92b2c76b1c6 100644 (file)
@@ -2399,7 +2399,6 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
 
 FastISel *
 X86TargetLowering::createFastISel(MachineFunction &mf, MachineModuleInfo *mmo,
-                            DwarfWriter *dw,
                             DenseMap<const Value *, unsigned> &vm,
                             DenseMap<const BasicBlock*, MachineBasicBlock*> &bm,
                             DenseMap<const AllocaInst *, int> &am
@@ -2407,7 +2406,7 @@ X86TargetLowering::createFastISel(MachineFunction &mf, MachineModuleInfo *mmo,
                           , SmallSet<Instruction*, 8> &cil
 #endif
                                   ) {
-  return X86::createFastISel(mf, mmo, dw, vm, bm, am
+  return X86::createFastISel(mf, mmo, vm, bm, am
 #ifndef NDEBUG
                              , cil
 #endif
index 9547f1927dc317623ff64c185cf0499a7bdd7830..85099015b9c301ea9abf84891fe57811d5a5362f 100644 (file)
@@ -574,8 +574,7 @@ namespace llvm {
     /// createFastISel - This method returns a target specific FastISel object,
     /// or null if the target does not support "fast" ISel.
     virtual FastISel *
-    createFastISel(MachineFunction &mf,
-                   MachineModuleInfo *mmi, DwarfWriter *dw,
+    createFastISel(MachineFunction &mf, MachineModuleInfo *mmi,
                    DenseMap<const Value *, unsigned> &,
                    DenseMap<const BasicBlock *, MachineBasicBlock *> &,
                    DenseMap<const AllocaInst *, int> &
@@ -816,7 +815,7 @@ namespace llvm {
 
   namespace X86 {
     FastISel *createFastISel(MachineFunction &mf,
-                           MachineModuleInfo *mmi, DwarfWriter *dw,
+                           MachineModuleInfo *mmi,
                            DenseMap<const Value *, unsigned> &,
                            DenseMap<const BasicBlock *, MachineBasicBlock *> &,
                            DenseMap<const AllocaInst *, int> &