class MachineJumpTableInfo;
class MachineModuleInfo;
class MachineMove;
+ class MCAsmInfo;
class MCInst;
class MCContext;
class MCSection;
class MCStreamer;
class MCSymbol;
- class DwarfWriter;
+ class DwarfDebug;
+ class DwarfException;
class Mangler;
- class MCAsmInfo;
class TargetLoweringObjectFile;
class TargetData;
class Twine;
/// asm writers.
class AsmPrinter : public MachineFunctionPass {
public:
- /// DW - If available, this is a pointer to the current dwarf writer.
- DwarfWriter *DW;
-
/// Target machine description.
///
TargetMachine &TM;
/// If VerboseAsm is set, a pointer to the loop info for this
/// function.
- ///
MachineLoopInfo *LI;
+
+ /// DD - If the target supports dwarf debug info, this pointer is non-null.
+ DwarfDebug *DD;
+
+ /// DE - If the target supports dwarf exception info, this pointer is
+ /// non-null.
+ DwarfException *DE;
protected:
explicit AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
#define DEBUG_TYPE "asm-printer"
#include "llvm/CodeGen/AsmPrinter.h"
+#include "DwarfDebug.h"
+#include "DwarfException.h"
#include "llvm/Module.h"
-#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
OutContext(Streamer.getContext()),
OutStreamer(Streamer),
LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) {
- DW = 0; MMI = 0; LI = 0;
+ DD = 0; DE = 0; MMI = 0; LI = 0;
GCMetadataPrinters = 0;
VerboseAsm = Streamer.isVerboseAsm();
}
AsmPrinter::~AsmPrinter() {
+ assert(DD == 0 && DE == 0 && "Debug/EH info didn't get finalized");
+
if (GCMetadataPrinters != 0) {
gcp_map_type &GCMap = getGCMap(GCMetadataPrinters);
MachineFunctionPass::getAnalysisUsage(AU);
AU.addRequired<MachineModuleInfo>();
AU.addRequired<GCModuleInfo>();
- AU.addRequired<DwarfWriter>();
if (isVerbose())
AU.addRequired<MachineLoopInfo>();
}
OutStreamer.AddBlankLine();
}
- DW = getAnalysisIfAvailable<DwarfWriter>();
- if (DW)
- DW->BeginModule(&M, this);
+ if (MAI->doesSupportDebugInformation())
+ DD = new DwarfDebug(this, &M);
+
+ if (MAI->doesSupportExceptionHandling())
+ DE = new DwarfException(this);
return false;
}
}
// Emit pre-function debug and/or EH information.
- if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
- DW->BeginFunction(MF);
+ if (DE) DE->BeginFunction(MF);
+ if (DD) DD->beginFunction(MF);
}
/// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
// Emit target-specific gunk before the function body.
EmitFunctionBodyStart();
- bool ShouldPrintDebugScopes =
- DW && MAI->doesSupportDebugInformation() &&DW->ShouldEmitDwarfDebug();
+ bool ShouldPrintDebugScopes = DD && MMI->hasDebugInfo();
// Print out code for the function.
bool HasAnyRealCode = false;
++EmittedInsts;
if (ShouldPrintDebugScopes)
- DW->BeginScope(II);
+ DD->beginScope(II);
if (isVerbose())
EmitComments(*II, OutStreamer.GetCommentOS());
}
if (ShouldPrintDebugScopes)
- DW->EndScope(II);
+ DD->endScope(II);
}
}
}
// Emit post-function debug information.
- if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
- DW->EndFunction(MF);
+ if (DD) DD->endFunction(MF);
+ if (DE) DE->EndFunction();
+ MMI->EndFunction();
// Print out jump tables referenced by the function.
EmitJumpTableInfo();
I != E; ++I)
EmitGlobalVariable(I);
- // Emit final debug information.
- if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
- DW->EndModule();
+ // Finalize debug and EH information.
+ if (DE) {
+ DE->EndModule();
+ delete DE; DE = 0;
+ }
+ if (DD) {
+ DD->endModule();
+ delete DD; DD = 0;
+ }
// If the target wants to know about weak references, print them all.
if (MAI->getWeakRefDirective()) {
EmitEndOfAsmFile(M);
delete Mang; Mang = 0;
- DW = 0; MMI = 0;
+ MMI = 0;
OutStreamer.Finish();
return false;
delete Variables[j];
}
-DwarfDebug::DwarfDebug(AsmPrinter *A)
+DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
: Asm(A), MMI(Asm->MMI), ModuleCU(0),
AbbreviationsSet(InitAbbreviationsSetSize),
CurrentFnDbgScope(0), DebugTimer(0) {
if (TimePassesIsEnabled)
DebugTimer = new Timer("Dwarf Debug Writer");
+
+ beginModule(M);
}
DwarfDebug::~DwarfDebug() {
for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j)
/// content. Create global DIEs and emit initial debug info sections.
/// This is inovked by the target AsmPrinter.
void DwarfDebug::beginModule(Module *M) {
- if (!Asm->MAI->doesSupportDebugInformation())
- return;
-
MMI = Asm->MMI;
TimeRegion Timer(DebugTimer);