Skip to content

Commit addb5c1

Browse files
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 602a116 commit addb5c1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend %s -g -c -O -o - -emit-irgen -enable-experimental-feature CoroutineAccessors | %FileCheck %s
2+
3+
// 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.
4+
5+
// CHECK-LABEL: @"$s26CoroutineAccessorsDebugLoc1SV3irmSivr"
6+
// CHECK: %{{.*}} = call token ({{.*}}) @llvm.coro.id.retcon.once({{.*}}), !dbg ![[DBGLOC:[0-9]+]]
7+
// CHECK-NEXT: %{{.*}} = call ptr @llvm.coro.begin({{.*}}), !dbg ![[DBGLOC]]
8+
9+
public struct S {
10+
public var o: any AnyObject
11+
public var _i: Int = 0
12+
13+
public var irm: Int {
14+
_read {
15+
yield _i
16+
}
17+
} // public var irm
18+
}

0 commit comments

Comments
 (0)