InstrInfo[MCL] = InstrInfoTy(Filename, DL.getLine());
}
-WinCodeViewLineTables::WinCodeViewLineTables(AsmPrinter *Asm)
- : Asm(Asm), CurFn(0) {
+WinCodeViewLineTables::WinCodeViewLineTables(AsmPrinter *AP)
+ : Asm(0), CurFn(0) {
+ MachineModuleInfo *MMI = AP->MMI;
+
+ // If module doesn't have named metadata anchors or COFF debug section
+ // is not available, skip any debug info related stuff.
+ if (!MMI->getModule()->getNamedMetadata("llvm.dbg.cu") ||
+ !AP->getObjFileLowering().getCOFFDebugSymbolsSection())
+ return;
+
// Tell MMI that we have debug info.
- Asm->MMI->setDebugInfoAvailability(true);
+ MMI->setDebugInfoAvailability(true);
+ Asm = AP;
}
static void EmitLabelDiff(MCStreamer &Streamer,
if (FnDebugInfo.empty())
return;
+ assert(Asm != 0);
Asm->OutStreamer.SwitchSection(
Asm->getObjFileLowering().getCOFFDebugSymbolsSection());
Asm->EmitInt32(COFF::DEBUG_SECTION_MAGIC);
void WinCodeViewLineTables::beginFunction(const MachineFunction *MF) {
assert(!CurFn && "Can't process two functions at once!");
- if (!Asm->MMI->hasDebugInfo())
+ if (!Asm || !Asm->MMI->hasDebugInfo())
return;
// Grab the lexical scopes for the function, if we don't have any of those
}
void WinCodeViewLineTables::endFunction(const MachineFunction *) {
- if (!CurFn) // We haven't created any debug info for this function.
+ if (!Asm || !CurFn) // We haven't created any debug info for this function.
return;
if (CurFn->Instrs.empty())
void WinCodeViewLineTables::beginInstruction(const MachineInstr *MI) {
// Ignore DBG_VALUE locations and function prologue.
- if (MI->isDebugValue() || MI->getFlag(MachineInstr::FrameSetup))
+ if (!Asm || MI->isDebugValue() || MI->getFlag(MachineInstr::FrameSetup))
return;
DebugLoc DL = MI->getDebugLoc();
if (DL == PrevInstLoc || DL.isUnknown())