diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index b6a90c5e2e225..92f56331d9c7f 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -2958,7 +2958,12 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn, // Because there's no good way to cross the CU boundary to insert a nested // DISubprogram definition in one CU into a type defined in another CU when // doing LTO builds. - if (llvm::isa(Scope)) { + if (llvm::isa(Scope) && + (Rep == SILFunctionTypeRepresentation::Method || + Rep == SILFunctionTypeRepresentation::ObjCMethod || + Rep == SILFunctionTypeRepresentation::WitnessMethod || + Rep == SILFunctionTypeRepresentation::CXXMethod || + Rep == SILFunctionTypeRepresentation::Thin)) { llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::toSPFlags( /*IsLocalToUnit=*/Fn ? Fn->hasInternalLinkage() : true, /*IsDefinition=*/false, /*IsOptimized=*/Opts.shouldOptimize());