Author: hans Date: Thu Jul 28 18:15:39 2016 New Revision: 277078 URL: http://llvm.org/viewvc/llvm-project?rev=277078&view=rev Log: Merging r276956: ------------------------------------------------------------------------ r276956 | majnemer | 2016-07-27 22:03:22 -0700 (Wed, 27 Jul 2016) | 6 lines
[CodeView] Don't crash on functions without subprograms A function may have instructions annotated with debug info without having a subprogram. This fixes PR28747. ------------------------------------------------------------------------ Added: llvm/branches/release_39/test/DebugInfo/COFF/pr28747.ll - copied unchanged from r276956, llvm/trunk/test/DebugInfo/COFF/pr28747.ll Modified: llvm/branches/release_39/ (props changed) llvm/branches/release_39/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp llvm/branches/release_39/test/DebugInfo/COFF/inlining-same-name.ll Propchange: llvm/branches/release_39/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jul 28 18:15:39 2016 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276077,276109,276181,276209,276236-276237,276358,276364,276368,276389,276438,276479,276510,276740 +/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276077,276109,276181,276209,276236-276237,276358,276364,276368,276389,276438,276479,276510,276740,276956 Modified: llvm/branches/release_39/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=277078&r1=277077&r2=277078&view=diff ============================================================================== --- llvm/branches/release_39/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original) +++ llvm/branches/release_39/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Jul 28 18:15:39 2016 @@ -214,10 +214,7 @@ TypeIndex CodeViewDebug::getScopeIndex(c } 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}); @@ -621,11 +618,12 @@ void CodeViewDebug::emitDebugInfoForFunc 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()); @@ -864,7 +862,7 @@ void CodeViewDebug::collectVariableInfo( 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); @@ -1939,7 +1937,8 @@ void CodeViewDebug::beginInstruction(con 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) Modified: llvm/branches/release_39/test/DebugInfo/COFF/inlining-same-name.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/test/DebugInfo/COFF/inlining-same-name.ll?rev=277078&r1=277077&r2=277078&view=diff ============================================================================== --- llvm/branches/release_39/test/DebugInfo/COFF/inlining-same-name.ll (original) +++ llvm/branches/release_39/test/DebugInfo/COFF/inlining-same-name.ll Thu Jul 28 18:15:39 2016 @@ -33,7 +33,7 @@ target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc" -define void @main(i32* %i.i) { +define void @main(i32* %i.i) !dbg !16 { store volatile i32 3, i32* %i.i, !dbg !6 store volatile i32 3, i32* %i.i, !dbg !19 ret void _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits