mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[DebugInfo] Dont emit info for __swift_async_resume_project_context or __swift_async_resume_get_context
Those functions are effectively outlined functions with an alwaysinline attribute. By removing their debug info and relying on the inliner to propagate the call site location to the inlined instructions, we restore the "original" locations as if the function had never been outlined. This is technically relying on an implementation detail of the inliner, but it seems to be the simplest way of addressing this issue.
This commit is contained in:
@@ -3114,7 +3114,7 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) {
|
||||
// Index of swiftasync context | ((index of swiftself) << 8).
|
||||
arguments.push_back(IGM.getInt32(paramAttributeFlags));
|
||||
arguments.push_back(currentResumeFn);
|
||||
auto resumeProjFn = IGF.getOrCreateResumePrjFn(true /*forProlog*/);
|
||||
auto resumeProjFn = IGF.getOrCreateResumePrjFn();
|
||||
arguments.push_back(
|
||||
Builder.CreateBitOrPointerCast(resumeProjFn, IGM.Int8PtrTy));
|
||||
auto dispatchFn = IGF.createAsyncDispatchFn(
|
||||
|
||||
@@ -2846,11 +2846,12 @@ IRGenFunction::emitAsyncResumeProjectContext(llvm::Value *calleeContext) {
|
||||
return callerContext;
|
||||
}
|
||||
|
||||
llvm::Function *IRGenFunction::getOrCreateResumePrjFn(bool forPrologue) {
|
||||
// The prologue version lacks artificial debug info as this would cause
|
||||
// verification errors when it gets inlined.
|
||||
auto name = forPrologue ? "__swift_async_resume_project_context_prologue"
|
||||
: "__swift_async_resume_project_context";
|
||||
llvm::Function *IRGenFunction::getOrCreateResumePrjFn() {
|
||||
auto name = "__swift_async_resume_project_context";
|
||||
// This is effectively an outlined function with `alwaysinline`. Don't emit
|
||||
// debug locations for those to avoid creating unnecessary inlined frames.
|
||||
// Instead, rely on the inliner to propagate the call site debug location.
|
||||
const bool skipDebugInfo = true;
|
||||
auto Fn = cast<llvm::Function>(IGM.getOrCreateHelperFunction(
|
||||
name, IGM.Int8PtrTy, {IGM.Int8PtrTy},
|
||||
[&](IRGenFunction &IGF) {
|
||||
@@ -2860,7 +2861,7 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn(bool forPrologue) {
|
||||
auto callerContext = IGF.emitAsyncResumeProjectContext(addr);
|
||||
Builder.CreateRet(callerContext);
|
||||
},
|
||||
false /*isNoInline*/, forPrologue));
|
||||
false /*isNoInline*/, skipDebugInfo));
|
||||
Fn->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
return Fn;
|
||||
}
|
||||
@@ -2955,7 +2956,7 @@ llvm::Function *IRGenFunction::getOrCreateResumeFromSuspensionFn() {
|
||||
auto &Builder = IGF.Builder;
|
||||
Builder.CreateRet(&*IGF.CurFn->arg_begin());
|
||||
},
|
||||
false /*isNoInline*/));
|
||||
false /*isNoInline*/, true /*forPrologue*/));
|
||||
fn->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
return fn;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
bool restoreCurrentContext = true);
|
||||
|
||||
llvm::Value *emitAsyncResumeProjectContext(llvm::Value *callerContextAddr);
|
||||
llvm::Function *getOrCreateResumePrjFn(bool forPrologue = false);
|
||||
llvm::Function *getOrCreateResumePrjFn();
|
||||
llvm::Function *createAsyncDispatchFn(const FunctionPointer &fnPtr,
|
||||
ArrayRef<llvm::Value *> args);
|
||||
llvm::Function *createAsyncDispatchFn(const FunctionPointer &fnPtr,
|
||||
|
||||
@@ -22,11 +22,21 @@ func ASYNC___2___() async -> Int {
|
||||
// CHECK: ret void
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// CHECK-LABEL: define {{.*}} @__swift_async_resume_get_context
|
||||
// CHECK-NOT: !dbg
|
||||
// CHECK: ret ptr
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.1"
|
||||
// CHECK-NOT: !dbg
|
||||
// CHECK: ret void
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// CHECK-LABEL: define {{.*}} @__swift_async_resume_project_context
|
||||
// CHECK-NOT: !dbg
|
||||
// CHECK: ret ptr
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// CHECK-LABEL: define {{.*}} @"$s1M12ASYNC___2___SiyYaF.0"
|
||||
// CHECK-NOT: !dbg
|
||||
// CHECK: ret void
|
||||
|
||||
Reference in New Issue
Block a user