@@ -204,10 +204,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
204204 void emitImport (ImportDecl *D);
205205 llvm::DISubprogram *emitFunction (const SILDebugScope *DS, llvm::Function *Fn,
206206 SILFunctionTypeRepresentation Rep,
207- SILType Ty, DeclContext *DeclCtx = nullptr );
207+ SILType Ty, DeclContext *DeclCtx = nullptr ,
208+ StringRef oulinedFromName = StringRef());
208209 llvm::DISubprogram *emitFunction (SILFunction &SILFn, llvm::Function *Fn);
209210 void emitArtificialFunction (IRBuilder &Builder, llvm::Function *Fn,
210211 SILType SILTy);
212+ void emitOutlinedFunction (IRBuilder &Builder,
213+ llvm::Function *Fn,
214+ StringRef outlinedFromName);
211215
212216 // / Return false if we fail to create the right DW_OP_LLVM_fragment operand.
213217 bool handleFragmentDIExpr (const SILDIExprOperand &CurDIExprOp,
@@ -2261,7 +2265,8 @@ llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction(SILFunction &SILFn,
22612265llvm::DISubprogram *
22622266IRGenDebugInfoImpl::emitFunction (const SILDebugScope *DS, llvm::Function *Fn,
22632267 SILFunctionTypeRepresentation Rep,
2264- SILType SILTy, DeclContext *DeclCtx) {
2268+ SILType SILTy, DeclContext *DeclCtx,
2269+ StringRef outlinedFromName) {
22652270 auto Cached = ScopeCache.find (DS);
22662271 if (Cached != ScopeCache.end ()) {
22672272 auto SP = cast<llvm::DISubprogram>(Cached->second );
@@ -2277,7 +2282,9 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
22772282 auto *SILFn = DS ? DS->Parent .dyn_cast <SILFunction *>() : nullptr ;
22782283
22792284 StringRef LinkageName;
2280- if (Fn)
2285+ if (!outlinedFromName.empty ())
2286+ LinkageName = outlinedFromName;
2287+ else if (Fn)
22812288 LinkageName = Fn->getName ();
22822289 else if (DS)
22832290 LinkageName = SILFn->getName ();
@@ -2407,6 +2414,18 @@ void IRGenDebugInfoImpl::emitArtificialFunction(IRBuilder &Builder,
24072414 setCurrentLoc (Builder, Scope, ALoc);
24082415}
24092416
2417+ void IRGenDebugInfoImpl::emitOutlinedFunction (IRBuilder &Builder,
2418+ llvm::Function *Fn,
2419+ StringRef outlinedFromName) {
2420+ RegularLocation ALoc = RegularLocation::getAutoGeneratedLocation ();
2421+ const SILDebugScope *Scope = new (IGM.getSILModule ()) SILDebugScope (ALoc);
2422+ emitFunction (Scope, Fn, SILFunctionTypeRepresentation::Thin, SILType (),
2423+ nullptr , outlinedFromName);
2424+ // / Reusing the current file would be wrong: An objc thunk, for example, could
2425+ // / be triggered from any random location. Use a placeholder name instead.
2426+ setCurrentLoc (Builder, Scope, ALoc);
2427+ }
2428+
24102429bool IRGenDebugInfoImpl::handleFragmentDIExpr (
24112430 const SILDIExprOperand &CurDIExprOp, SmallVectorImpl<uint64_t > &Operands) {
24122431 assert (CurDIExprOp.getOperator () == SILDIExprOperator::Fragment);
@@ -2911,7 +2930,11 @@ void IRGenDebugInfo::emitArtificialFunction(IRBuilder &Builder,
29112930 static_cast <IRGenDebugInfoImpl *>(this )->emitArtificialFunction (Builder, Fn,
29122931 SILTy);
29132932}
2914-
2933+ void IRGenDebugInfo::emitOutlinedFunction (IRBuilder &Builder,
2934+ llvm::Function *Fn, StringRef name) {
2935+ static_cast <IRGenDebugInfoImpl *>(this )->emitOutlinedFunction (Builder, Fn,
2936+ name);
2937+ }
29152938void IRGenDebugInfo::emitVariableDeclaration (
29162939 IRBuilder &Builder, ArrayRef<llvm::Value *> Storage, DebugTypeInfo Ty,
29172940 const SILDebugScope *DS, Optional<SILLocation> VarLoc,
0 commit comments