diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4224,17 +4224,11 @@ if (Func->getSubprogram()) return; - // Do not emit a declaration subprogram for a builtin, a function with nodebug - // attribute, or if call site info isn't required. Also, elide declarations - // for functions with reserved names, as call site-related features aren't - // interesting in this case (& also, the compiler may emit calls to these - // functions without debug locations, which makes the verifier complain). - if (CalleeDecl->getBuiltinID() != 0 || CalleeDecl->hasAttr() || + // Do not emit a declaration subprogram for a function with nodebug + // attribute, or if call site info isn't required. + if (CalleeDecl->hasAttr() || getCallSiteRelatedAttrs() == llvm::DINode::FlagZero) return; - if (CalleeDecl->isReserved(CGM.getLangOpts()) != - ReservedIdentifierStatus::NotReserved) - return; // If there is no DISubprogram attached to the function being called, // create the one describing the function in order to have complete diff --git a/clang/test/CodeGen/debug-info-extern-call.c b/clang/test/CodeGen/debug-info-extern-call.c --- a/clang/test/CodeGen/debug-info-extern-call.c +++ b/clang/test/CodeGen/debug-info-extern-call.c @@ -29,8 +29,8 @@ // DECLS-FOR-EXTERN: [[FN1_TYPES]] = !{[[X_TYPE:![0-9]+]], // DECLS-FOR-EXTERN: [[X_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "x", // DECLS-FOR-EXTERN-SAME: baseType: [[INT_TYPE]]) -// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp" -// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name" +// DECLS-FOR-EXTERN: !DISubprogram(name: "memcmp" +// DECLS-FOR-EXTERN: !DISubprogram(name: "__some_reserved_name" // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1" // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp" diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3469,9 +3469,11 @@ // Verify that each inlinable callsite of a debug-info-bearing function in a // debug-info-bearing function has a debug location attached to it. Failure to // do so causes assertion failures when the inliner sets up inline scope info - // (Interposable functions are not inlinable). + // (Interposable functions are not inlinable as are functions w/o + // declarations). if (Call.getFunction()->getSubprogram() && Call.getCalledFunction() && !Call.getCalledFunction()->isInterposable() && + !Call.getCalledFunction()->isDeclaration() && Call.getCalledFunction()->getSubprogram()) CheckDI(Call.getDebugLoc(), "inlinable function call in a function with " diff --git a/llvm/test/Verifier/callsite-dbgloc.ll b/llvm/test/Verifier/callsite-dbgloc.ll --- a/llvm/test/Verifier/callsite-dbgloc.ll +++ b/llvm/test/Verifier/callsite-dbgloc.ll @@ -45,6 +45,9 @@ call void @j() ; CHECK: inlinable function call in a function with debug info must have a !dbg location call void @k() +; CHECK-NOT: inlinable function call in a function with debug info must have a !dbg location +; CHECK-NOT: @i + call void (...) @i() ret void, !dbg !13 }