@@ -284,6 +284,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
284
284
void emitPackCountParameter (IRGenFunction &IGF, llvm::Value *Metadata,
285
285
SILDebugVariable VarInfo);
286
286
287
+ // / Return flags which enable debug info emission for call sites, provided
288
+ // / that it is supported and enabled.
289
+ llvm::DINode::DIFlags getCallSiteRelatedAttrs () const ;
290
+
287
291
// / Return the DIBuilder.
288
292
llvm::DIBuilder &getBuilder () { return DBuilder; }
289
293
@@ -3042,6 +3046,27 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
3042
3046
ImportedModules.insert (Imported.importedModule );
3043
3047
}
3044
3048
3049
+ // / This is effectively \p clang::CGDebugInfo::getCallSiteRelatedAttrs().
3050
+ llvm::DINode::DIFlags IRGenDebugInfoImpl::getCallSiteRelatedAttrs () const {
3051
+ auto SwiftLangOpts = IGM.Context .LangOpts ;
3052
+ auto Loader = IGM.getSILModule ().getASTContext ().getClangModuleLoader ();
3053
+ auto *Importer = static_cast <ClangImporter *>(&*Loader);
3054
+ auto &CGO = Importer->getCodeGenOpts ();
3055
+
3056
+ // Do not generate call site attributes if there is no debug info to be
3057
+ // emitted.
3058
+ if (CGO.getDebugInfo () == llvm::codegenoptions::NoDebugInfo ||
3059
+ CGO.getDebugInfo () == llvm::codegenoptions::LocTrackingOnly)
3060
+ return llvm::DINode::FlagZero;
3061
+
3062
+ // Call site attributes are available in DWARFv5. However, for swift, lldb can
3063
+ // accept these attributes as if they were part of DWARFv4.
3064
+ if (Opts.DWARFVersion < 4 )
3065
+ return llvm::DINode::FlagZero;
3066
+
3067
+ return llvm::DINode::FlagAllCallsDescribed;
3068
+ }
3069
+
3045
3070
llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction (SILFunction &SILFn,
3046
3071
llvm::Function *Fn) {
3047
3072
auto *DS = SILFn.getDebugScope ();
@@ -3193,9 +3218,10 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
3193
3218
}
3194
3219
3195
3220
// Construct the DISubprogram.
3196
- llvm::DISubprogram *SP = DBuilder.createFunction (
3197
- Scope, Name, LinkageName, File, Line, DIFnTy, ScopeLine, Flags, SPFlags,
3198
- TemplateParameters, Decl, Error);
3221
+ llvm::DISubprogram *SP =
3222
+ DBuilder.createFunction (Scope, Name, LinkageName, File, Line, DIFnTy,
3223
+ ScopeLine, Flags | getCallSiteRelatedAttrs (),
3224
+ SPFlags, TemplateParameters, Decl, Error);
3199
3225
3200
3226
if (Fn && !Fn->isDeclaration ())
3201
3227
Fn->setSubprogram (SP);
0 commit comments