Skip to content

Commit 5183bb7

Browse files
authored
Merge pull request swiftlang#18981 from rjmccall/llvm-noinline-coroutines
Disable inlining coroutines until the coroutine-splitting pass runs
2 parents 661c30f + 6b9cfbe commit 5183bb7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,11 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM,
12591259
else
12601260
CurFn->addFnAttr(llvm::Attribute::SanitizeThread);
12611261
}
1262+
1263+
// Disable inlining of coroutine functions until we split.
1264+
if (f->getLoweredFunctionType()->isCoroutine()) {
1265+
CurFn->addFnAttr(llvm::Attribute::NoInline);
1266+
}
12621267
}
12631268

12641269
IRGenSILFunction::~IRGenSILFunction() {

test/IRGen/yield_once.sil

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sil @marker : $(Builtin.Int32) -> ()
77
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc i8* @test_simple
88
// CHECK-32-SAME: i8* noalias dereferenceable([[BUFFER_SIZE:16]]))
99
// CHECK-64-SAME: (i8* noalias dereferenceable([[BUFFER_SIZE:32]]))
10+
// CHECK-SAME: [[CORO_ATTRIBUTES:#[0-9]+]]
1011
sil @test_simple : $@yield_once () -> () {
1112
entry:
1213
// CHECK-32: [[ID:%.*]] = call token @llvm.coro.id.retcon.once(i32 [[BUFFER_SIZE]], i32 [[BUFFER_ALIGN:4]], i8* %0, i8* bitcast (void (i8*, i1)* @"$SIet_TC" to i8*), i8* bitcast (i8* (i32)* @malloc to i8*), i8* bitcast (void (i8*)* @free to i8*))
@@ -88,3 +89,6 @@ cont:
8889
%ret = tuple ()
8990
return %ret : $()
9091
}
92+
93+
// CHECK: attributes [[CORO_ATTRIBUTES]] =
94+
// CHECK-SAME: noinline

0 commit comments

Comments
 (0)