Skip to content

Commit add012c

Browse files
authored
Merge pull request #69682 from kubamracek/embedded-debuginfo-irgen
[embedded] Avoid materializing generic functions for debuginfo purposes in embedded Swift
2 parents 7a920cd + 84561f9 commit add012c

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,11 @@ llvm::DIScope *IRGenDebugInfoImpl::getOrCreateScope(const SILDebugScope *DS) {
23282328
// Force the debug info for the function to be emitted, even if it
23292329
// is external or has been inlined.
23302330
llvm::Function *Fn = nullptr;
2331-
if (!SILFn->getName().empty() && !SILFn->isZombie())
2331+
// Avoid materializing generic functions in embedded Swift mode.
2332+
bool genericInEmbedded =
2333+
IGM.Context.LangOpts.hasFeature(Feature::Embedded) &&
2334+
SILFn->isGeneric();
2335+
if (!SILFn->getName().empty() && !SILFn->isZombie() && !genericInEmbedded)
23322336
Fn = IGM.getAddrOfSILFunction(SILFn, NotForDefinition);
23332337
auto *SP = emitFunction(*SILFn, Fn);
23342338

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %target-run-simple-swift(-g %S/Inputs/print.swift -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-g -Osize %S/Inputs/print.swift -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
3+
4+
// REQUIRES: executable_test
5+
// REQUIRES: optimized_stdlib
6+
// REQUIRES: VENDOR=apple
7+
// REQUIRES: OS=macosx
8+
9+
struct User {
10+
let o: BaseClass
11+
}
12+
13+
class BaseClass {
14+
func foo() {}
15+
}
16+
17+
protocol Protocol {
18+
func protofoo()
19+
}
20+
21+
class Implementor: Protocol {
22+
func protofoo() { print("Implementor.protofoo") }
23+
}
24+
25+
class GenericSubClass<P: Protocol>: BaseClass {
26+
let p: P
27+
28+
init(p: P) {
29+
self.p = p
30+
}
31+
32+
override func foo() {
33+
let x = { self.p.protofoo() }
34+
x()
35+
}
36+
}
37+
38+
@main
39+
struct Main {
40+
static func main() {
41+
let p = Implementor()
42+
let o = GenericSubClass(p: p)
43+
let user = User(o: o)
44+
user.o.foo()
45+
}
46+
}
47+
48+
// CHECK: Implementor.protofoo
49+

0 commit comments

Comments
 (0)