[llvm-commits] [llvm] r61955 - in /llvm/trunk: include/llvm/CodeGen/DwarfWriter.h lib/CodeGen/AsmPrinter/DwarfWriter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h lib/Target/XCore/XCoreAsmPrinter.cpp
Devang Patel
dpatel at apple.com
Thu Jan 8 15:40:34 PST 2009
Author: dpatel
Date: Thu Jan 8 17:40:34 2009
New Revision: 61955
URL: http://llvm.org/viewvc/llvm-project?rev=61955&view=rev
Log:
Convert DwarfWriter into a pass.
Now Users request DwarfWriter through getAnalysisUsage() instead of creating an instance of DwarfWriter object directly.
Modified:
llvm/trunk/include/llvm/CodeGen/DwarfWriter.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Thu Jan 8 17:40:34 2009
@@ -20,6 +20,8 @@
#ifndef LLVM_CODEGEN_DWARFWRITER_H
#define LLVM_CODEGEN_DWARFWRITER_H
+#include "llvm/Pass.h"
+
namespace llvm {
class AsmPrinter;
@@ -35,7 +37,7 @@
// DwarfWriter - Emits Dwarf debug and exception handling directives.
//
-class DwarfWriter {
+class DwarfWriter : public ImmutablePass {
private:
/// DD - Provides the DwarfWriter debug implementation.
///
@@ -46,20 +48,19 @@
DwarfException *DE;
public:
- DwarfWriter(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
+ static char ID; // Pass identification, replacement for typeid
+
+ DwarfWriter();
virtual ~DwarfWriter();
- /// SetModuleInfo - Set machine module info when it's known that pass manager
- /// has created it. Set by the target AsmPrinter.
- void SetModuleInfo(MachineModuleInfo *MMI);
-
//===--------------------------------------------------------------------===//
// Main entry points.
//
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// content.
- void BeginModule(Module *M);
+ void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
+ AsmPrinter *A, const TargetAsmInfo *T);
/// EndModule - Emit all Dwarf sections that should come after the content.
///
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Thu Jan 8 17:40:34 2009
@@ -43,6 +43,10 @@
using namespace llvm;
using namespace llvm::dwarf;
+static RegisterPass<DwarfWriter>
+X("dwarfwriter", "DWARF Information Writer");
+char DwarfWriter::ID = 0;
+
namespace llvm {
//===----------------------------------------------------------------------===//
@@ -4897,10 +4901,7 @@
/// DwarfWriter Implementation
///
-DwarfWriter::DwarfWriter(raw_ostream &OS, AsmPrinter *A,
- const TargetAsmInfo *T) {
- DE = new DwarfException(OS, A, T);
- DD = new DwarfDebug(OS, A, T);
+DwarfWriter::DwarfWriter() : ImmutablePass(&ID), DD(NULL), DE(NULL) {
}
DwarfWriter::~DwarfWriter() {
@@ -4908,18 +4909,18 @@
delete DD;
}
-/// SetModuleInfo - Set machine module info when it's known that pass manager
-/// has created it. Set by the target AsmPrinter.
-void DwarfWriter::SetModuleInfo(MachineModuleInfo *MMI) {
- DD->SetModuleInfo(MMI);
- DE->SetModuleInfo(MMI);
-}
-
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// content.
-void DwarfWriter::BeginModule(Module *M) {
+void DwarfWriter::BeginModule(Module *M,
+ MachineModuleInfo *MMI,
+ raw_ostream &OS, AsmPrinter *A,
+ const TargetAsmInfo *T) {
+ DE = new DwarfException(OS, A, T);
+ DD = new DwarfDebug(OS, A, T);
DE->BeginModule(M);
DD->BeginModule(M);
+ DD->SetModuleInfo(MMI);
+ DE->SetModuleInfo(MMI);
}
/// EndModule - Emit all Dwarf sections that should come after the content.
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Thu Jan 8 17:40:34 2009
@@ -44,12 +44,12 @@
namespace {
struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
ARMAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
- : AsmPrinter(O, TM, T), DW(O, this, T), MMI(NULL), AFI(NULL), MCP(NULL),
+ : AsmPrinter(O, TM, T), DW(0), MMI(NULL), AFI(NULL), MCP(NULL),
InCPMode(false) {
Subtarget = &TM.getSubtarget<ARMSubtarget>();
}
- DwarfWriter DW;
+ DwarfWriter *DW;
MachineModuleInfo *MMI;
/// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
@@ -172,6 +172,7 @@
AsmPrinter::getAnalysisUsage(AU);
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
}
};
} // end of anonymous namespace
@@ -231,7 +232,7 @@
O << CurrentFnName << ":\n";
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
if (Subtarget->isTargetDarwin()) {
// If the function is empty, then we need to emit *something*. Otherwise,
@@ -262,7 +263,7 @@
O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
O.flush();
@@ -776,15 +777,15 @@
}
bool ARMAsmPrinter::doInitialization(Module &M) {
- // Emit initial debug information.
- DW.BeginModule(&M);
bool Result = AsmPrinter::doInitialization(M);
- // AsmPrinter::doInitialization should have done this analysis.
+ // Emit initial debug information.
MMI = getAnalysisToUpdate<MachineModuleInfo>();
assert(MMI);
- DW.SetModuleInfo(MMI);
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ assert(DW && "Dwarf Writer is not available");
+ DW->BeginModule(&M, MMI, O, this, TAI);
// Darwin wants symbols to be quoted if they have complex names.
if (Subtarget->isTargetDarwin())
@@ -1012,7 +1013,7 @@
// Emit initial debug information.
- DW.EndModule();
+ 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
@@ -1022,7 +1023,7 @@
O << "\t.subsections_via_symbols\n";
} else {
// Emit final debug information for ELF.
- DW.EndModule();
+ DW->EndModule();
}
return AsmPrinter::doFinalization(M);
Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Thu Jan 8 17:40:34 2009
@@ -288,13 +288,13 @@
/// LinuxAsmPrinter - SPU assembly printer, customized for Linux
struct VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
- DwarfWriter DW;
+ DwarfWriter *DW;
MachineModuleInfo *MMI;
LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM,
const TargetAsmInfo *T) :
SPUAsmPrinter(O, TM, T),
- DW(O, this, T),
+ DW(0),
MMI(0)
{ }
@@ -310,6 +310,7 @@
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
SPUAsmPrinter::getAnalysisUsage(AU);
}
@@ -456,7 +457,7 @@
O << CurrentFnName << ":\n";
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
@@ -479,7 +480,7 @@
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
// We didn't modify anything.
return false;
@@ -490,9 +491,10 @@
bool Result = AsmPrinter::doInitialization(M);
SwitchToTextSection("\t.text");
// Emit initial debug information.
- DW.BeginModule(&M);
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ assert(DW && "Dwarf Writer is not available");
MMI = getAnalysisToUpdate<MachineModuleInfo>();
- DW.SetModuleInfo(MMI);
+ DW->BeginModule(&M, MMI, O, this, TAI);
return Result;
}
@@ -602,7 +604,7 @@
// TODO
// Emit initial debug information.
- DW.EndModule();
+ DW->EndModule();
return AsmPrinter::doFinalization(M);
}
Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Thu Jan 8 17:40:34 2009
@@ -292,13 +292,12 @@
/// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
struct VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
-
- DwarfWriter DW;
+ DwarfWriter *DW;
MachineModuleInfo *MMI;
PPCLinuxAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
const TargetAsmInfo *T)
- : PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
+ : PPCAsmPrinter(O, TM, T), DW(0), MMI(0) {
}
virtual const char *getPassName() const {
@@ -312,6 +311,7 @@
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
PPCAsmPrinter::getAnalysisUsage(AU);
}
@@ -322,12 +322,12 @@
/// OS X
struct VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
- DwarfWriter DW;
+ DwarfWriter *DW;
MachineModuleInfo *MMI;
-
+ raw_ostream &OS;
PPCDarwinAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
const TargetAsmInfo *T)
- : PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
+ : PPCAsmPrinter(O, TM, T), DW(0), MMI(0), OS(O) {
}
virtual const char *getPassName() const {
@@ -341,6 +341,7 @@
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
PPCAsmPrinter::getAnalysisUsage(AU);
}
@@ -602,7 +603,7 @@
O << CurrentFnName << ":\n";
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
@@ -627,7 +628,7 @@
SwitchToSection(TAI->SectionForGlobal(F));
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
O.flush();
@@ -639,12 +640,11 @@
bool Result = AsmPrinter::doInitialization(M);
// Emit initial debug information.
- DW.BeginModule(&M);
-
- // AsmPrinter::doInitialization should have done this analysis.
MMI = getAnalysisToUpdate<MachineModuleInfo>();
assert(MMI);
- DW.SetModuleInfo(MMI);
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ assert(DW && "DwarfWriter is not available");
+ DW->BeginModule(&M, MMI, O, this, TAI);
// GNU as handles section names wrapped in quotes
Mang->setUseQuotes(true);
@@ -753,7 +753,7 @@
// TODO
// Emit initial debug information.
- DW.EndModule();
+ DW->EndModule();
return AsmPrinter::doFinalization(M);
}
@@ -792,7 +792,7 @@
O << CurrentFnName << ":\n";
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// If the function is empty, then we need to emit *something*. Otherwise, the
// function's label might be associated with something that it wasn't meant to
@@ -821,7 +821,7 @@
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
// We didn't modify anything.
return false;
@@ -854,13 +854,13 @@
bool Result = AsmPrinter::doInitialization(M);
// Emit initial debug information.
- DW.BeginModule(&M);
-
// We need this for Personality functions.
// AsmPrinter::doInitialization should have done this analysis.
MMI = getAnalysisToUpdate<MachineModuleInfo>();
assert(MMI);
- DW.SetModuleInfo(MMI);
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ assert(DW && "DwarfWriter is not available");
+ DW->BeginModule(&M, MMI, O, this, TAI);
// Darwin wants symbols to be quoted if they have complex names.
Mang->setUseQuotes(true);
@@ -1122,7 +1122,7 @@
// Emit initial debug information.
- DW.EndModule();
+ 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
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Thu Jan 8 17:40:34 2009
@@ -227,7 +227,7 @@
// Emit pre-function debug and/or EH information.
if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// Print out code for the function.
bool hasAnyRealCode = false;
@@ -260,7 +260,7 @@
// Emit post-function debug information.
if (TAI->doesSupportDebugInformation())
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
// Print out jump tables referenced by the function.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
@@ -726,10 +726,6 @@
/// doInitialization
bool X86ATTAsmPrinter::doInitialization(Module &M) {
- if (TAI->doesSupportDebugInformation()) {
- // Emit initial debug information.
- DW.BeginModule(&M);
- }
bool Result = AsmPrinter::doInitialization(M);
@@ -738,7 +734,8 @@
// the MachineModuleInfo address on to DwarfWriter.
// AsmPrinter::doInitialization did this analysis.
MMI = getAnalysisToUpdate<MachineModuleInfo>();
- DW.SetModuleInfo(MMI);
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ DW->BeginModule(&M, MMI, O, this, TAI);
}
// Darwin wants symbols to be quoted if they have complex names.
@@ -973,7 +970,8 @@
}
// Emit final debug information.
- DW.EndModule();
+ DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>();
+ 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
@@ -992,10 +990,12 @@
}
// Emit final debug information.
- DW.EndModule();
+ DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>();
+ DW->EndModule();
} else if (Subtarget->isTargetELF()) {
// Emit final debug information.
- DW.EndModule();
+ DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>();
+ DW->EndModule();
}
return AsmPrinter::doFinalization(M);
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Thu Jan 8 17:40:34 2009
@@ -29,14 +29,13 @@
struct MachineJumpTableInfo;
struct VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
- DwarfWriter DW;
+ DwarfWriter *DW;
MachineModuleInfo *MMI;
-
const X86Subtarget *Subtarget;
X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
const TargetAsmInfo *T)
- : AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
+ : AsmPrinter(O, TM, T), DW(0), MMI(0) {
Subtarget = &TM.getSubtarget<X86Subtarget>();
}
@@ -51,6 +50,7 @@
Subtarget->isTargetCygMing()) {
AU.addRequired<MachineModuleInfo>();
}
+ AU.addRequired<DwarfWriter>();
AsmPrinter::getAnalysisUsage(AU);
}
Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=61955&r1=61954&r2=61955&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Thu Jan 8 17:40:34 2009
@@ -56,10 +56,10 @@
struct VISIBILITY_HIDDEN XCoreAsmPrinter : public AsmPrinter {
XCoreAsmPrinter(raw_ostream &O, XCoreTargetMachine &TM,
const TargetAsmInfo *T)
- : AsmPrinter(O, TM, T), DW(O, this, T),
+ : AsmPrinter(O, TM, T), DW(0),
Subtarget(*TM.getSubtargetImpl()) { }
- DwarfWriter DW;
+ DwarfWriter *DW;
const XCoreSubtarget &Subtarget;
virtual const char *getPassName() const {
@@ -91,6 +91,7 @@
AsmPrinter::getAnalysisUsage(AU);
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
}
};
} // end of anonymous namespace
@@ -305,7 +306,7 @@
emitFunctionStart(MF);
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
@@ -332,7 +333,7 @@
emitFunctionEnd(MF);
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
// We didn't modify anything.
return false;
@@ -438,9 +439,10 @@
}
// Emit initial debug information.
- DW.BeginModule(&M);
-
- DW.SetModuleInfo(getAnalysisToUpdate<MachineModuleInfo>());
+ DW = getAnalysisToUpdate<DwarfWriter>();
+ assert(DW && "Dwarf Writer is not available");
+ DW->BeginModule(&M, getAnalysisToUpdate<MachineModuleInfo>(),
+ O, this, TAI);
return Result;
}
@@ -453,7 +455,7 @@
}
// Emit final debug information.
- DW.EndModule();
+ DW->EndModule();
return AsmPrinter::doFinalization(M);
}
More information about the llvm-commits
mailing list