Skip to content

Commit 8a25294

Browse files
Merge pull request #71965 from augusto2112/fix-lto-decl
[DebugInfo] Emit witness and objc method declarations in debug info
2 parents 9f9f91d + 53d1844 commit 8a25294

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,9 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
28572857
// Because there's no good way to cross the CU boundary to insert a nested
28582858
// DISubprogram definition in one CU into a type defined in another CU when
28592859
// doing LTO builds.
2860-
if (Rep == SILFunctionTypeRepresentation::Method) {
2860+
if (Rep == SILFunctionTypeRepresentation::Method ||
2861+
Rep == SILFunctionTypeRepresentation::ObjCMethod ||
2862+
Rep == SILFunctionTypeRepresentation::WitnessMethod) {
28612863
llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::toSPFlags(
28622864
/*IsLocalToUnit=*/Fn ? Fn->hasInternalLinkage() : true,
28632865
/*IsDefinition=*/false, /*IsOptimized=*/Opts.shouldOptimize());
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -gdwarf-types -o - | %FileCheck %s
2+
3+
// Verify that we added a declaration for a witness method.
4+
5+
// CHECK: define{{.*}}@"$s4main14PutCharPrinterCAA09CharacterD0A2aDPxycfCTW"{{.*}} !dbg ![[INIT_DEF_DBG:[0-9]+]]
6+
// CHECK: ![[INIT_DEF_DBG]] = distinct !DISubprogram(name: "init", linkageName: "$s4main14PutCharPrinterCAA09CharacterD0A2aDPxycfCTW"
7+
// CHECK-SAME: DISPFlagDefinition{{.*}} declaration: ![[FUNC_DEF_DBG:[0-9]+]]
8+
// CHECK: ![[FUNC_DEF_DBG]] = !DISubprogram(name: "init", linkageName: "$s4main14PutCharPrinterCAA09CharacterD0A2aDPxycfCTW"
9+
10+
protocol CharacterPrinter {
11+
init()
12+
}
13+
14+
class PutCharPrinter: CharacterPrinter {
15+
public required init() {}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -gdwarf-types -o - | %FileCheck %s
3+
4+
// Verify that we added a declaration for a witness method.
5+
6+
// CHECK: define {{.*}}"$s4main9SomeClassC3fooyyFTo"{{.*}} !dbg ![[INIT_DEF_DBG:[0-9]+]]
7+
// CHECK: ![[INIT_DEF_DBG]] = distinct !DISubprogram(name: "foo", linkageName: "$s4main9SomeClassC3fooyyFTo"
8+
// CHECK-SAME: DISPFlagDefinition{{.*}} declaration: ![[FUNC_DEF_DBG:[0-9]+]]
9+
// CHECK: ![[FUNC_DEF_DBG]] = !DISubprogram(name: "foo", linkageName: "$s4main9SomeClassC3fooyyFTo"
10+
11+
import Foundation
12+
13+
class SomeClass {
14+
public required init() {}
15+
16+
@objc func foo() {}
17+
}

0 commit comments

Comments
 (0)