forked from OSchip/llvm-project
Fix PR19239 - Add support for generating debug info for functions without lexical scopes and/or debug info at all
llvm-svn: 204790
This commit is contained in:
parent
e32ef937eb
commit
8499a12259
|
@ -131,9 +131,12 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) {
|
||||||
// For each function there is a separate subsection
|
// For each function there is a separate subsection
|
||||||
// which holds the PC to file:line table.
|
// which holds the PC to file:line table.
|
||||||
const MCSymbol *Fn = Asm->getSymbol(GV);
|
const MCSymbol *Fn = Asm->getSymbol(GV);
|
||||||
const FunctionInfo &FI = FnDebugInfo[GV];
|
|
||||||
assert(Fn);
|
assert(Fn);
|
||||||
assert(FI.Instrs.size() > 0);
|
|
||||||
|
const FunctionInfo &FI = FnDebugInfo[GV];
|
||||||
|
if (FI.Instrs.empty())
|
||||||
|
return;
|
||||||
|
assert(FI.End && "Don't know where the function ends?");
|
||||||
|
|
||||||
// PCs/Instructions are grouped into segments sharing the same filename.
|
// PCs/Instructions are grouped into segments sharing the same filename.
|
||||||
// Pre-calculate the lengths (in instructions) of these segments and store
|
// Pre-calculate the lengths (in instructions) of these segments and store
|
||||||
|
@ -264,12 +267,6 @@ void WinCodeViewLineTables::beginFunction(const MachineFunction *MF) {
|
||||||
if (!Asm || !Asm->MMI->hasDebugInfo())
|
if (!Asm || !Asm->MMI->hasDebugInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Grab the lexical scopes for the function, if we don't have any of those
|
|
||||||
// then we're not going to be able to do anything.
|
|
||||||
LScopes.initialize(*MF);
|
|
||||||
if (LScopes.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const Function *GV = MF->getFunction();
|
const Function *GV = MF->getFunction();
|
||||||
assert(FnDebugInfo.count(GV) == false);
|
assert(FnDebugInfo.count(GV) == false);
|
||||||
VisitedFunctions.push_back(GV);
|
VisitedFunctions.push_back(GV);
|
||||||
|
@ -311,13 +308,12 @@ void WinCodeViewLineTables::endFunction(const MachineFunction *) {
|
||||||
if (!Asm || !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;
|
return;
|
||||||
|
|
||||||
if (CurFn->Instrs.empty())
|
if (!CurFn->Instrs.empty()) {
|
||||||
llvm_unreachable("Can this ever happen?");
|
// Define end label for subprogram.
|
||||||
|
MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
|
||||||
// Define end label for subprogram.
|
Asm->OutStreamer.EmitLabel(FunctionEndSym);
|
||||||
MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
|
CurFn->End = FunctionEndSym;
|
||||||
Asm->OutStreamer.EmitLabel(FunctionEndSym);
|
}
|
||||||
CurFn->End = FunctionEndSym;
|
|
||||||
CurFn = 0;
|
CurFn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,13 @@ namespace llvm {
|
||||||
class WinCodeViewLineTables : public AsmPrinterHandler {
|
class WinCodeViewLineTables : public AsmPrinterHandler {
|
||||||
AsmPrinter *Asm;
|
AsmPrinter *Asm;
|
||||||
DebugLoc PrevInstLoc;
|
DebugLoc PrevInstLoc;
|
||||||
LexicalScopes LScopes;
|
|
||||||
|
|
||||||
// For each function, store a vector of labels to its instructions, as well as
|
// For each function, store a vector of labels to its instructions, as well as
|
||||||
// to the end of the function.
|
// to the end of the function.
|
||||||
struct FunctionInfo {
|
struct FunctionInfo {
|
||||||
SmallVector<MCSymbol *, 10> Instrs;
|
SmallVector<MCSymbol *, 10> Instrs;
|
||||||
MCSymbol *End;
|
MCSymbol *End;
|
||||||
|
FunctionInfo() : End(0) {}
|
||||||
} *CurFn;
|
} *CurFn;
|
||||||
|
|
||||||
typedef DenseMap<const Function *, FunctionInfo> FnDebugInfoTy;
|
typedef DenseMap<const Function *, FunctionInfo> FnDebugInfoTy;
|
||||||
|
|
Loading…
Reference in New Issue