From 14a55d952cf238fff42da53a75f39cf06dab184b Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 19 Jun 2009 21:54:26 +0000 Subject: [PATCH] Move up dwarf writer initialization in common AsmPrinter class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73784 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 14 +++++++--- lib/Target/ARM/ARMTargetAsmInfo.cpp | 2 ++ lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 6 ----- .../CellSPU/AsmPrinter/SPUAsmPrinter.cpp | 6 +---- .../PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 16 ------------ .../X86/AsmPrinter/X86ATTAsmPrinter.cpp | 26 +++++-------------- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h | 3 +-- lib/Target/XCore/XCoreAsmPrinter.cpp | 6 +---- lib/Target/XCore/XCoreTargetAsmInfo.cpp | 1 + 9 files changed, 24 insertions(+), 56 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 28f3b9b1bf6..e9319046234 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -177,9 +177,17 @@ bool AsmPrinter::doInitialization(Module &M) { SwitchToDataSection(""); // Reset back to no section. - MachineModuleInfo *MMI = getAnalysisIfAvailable(); - if (MMI) MMI->AnalyzeModule(M); - DW = getAnalysisIfAvailable(); + if (TAI->doesSupportDebugInformation() + || TAI->doesSupportExceptionHandling()) { + MachineModuleInfo *MMI = getAnalysisIfAvailable(); + if (MMI) { + MMI->AnalyzeModule(M); + DW = getAnalysisIfAvailable(); + if (DW) + DW->BeginModule(&M, MMI, O, this, TAI); + } + } + return false; } diff --git a/lib/Target/ARM/ARMTargetAsmInfo.cpp b/lib/Target/ARM/ARMTargetAsmInfo.cpp index 4777fdc7084..42b8eae5e05 100644 --- a/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -52,6 +52,7 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): SetDirective = "\t.set\t"; ProtectedDirective = NULL; HasDotTypeDotSizeDirective = false; + SupportsDebugInformation = true; } ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): @@ -85,6 +86,7 @@ ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits"; StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits"; } + SupportsDebugInformation = true; } /// Count the number of comma-separated arguments. diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 258a2ff7773..03759af7f06 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -828,13 +828,7 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) { bool ARMAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); // Thumb-2 instructions are supported only in unified assembler syntax mode. if (Subtarget->hasThumb2()) diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp index 504b465eb3f..c008eb78eb7 100644 --- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp +++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp @@ -490,12 +490,8 @@ LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) bool LinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - SwitchToTextSection("\t.text"); - // Emit initial debug information. DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - MMI = getAnalysisIfAvailable(); - DW->BeginModule(&M, MMI, O, this, TAI); + SwitchToTextSection("\t.text"); return Result; } diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index f04310ca04a..08ae3bf943b 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -646,16 +646,8 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool PPCLinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "DwarfWriter is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); - SwitchToSection(TAI->getTextSection()); - return Result; } @@ -872,15 +864,7 @@ bool PPCDarwinAsmPrinter::doInitialization(Module &M) { O << "\t.machine " << CPUDirectives[Directive] << '\n'; bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - // We need this for Personality functions. - // AsmPrinter::doInitialization should have done this analysis. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "DwarfWriter is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 927267bc17b..f5e3831ff33 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -780,19 +780,7 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) { /// doInitialization bool X86ATTAsmPrinter::doInitialization(Module &M) { - - bool Result = AsmPrinter::doInitialization(M); - - if (TAI->doesSupportDebugInformation()) { - // Let PassManager know we need debug information and relay - // the MachineModuleInfo address on to DwarfWriter. - // AsmPrinter::doInitialization did this analysis. - MMI = getAnalysisIfAvailable(); - DW = getAnalysisIfAvailable(); - DW->BeginModule(&M, MMI, O, this, TAI); - } - - return Result; + return AsmPrinter::doInitialization(M); } @@ -1046,8 +1034,8 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { } // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); // Funny Darwin hack: This flag tells the linker that no global symbols // contain code that falls through to other global symbols (e.g. the obvious @@ -1066,12 +1054,12 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { } // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); } else if (Subtarget->isTargetELF()) { // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); } return AsmPrinter::doFinalization(M); diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h index f7e602b5da8..9dd2938e835 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h @@ -30,14 +30,13 @@ class MachineJumpTableInfo; class MCInst; class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { - DwarfWriter *DW; MachineModuleInfo *MMI; const X86Subtarget *Subtarget; public: explicit X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM, const TargetAsmInfo *T, CodeGenOpt::Level OL, bool V) - : AsmPrinter(O, TM, T, OL, V), DW(0), MMI(0) { + : AsmPrinter(O, TM, T, OL, V), MMI(0) { Subtarget = &TM.getSubtarget(); } diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp index c9a6d8afd31..ed4c1018432 100644 --- a/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -428,6 +428,7 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) { bool XCoreAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); + DW = getAnalysisIfAvailable(); if (!FileDirective.empty()) { emitFileDirective(FileDirective); @@ -449,11 +450,6 @@ bool XCoreAsmPrinter::doInitialization(Module &M) { } } - // Emit initial debug information. - DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - DW->BeginModule(&M, getAnalysisIfAvailable(), - O, this, TAI); return Result; } diff --git a/lib/Target/XCore/XCoreTargetAsmInfo.cpp b/lib/Target/XCore/XCoreTargetAsmInfo.cpp index fe985d2d3be..59ad624052a 100644 --- a/lib/Target/XCore/XCoreTargetAsmInfo.cpp +++ b/lib/Target/XCore/XCoreTargetAsmInfo.cpp @@ -24,6 +24,7 @@ using namespace llvm; XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM) : ELFTargetAsmInfo(TM), Subtarget(TM.getSubtargetImpl()) { + SupportsDebugInformation = true; TextSection = getUnnamedSection("\t.text", SectionFlags::Code); DataSection = getNamedSection("\t.dp.data", SectionFlags::Writeable | SectionFlags::Small);