Skip to content

Commit b117565

Browse files
rastogishubhamCatfish-Man
authored andcommitted
Set debug location to Coroutine call expression
If debug info generation is enabled, set debug location to the coroutine call instruction to make sure there are no issues with invalid debug information in LTO. This happens because in LTO, if a call to a function doesn't contain a debug location, we see the warning: inlinable function call in a function with debug info must have a !dbg location ld: warning: Invalid debug info found, debug info will be stripped Which then strips the debug info from the entire .o file linked into the dylib.
1 parent c47fe33 commit b117565

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5023,6 +5023,8 @@ static void emitRetconCoroutineEntry(
50235023
for (auto *arg : finalArguments) {
50245024
arguments.push_back(arg);
50255025
}
5026+
ArtificialLocation Loc(IGF.getDebugScope(), IGF.IGM.DebugInfo.get(),
5027+
IGF.Builder);
50265028
llvm::Value *id = IGF.Builder.CreateIntrinsicCall(idIntrinsic, arguments);
50275029

50285030
// Call 'llvm.coro.begin', just for consistency with the normal pattern.
@@ -5127,7 +5129,6 @@ void irgen::emitYieldOnceCoroutineEntry(
51275129
allocFn = IGF.IGM.getOpaquePtr(IGF.IGM.getMallocFn());
51285130
}
51295131

5130-
ArtificialLocation Loc(IGF.getDebugScope(), IGF.IGM.DebugInfo.get(), IGF.Builder);
51315132
emitRetconCoroutineEntry(IGF, fnType, buffer,
51325133
llvm::Intrinsic::coro_id_retcon_once,
51335134
getYieldOnceCoroutineBufferSize(IGF.IGM),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// REQUIRES: swift_feature_CoroutineAccessors
2+
// RUN: %target-swift-frontend %s -g -c -O -o - -emit-irgen -enable-experimental-feature CoroutineAccessors | %FileCheck %s
3+
4+
// This test checks to made sure that the ReadAccessor s26CoroutineAccessorsDebugLoc1SV3irmSivr that has a call to @llvm.coro.id.retcon.once, also has a debug location set.
5+
6+
// CHECK-LABEL: @"$s26CoroutineAccessorsDebugLoc1SV3irmSivr"
7+
// CHECK: %{{.*}} = call token ({{.*}}) @llvm.coro.id.retcon.once({{.*}}), !dbg ![[DBGLOC:[0-9]+]]
8+
// CHECK-NEXT: %{{.*}} = call ptr @llvm.coro.begin({{.*}}), !dbg ![[DBGLOC]]
9+
10+
public struct S {
11+
public var o: any AnyObject
12+
public var _i: Int = 0
13+
14+
public var irm: Int {
15+
_read {
16+
yield _i
17+
}
18+
} // public var irm
19+
}

0 commit comments

Comments
 (0)