Fix debug info for NoDebug attr
NoDebug attr does not totally eliminate debug info about a function when
inlining is enabled. This is inconsistent with when inlining is disabled.
This patch fixes that.
Differential Revision: https://reviews.llvm.org/D79967
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 88ddb44..7ec792c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3885,12 +3885,12 @@
if (Func->getSubprogram())
return;
- // Do not emit a declaration subprogram for a builtin 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 ||
+ // 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<NoDebugAttr>() ||
getCallSiteRelatedAttrs() == llvm::DINode::FlagZero)
return;
if (const auto *Id = CalleeDecl->getIdentifier())