diff options
author | Devang Patel <dpatel@apple.com> | 2009-01-05 23:21:35 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-01-05 23:21:35 +0000 |
commit | 78eb6ad6333ba19d8f5ece81f8b3ac57e6747dfc (patch) | |
tree | 2747f83cd12e7b749fce4bdf5efa05ffab7c1089 /lib/CodeGen/AsmPrinter/DwarfWriter.cpp | |
parent | c452324f60561bdc1a3f90b8f7d085beb9487f36 (diff) |
Construct subprogram DIEs using DebugInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfWriter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 026671436c..a2543f9f55 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -3214,6 +3214,45 @@ private: } } + /// ConstructSubprograms - Create DIEs for each of the externally visible + /// subprograms. + void ConstructSubprograms() { + + std::string SPName = "llvm.dbg.subprograms"; + std::vector<GlobalVariable*> Result; + getGlobalVariablesUsing(*M, SPName, Result); + for (std::vector<GlobalVariable *>::iterator RI = Result.begin(), + RE = Result.end(); RI != RE; ++RI) { + + DISubprogram *SP = new DISubprogram(*RI); + CompileUnit *Unit = FindCompileUnit(SP->getCompileUnit()); + + // Check for pre-existence. + DIE *&Slot = Unit->getDieMapSlotFor(SP->getGV()); + if (Slot) continue; + + DIE *SubprogramDie = new DIE(DW_TAG_subprogram); + AddString(SubprogramDie, DW_AT_name, DW_FORM_string, SP->getName()); + const std::string &LinkageName = SP->getLinkageName(); + if (!LinkageName.empty()) + AddString(SubprogramDie, DW_AT_MIPS_linkage_name, DW_FORM_string, + LinkageName); + DIType SPTy = SP->getType(); + AddType(Unit, SubprogramDie, SPTy); + if (!SP->isLocalToUnit()) + AddUInt(SubprogramDie, DW_AT_external, DW_FORM_flag, 1); + AddUInt(SubprogramDie, DW_AT_prototyped, DW_FORM_flag, 1); + + AddSourceLine(SubprogramDie, SP); + //Add to map. + Slot = SubprogramDie; + //Add to context owner. + Unit->getDie()->AddChild(SubprogramDie); + //Expose as global. + Unit->AddGlobal(SP->getName(), SubprogramDie); + } + } + /// ConstructSubprogramDIEs - Create DIEs for each of the externally visible /// subprograms. void ConstructSubprogramDIEs() { |