Skip to content

Commit cf204f2

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. (cherry picked from commit 17e756b)
1 parent 0fbf660 commit cf204f2

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
@@ -5019,6 +5019,8 @@ static void emitRetconCoroutineEntry(
50195019
for (auto *arg : finalArguments) {
50205020
arguments.push_back(arg);
50215021
}
5022+
ArtificialLocation Loc(IGF.getDebugScope(), IGF.IGM.DebugInfo.get(),
5023+
IGF.Builder);
50225024
llvm::Value *id = IGF.Builder.CreateIntrinsicCall(idIntrinsic, arguments);
50235025

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

5128-
ArtificialLocation Loc(IGF.getDebugScope(), IGF.IGM.DebugInfo.get(), IGF.Builder);
51295130
emitRetconCoroutineEntry(IGF, fnType, buffer,
51305131
llvm::Intrinsic::coro_id_retcon_once,
51315132
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)