mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-19 19:44:55 +00:00
Refactor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137689 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -574,6 +574,63 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// collectInfoFromNamedMDNodes - Collect debug info from named mdnodes such
|
||||||
|
/// as llvm.dbg.enum and llvm.dbg.ty
|
||||||
|
void DwarfDebug::collectInfoFromNamedMDNodes(Module *M) {
|
||||||
|
if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum"))
|
||||||
|
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||||
|
DIType Ty(NMD->getOperand(i));
|
||||||
|
getCompileUnit(Ty)->getOrCreateTypeDIE(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.ty"))
|
||||||
|
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||||
|
DIType Ty(NMD->getOperand(i));
|
||||||
|
getCompileUnit(Ty)->getOrCreateTypeDIE(Ty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// collectLegacyDebugInfo - Collect debug info using DebugInfoFinder.
|
||||||
|
/// FIXME - Remove this when dragon-egg and llvm-gcc switch to DIBuilder.
|
||||||
|
bool DwarfDebug::collectLegacyDebugInfo(Module *M) {
|
||||||
|
DebugInfoFinder DbgFinder;
|
||||||
|
DbgFinder.processModule(*M);
|
||||||
|
|
||||||
|
bool HasDebugInfo = false;
|
||||||
|
// Scan all the compile-units to see if there are any marked as the main
|
||||||
|
// unit. If not, we do not generate debug info.
|
||||||
|
for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
|
||||||
|
E = DbgFinder.compile_unit_end(); I != E; ++I) {
|
||||||
|
if (DICompileUnit(*I).isMain()) {
|
||||||
|
HasDebugInfo = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!HasDebugInfo) return false;
|
||||||
|
|
||||||
|
// Create all the compile unit DIEs.
|
||||||
|
for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
|
||||||
|
E = DbgFinder.compile_unit_end(); I != E; ++I)
|
||||||
|
constructCompileUnit(*I);
|
||||||
|
|
||||||
|
// Create DIEs for each global variable.
|
||||||
|
for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),
|
||||||
|
E = DbgFinder.global_variable_end(); I != E; ++I) {
|
||||||
|
const MDNode *N = *I;
|
||||||
|
if (DIGlobalVariable(N).getVersion() <= LLVMDebugVersion9)
|
||||||
|
constructGlobalVariableDIE(getCompileUnit(N), N);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create DIEs for each subprogram.
|
||||||
|
for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
|
||||||
|
E = DbgFinder.subprogram_end(); I != E; ++I) {
|
||||||
|
const MDNode *N = *I;
|
||||||
|
constructSubprogramDIE(getCompileUnit(N), N);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HasDebugInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/// beginModule - Emit all Dwarf sections that should come prior to the
|
/// beginModule - Emit all Dwarf sections that should come prior to the
|
||||||
/// content. Create global DIEs and emit initial debug info sections.
|
/// content. Create global DIEs and emit initial debug info sections.
|
||||||
/// This is invoked by the target AsmPrinter.
|
/// This is invoked by the target AsmPrinter.
|
||||||
@@ -608,43 +665,10 @@ void DwarfDebug::beginModule(Module *M) {
|
|||||||
constructSubprogramDIE(getCompileUnit(N), N);
|
constructSubprogramDIE(getCompileUnit(N), N);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if (!collectLegacyDebugInfo(M))
|
||||||
|
return;
|
||||||
|
|
||||||
DebugInfoFinder DbgFinder;
|
collectInfoFromNamedMDNodes(M);
|
||||||
DbgFinder.processModule(*M);
|
|
||||||
|
|
||||||
bool HasDebugInfo = false;
|
|
||||||
// Scan all the compile-units to see if there are any marked as the main
|
|
||||||
// unit. If not, we do not generate debug info.
|
|
||||||
for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
|
|
||||||
E = DbgFinder.compile_unit_end(); I != E; ++I) {
|
|
||||||
if (DICompileUnit(*I).isMain()) {
|
|
||||||
HasDebugInfo = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!HasDebugInfo) return;
|
|
||||||
|
|
||||||
// Create all the compile unit DIEs.
|
|
||||||
for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
|
|
||||||
E = DbgFinder.compile_unit_end(); I != E; ++I)
|
|
||||||
constructCompileUnit(*I);
|
|
||||||
|
|
||||||
// Create DIEs for each global variable.
|
|
||||||
for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),
|
|
||||||
E = DbgFinder.global_variable_end(); I != E; ++I) {
|
|
||||||
const MDNode *N = *I;
|
|
||||||
if (DIGlobalVariable(N).getVersion() <= LLVMDebugVersion9)
|
|
||||||
constructGlobalVariableDIE(getCompileUnit(N), N);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create DIEs for each subprogram.
|
|
||||||
for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
|
|
||||||
E = DbgFinder.subprogram_end(); I != E; ++I) {
|
|
||||||
const MDNode *N = *I;
|
|
||||||
constructSubprogramDIE(getCompileUnit(N), N);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tell MMI that we have debug info.
|
// Tell MMI that we have debug info.
|
||||||
MMI->setDebugInfoAvailability(true);
|
MMI->setDebugInfoAvailability(true);
|
||||||
@@ -652,19 +676,6 @@ void DwarfDebug::beginModule(Module *M) {
|
|||||||
// Emit initial sections.
|
// Emit initial sections.
|
||||||
EmitSectionLabels();
|
EmitSectionLabels();
|
||||||
|
|
||||||
//getOrCreateTypeDIE
|
|
||||||
if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum"))
|
|
||||||
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
|
||||||
DIType Ty(NMD->getOperand(i));
|
|
||||||
getCompileUnit(Ty)->getOrCreateTypeDIE(Ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.ty"))
|
|
||||||
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
|
||||||
DIType Ty(NMD->getOperand(i));
|
|
||||||
getCompileUnit(Ty)->getOrCreateTypeDIE(Ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prime section data.
|
// Prime section data.
|
||||||
SectionMap.insert(Asm->getObjFileLowering().getTextSection());
|
SectionMap.insert(Asm->getObjFileLowering().getTextSection());
|
||||||
}
|
}
|
||||||
|
@@ -468,6 +468,14 @@ public:
|
|||||||
DwarfDebug(AsmPrinter *A, Module *M);
|
DwarfDebug(AsmPrinter *A, Module *M);
|
||||||
~DwarfDebug();
|
~DwarfDebug();
|
||||||
|
|
||||||
|
/// collectInfoFromNamedMDNodes - Collect debug info from named mdnodes such
|
||||||
|
/// as llvm.dbg.enum and llvm.dbg.ty
|
||||||
|
void collectInfoFromNamedMDNodes(Module *M);
|
||||||
|
|
||||||
|
/// collectLegacyDebugInfo - Collect debug info using DebugInfoFinder.
|
||||||
|
/// FIXME - Remove this when dragon-egg and llvm-gcc switch to DIBuilder.
|
||||||
|
bool collectLegacyDebugInfo(Module *M);
|
||||||
|
|
||||||
/// beginModule - Emit all Dwarf sections that should come prior to the
|
/// beginModule - Emit all Dwarf sections that should come prior to the
|
||||||
/// content.
|
/// content.
|
||||||
void beginModule(Module *M);
|
void beginModule(Module *M);
|
||||||
|
Reference in New Issue
Block a user