summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-28 05:03:22 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-28 05:03:22 +0000
commit67f684e18ea55621078b30ab26462f7e74e0986a (patch)
tree840f5266c699491106d5ee1d643270785829a4ab /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parentaa849bc2f23432af3104b2c1524009312bcad223 (diff)
downloadbcm5719-llvm-67f684e18ea55621078b30ab26462f7e74e0986a.tar.gz
bcm5719-llvm-67f684e18ea55621078b30ab26462f7e74e0986a.zip
[CodeView] Don't crash on functions without subprograms
A function may have instructions annotated with debug info without having a subprogram. This fixes PR28747. llvm-svn: 276956
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index e639d0e2b39..7e8f46b0a2a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -217,10 +217,7 @@ TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) {
}
TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) {
- // It's possible to ask for the FuncId of a function which doesn't have a
- // subprogram: inlining a function with debug info into a function with none.
- if (!SP)
- return TypeIndex::None();
+ assert(SP);
// Check if we've already translated this subprogram.
auto I = TypeIndices.find({SP, nullptr});
@@ -624,11 +621,12 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
std::string FuncName;
auto *SP = GV->getSubprogram();
+ assert(SP);
setCurrentSubprogram(SP);
// If we have a display name, build the fully qualified name by walking the
// chain of scopes.
- if (SP != nullptr && !SP->getDisplayName().empty())
+ if (!SP->getDisplayName().empty())
FuncName =
getFullyQualifiedName(SP->getScope().resolve(), SP->getDisplayName());
@@ -867,7 +865,7 @@ void CodeViewDebug::collectVariableInfo(const DISubprogram *SP) {
void CodeViewDebug::beginFunction(const MachineFunction *MF) {
assert(!CurFn && "Can't process two functions at once!");
- if (!Asm || !MMI->hasDebugInfo())
+ if (!Asm || !MMI->hasDebugInfo() || !MF->getFunction()->getSubprogram())
return;
DebugHandlerBase::beginFunction(MF);
@@ -1942,7 +1940,8 @@ void CodeViewDebug::beginInstruction(const MachineInstr *MI) {
DebugHandlerBase::beginInstruction(MI);
// Ignore DBG_VALUE locations and function prologue.
- if (!Asm || MI->isDebugValue() || MI->getFlag(MachineInstr::FrameSetup))
+ if (!Asm || !CurFn || MI->isDebugValue() ||
+ MI->getFlag(MachineInstr::FrameSetup))
return;
DebugLoc DL = MI->getDebugLoc();
if (DL == PrevInstLoc || !DL)
OpenPOWER on IntegriCloud