Convert DwarfWriter into a pass.
Now Users request DwarfWriter through getAnalysisUsage() instead of creating an instance of DwarfWriter object directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61955 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 16d1531..6293590 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -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.