@@ -204,10 +204,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
204
204
void emitImport (ImportDecl *D);
205
205
llvm::DISubprogram *emitFunction (const SILDebugScope *DS, llvm::Function *Fn,
206
206
SILFunctionTypeRepresentation Rep,
207
- SILType Ty, DeclContext *DeclCtx = nullptr );
207
+ SILType Ty, DeclContext *DeclCtx = nullptr ,
208
+ StringRef oulinedFromName = StringRef());
208
209
llvm::DISubprogram *emitFunction (SILFunction &SILFn, llvm::Function *Fn);
209
210
void emitArtificialFunction (IRBuilder &Builder, llvm::Function *Fn,
210
211
SILType SILTy);
212
+ void emitOutlinedFunction (IRBuilder &Builder,
213
+ llvm::Function *Fn,
214
+ StringRef outlinedFromName);
211
215
212
216
// / Return false if we fail to create the right DW_OP_LLVM_fragment operand.
213
217
bool handleFragmentDIExpr (const SILDIExprOperand &CurDIExprOp,
@@ -2261,7 +2265,8 @@ llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction(SILFunction &SILFn,
2261
2265
llvm::DISubprogram *
2262
2266
IRGenDebugInfoImpl::emitFunction (const SILDebugScope *DS, llvm::Function *Fn,
2263
2267
SILFunctionTypeRepresentation Rep,
2264
- SILType SILTy, DeclContext *DeclCtx) {
2268
+ SILType SILTy, DeclContext *DeclCtx,
2269
+ StringRef outlinedFromName) {
2265
2270
auto Cached = ScopeCache.find (DS);
2266
2271
if (Cached != ScopeCache.end ()) {
2267
2272
auto SP = cast<llvm::DISubprogram>(Cached->second );
@@ -2277,7 +2282,9 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
2277
2282
auto *SILFn = DS ? DS->Parent .dyn_cast <SILFunction *>() : nullptr ;
2278
2283
2279
2284
StringRef LinkageName;
2280
- if (Fn)
2285
+ if (!outlinedFromName.empty ())
2286
+ LinkageName = outlinedFromName;
2287
+ else if (Fn)
2281
2288
LinkageName = Fn->getName ();
2282
2289
else if (DS)
2283
2290
LinkageName = SILFn->getName ();
@@ -2407,6 +2414,18 @@ void IRGenDebugInfoImpl::emitArtificialFunction(IRBuilder &Builder,
2407
2414
setCurrentLoc (Builder, Scope, ALoc);
2408
2415
}
2409
2416
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
+
2410
2429
bool IRGenDebugInfoImpl::handleFragmentDIExpr (
2411
2430
const SILDIExprOperand &CurDIExprOp, SmallVectorImpl<uint64_t > &Operands) {
2412
2431
assert (CurDIExprOp.getOperator () == SILDIExprOperator::Fragment);
@@ -2911,7 +2930,11 @@ void IRGenDebugInfo::emitArtificialFunction(IRBuilder &Builder,
2911
2930
static_cast <IRGenDebugInfoImpl *>(this )->emitArtificialFunction (Builder, Fn,
2912
2931
SILTy);
2913
2932
}
2914
-
2933
+ void IRGenDebugInfo::emitOutlinedFunction (IRBuilder &Builder,
2934
+ llvm::Function *Fn, StringRef name) {
2935
+ static_cast <IRGenDebugInfoImpl *>(this )->emitOutlinedFunction (Builder, Fn,
2936
+ name);
2937
+ }
2915
2938
void IRGenDebugInfo::emitVariableDeclaration (
2916
2939
IRBuilder &Builder, ArrayRef<llvm::Value *> Storage, DebugTypeInfo Ty,
2917
2940
const SILDebugScope *DS, Optional<SILLocation> VarLoc,
0 commit comments