Skip to content

Commit 9fed715

Browse files
authored
Merge pull request #77327 from gottesmm/pr-e17f051658ed11baef6acc72f598fd5f952c0c26
Convert IRGen based FileCheck lines to SIL based test that is platform invariant
2 parents 11e8df0 + c8199b4 commit 9fed715

File tree

12 files changed

+86
-45
lines changed

12 files changed

+86
-45
lines changed

include/swift/Basic/FileTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ TYPE("swiftmodulesummary", SwiftModuleSummaryFile, "swiftmodulesummary", "")
5656
TYPE("swiftsourceinfo", SwiftSourceInfoFile, "swiftsourceinfo", "")
5757
TYPE("assembly", Assembly, "s", "")
5858
TYPE("raw-sil", RawSIL, "sil", "")
59+
TYPE("lowered-sil", LoweredSIL, "sil", "")
5960
TYPE("raw-sib", RawSIB, "sib", "")
6061
TYPE("llvm-ir", LLVM_IR, "ll", "")
6162
TYPE("raw-llvm-ir", RawLLVM_IR, "ll", "")

include/swift/Frontend/FrontendOptions.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,21 @@ class FrontendOptions {
182182
Immediate, ///< Immediate mode
183183
REPL, ///< REPL mode
184184

185-
EmitAssembly, ///< Emit assembly
186-
EmitIRGen, ///< Emit LLVM IR before LLVM optimizations
187-
EmitIR, ///< Emit LLVM IR after LLVM optimizations
188-
EmitBC, ///< Emit LLVM BC
189-
EmitObject, ///< Emit object file
185+
EmitAssembly, ///< Emit assembly
186+
EmitLoweredSIL, ///< Emit lowered SIL before IRGen runs
187+
EmitIRGen, ///< Emit LLVM IR before LLVM optimizations
188+
EmitIR, ///< Emit LLVM IR after LLVM optimizations
189+
EmitBC, ///< Emit LLVM BC
190+
EmitObject, ///< Emit object file
190191

191192
DumpTypeInfo, ///< Dump IRGen type info
192193

193194
EmitPCM, ///< Emit precompiled Clang module from a module map
194195
DumpPCM, ///< Dump information about a precompiled Clang module
195196

196-
ScanDependencies, ///< Scan dependencies of Swift source files
197-
PrintVersion, ///< Print version information.
198-
PrintFeature, ///< Print supported feature of this compiler
197+
ScanDependencies, ///< Scan dependencies of Swift source files
198+
PrintVersion, ///< Print version information.
199+
PrintFeature, ///< Print supported feature of this compiler
199200
};
200201

201202
/// Indicates the action the user requested that the frontend perform.

include/swift/Option/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,8 @@ def emit_sil : Flag<["-"], "emit-sil">,
12871287
HelpText<"Emit canonical SIL file(s)">, ModeOpt;
12881288
def emit_silgen : Flag<["-"], "emit-silgen">,
12891289
HelpText<"Emit raw SIL file(s)">, ModeOpt;
1290+
def emit_lowered_sil : Flag<["-"], "emit-lowered-sil">,
1291+
HelpText<"Emit lowered SIL file(s)">, ModeOpt;
12901292
def emit_sib : Flag<["-"], "emit-sib">,
12911293
HelpText<"Emit serialized AST + canonical SIL file(s)">, ModeOpt;
12921294
def emit_sibgen : Flag<["-"], "emit-sibgen">,

lib/Basic/FileTypes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ bool file_types::isTextual(ID Id) {
9393
switch (Id) {
9494
case file_types::TY_Swift:
9595
case file_types::TY_SIL:
96+
case file_types::TY_LoweredSIL:
9697
case file_types::TY_Dependencies:
9798
case file_types::TY_Assembly:
9899
case file_types::TY_ASTDump:
@@ -160,6 +161,7 @@ bool file_types::isAfterLLVM(ID Id) {
160161
case file_types::TY_ImportedModules:
161162
case file_types::TY_TBD:
162163
case file_types::TY_SIL:
164+
case file_types::TY_LoweredSIL:
163165
case file_types::TY_Dependencies:
164166
case file_types::TY_ASTDump:
165167
case file_types::TY_RawSIL:
@@ -211,6 +213,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
211213
switch (Id) {
212214
case file_types::TY_Swift:
213215
case file_types::TY_SIL:
216+
case file_types::TY_LoweredSIL:
214217
case file_types::TY_RawSIL:
215218
case file_types::TY_SIB:
216219
case file_types::TY_RawSIB:
@@ -274,6 +277,7 @@ bool file_types::isProducedFromDiagnostics(ID Id) {
274277
return true;
275278
case file_types::TY_Swift:
276279
case file_types::TY_SIL:
280+
case file_types::TY_LoweredSIL:
277281
case file_types::TY_RawSIL:
278282
case file_types::TY_SIB:
279283
case file_types::TY_RawSIB:

lib/Driver/Driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,10 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
11601160
OI.CompilerOutputType = file_types::TY_RawSIL;
11611161
break;
11621162

1163+
case options::OPT_emit_lowered_sil:
1164+
OI.CompilerOutputType = file_types::TY_LoweredSIL;
1165+
break;
1166+
11631167
case options::OPT_emit_sib:
11641168
OI.CompilerOutputType = file_types::TY_SIB;
11651169
break;
@@ -1619,6 +1623,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
16191623
switch (InputType) {
16201624
case file_types::TY_Swift:
16211625
case file_types::TY_SIL:
1626+
case file_types::TY_LoweredSIL:
16221627
case file_types::TY_SIB: {
16231628
// Source inputs always need to be compiled.
16241629
assert(file_types::isPartOfSwiftCompilation(InputType));

lib/Driver/ToolChains.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,8 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
708708
return "-emit-silgen";
709709
case file_types::TY_SIL:
710710
return "-emit-sil";
711+
case file_types::TY_LoweredSIL:
712+
return "-emit-lowered-sil";
711713
case file_types::TY_RawSIB:
712714
return "-emit-sibgen";
713715
case file_types::TY_SIB:
@@ -1008,6 +1010,7 @@ ToolChain::constructInvocation(const BackendJobAction &job,
10081010
case file_types::TY_RawSIL:
10091011
case file_types::TY_RawSIB:
10101012
case file_types::TY_SIL:
1013+
case file_types::TY_LoweredSIL:
10111014
case file_types::TY_SIB:
10121015
case file_types::TY_PCH:
10131016
case file_types::TY_ClangModuleFile:

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ ArgsToFrontendOptionsConverter::determineRequestedAction(const ArgList &args) {
547547
return FrontendOptions::ActionType::EmitSIL;
548548
if (Opt.matches(OPT_emit_silgen))
549549
return FrontendOptions::ActionType::EmitSILGen;
550+
if (Opt.matches(OPT_emit_lowered_sil))
551+
return FrontendOptions::ActionType::EmitLoweredSIL;
550552
if (Opt.matches(OPT_emit_sib))
551553
return FrontendOptions::ActionType::EmitSIB;
552554
if (Opt.matches(OPT_emit_sibgen))

lib/Frontend/FrontendOptions.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
4747
return false;
4848
case ActionType::EmitSILGen:
4949
case ActionType::EmitSIL:
50+
case ActionType::EmitLoweredSIL:
5051
case ActionType::EmitSIBGen:
5152
case ActionType::EmitSIB:
5253
case ActionType::EmitModuleOnly:
@@ -113,6 +114,7 @@ bool FrontendOptions::doesActionRequireSwiftStandardLibrary(ActionType action) {
113114
case ActionType::DumpTypeRefinementContexts:
114115
case ActionType::EmitSILGen:
115116
case ActionType::EmitSIL:
117+
case ActionType::EmitLoweredSIL:
116118
case ActionType::EmitModuleOnly:
117119
case ActionType::MergeModules:
118120
case ActionType::EmitSIBGen:
@@ -158,6 +160,7 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
158160
case ActionType::DumpTypeRefinementContexts:
159161
case ActionType::EmitSILGen:
160162
case ActionType::EmitSIL:
163+
case ActionType::EmitLoweredSIL:
161164
case ActionType::EmitModuleOnly:
162165
case ActionType::MergeModules:
163166
case ActionType::EmitSIBGen:
@@ -200,6 +203,7 @@ bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
200203
case ActionType::DumpTypeRefinementContexts:
201204
case ActionType::EmitSILGen:
202205
case ActionType::EmitSIL:
206+
case ActionType::EmitLoweredSIL:
203207
case ActionType::EmitModuleOnly:
204208
case ActionType::MergeModules:
205209
case ActionType::EmitSIBGen:
@@ -252,6 +256,7 @@ bool FrontendOptions::supportCompilationCaching(ActionType action) {
252256
case ActionType::EmitObject:
253257
case ActionType::EmitSILGen:
254258
case ActionType::EmitSIL:
259+
case ActionType::EmitLoweredSIL:
255260
case ActionType::EmitModuleOnly:
256261
case ActionType::EmitSIBGen:
257262
case ActionType::EmitSIB:
@@ -315,6 +320,9 @@ FrontendOptions::formatForPrincipalOutputFileForAction(ActionType action) {
315320
case ActionType::EmitSIL:
316321
return TY_SIL;
317322

323+
case ActionType::EmitLoweredSIL:
324+
return TY_LoweredSIL;
325+
318326
case ActionType::EmitSIBGen:
319327
return TY_RawSIB;
320328

@@ -387,6 +395,7 @@ bool FrontendOptions::canActionEmitDependencies(ActionType action) {
387395
case ActionType::EmitPCH:
388396
case ActionType::EmitSILGen:
389397
case ActionType::EmitSIL:
398+
case ActionType::EmitLoweredSIL:
390399
case ActionType::EmitSIBGen:
391400
case ActionType::EmitSIB:
392401
case ActionType::EmitIRGen:
@@ -431,6 +440,7 @@ bool FrontendOptions::canActionEmitReferenceDependencies(ActionType action) {
431440
case ActionType::EmitPCH:
432441
case ActionType::EmitSILGen:
433442
case ActionType::EmitSIL:
443+
case ActionType::EmitLoweredSIL:
434444
case ActionType::EmitSIBGen:
435445
case ActionType::EmitSIB:
436446
case ActionType::EmitIRGen:
@@ -475,6 +485,7 @@ bool FrontendOptions::canActionEmitModuleSummary(ActionType action) {
475485
case ActionType::PrintFeature:
476486
return false;
477487
case ActionType::EmitSIL:
488+
case ActionType::EmitLoweredSIL:
478489
case ActionType::EmitSIB:
479490
case ActionType::EmitIRGen:
480491
case ActionType::EmitIR:
@@ -515,6 +526,7 @@ bool FrontendOptions::canActionEmitClangHeader(ActionType action) {
515526
case ActionType::EmitModuleOnly:
516527
case ActionType::EmitSILGen:
517528
case ActionType::EmitSIL:
529+
case ActionType::EmitLoweredSIL:
518530
case ActionType::EmitSIBGen:
519531
case ActionType::EmitSIB:
520532
case ActionType::EmitIRGen:
@@ -557,6 +569,7 @@ bool FrontendOptions::canActionEmitLoadedModuleTrace(ActionType action) {
557569
case ActionType::EmitPCH:
558570
case ActionType::EmitSILGen:
559571
case ActionType::EmitSIL:
572+
case ActionType::EmitLoweredSIL:
560573
case ActionType::EmitSIBGen:
561574
case ActionType::EmitSIB:
562575
case ActionType::EmitIRGen:
@@ -599,6 +612,7 @@ bool FrontendOptions::canActionEmitModuleSemanticInfo(ActionType action) {
599612
case ActionType::PrintVersion:
600613
case ActionType::PrintFeature:
601614
case ActionType::EmitSIL:
615+
case ActionType::EmitLoweredSIL:
602616
case ActionType::EmitSIBGen:
603617
case ActionType::EmitSIB:
604618
case ActionType::EmitIRGen:
@@ -647,6 +661,7 @@ bool FrontendOptions::canActionEmitConstValues(ActionType action) {
647661
case ActionType::EmitPCH:
648662
case ActionType::EmitSILGen:
649663
case ActionType::EmitSIL:
664+
case ActionType::EmitLoweredSIL:
650665
case ActionType::EmitSIBGen:
651666
case ActionType::EmitSIB:
652667
case ActionType::EmitIRGen:
@@ -688,6 +703,7 @@ bool FrontendOptions::canActionEmitModule(ActionType action) {
688703
case ActionType::MergeModules:
689704
case ActionType::EmitModuleOnly:
690705
case ActionType::EmitSIL:
706+
case ActionType::EmitLoweredSIL:
691707
case ActionType::EmitSIBGen:
692708
case ActionType::EmitSIB:
693709
case ActionType::EmitIRGen:
@@ -735,6 +751,7 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
735751
case ActionType::MergeModules:
736752
case ActionType::EmitModuleOnly:
737753
case ActionType::EmitSIL:
754+
case ActionType::EmitLoweredSIL:
738755
case ActionType::EmitSIB:
739756
case ActionType::EmitIRGen:
740757
case ActionType::EmitIR:
@@ -777,6 +794,7 @@ bool FrontendOptions::canActionEmitAPIDescriptor(ActionType action) {
777794
case ActionType::MergeModules:
778795
case ActionType::EmitModuleOnly:
779796
case ActionType::EmitSIL:
797+
case ActionType::EmitLoweredSIL:
780798
case ActionType::EmitSIB:
781799
case ActionType::EmitIRGen:
782800
case ActionType::EmitIR:
@@ -804,6 +822,7 @@ bool FrontendOptions::doesActionProduceOutput(ActionType action) {
804822
case ActionType::EmitPCH:
805823
case ActionType::EmitSILGen:
806824
case ActionType::EmitSIL:
825+
case ActionType::EmitLoweredSIL:
807826
case ActionType::EmitSIBGen:
808827
case ActionType::EmitSIB:
809828
case ActionType::EmitModuleOnly:
@@ -862,6 +881,7 @@ bool FrontendOptions::doesActionProduceTextualOutput(ActionType action) {
862881
case ActionType::EmitImportedModules:
863882
case ActionType::EmitSILGen:
864883
case ActionType::EmitSIL:
884+
case ActionType::EmitLoweredSIL:
865885
case ActionType::EmitAssembly:
866886
case ActionType::EmitIRGen:
867887
case ActionType::EmitIR:
@@ -901,6 +921,7 @@ bool FrontendOptions::doesActionGenerateSIL(ActionType action) {
901921
case ActionType::EmitSILGen:
902922
case ActionType::EmitSIBGen:
903923
case ActionType::EmitSIL:
924+
case ActionType::EmitLoweredSIL:
904925
case ActionType::EmitSIB:
905926
case ActionType::EmitModuleOnly:
906927
case ActionType::MergeModules:
@@ -938,6 +959,7 @@ bool FrontendOptions::doesActionGenerateIR(ActionType action) {
938959
case ActionType::EmitPCH:
939960
case ActionType::EmitSILGen:
940961
case ActionType::EmitSIL:
962+
case ActionType::EmitLoweredSIL:
941963
case ActionType::EmitSIBGen:
942964
case ActionType::EmitSIB:
943965
case ActionType::EmitImportedModules:
@@ -981,6 +1003,7 @@ bool FrontendOptions::doesActionBuildModuleFromInterface(ActionType action) {
9811003
case ActionType::EmitPCH:
9821004
case ActionType::EmitSILGen:
9831005
case ActionType::EmitSIL:
1006+
case ActionType::EmitLoweredSIL:
9841007
case ActionType::EmitSIBGen:
9851008
case ActionType::EmitSIB:
9861009
case ActionType::EmitImportedModules:

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ static bool performAction(CompilerInstance &Instance,
12791279
case FrontendOptions::ActionType::EmitSILGen:
12801280
case FrontendOptions::ActionType::EmitSIBGen:
12811281
case FrontendOptions::ActionType::EmitSIL:
1282+
case FrontendOptions::ActionType::EmitLoweredSIL:
12821283
case FrontendOptions::ActionType::EmitSIB:
12831284
case FrontendOptions::ActionType::EmitModuleOnly:
12841285
case FrontendOptions::ActionType::MergeModules:
@@ -1748,6 +1749,10 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
17481749

17491750
runSILLoweringPasses(*SM);
17501751

1752+
// If we are asked to emit lowered SIL, dump it now and return.
1753+
if (Action == FrontendOptions::ActionType::EmitLoweredSIL)
1754+
return writeSIL(*SM, PSPs, Instance, Invocation.getSILOptions());
1755+
17511756
// Cancellation check after SILLowering.
17521757
if (Instance.isCancellationRequested())
17531758
return true;

test/Concurrency/hoptomainactorifneeded.swift

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-silgen %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-ir %s | %FileCheck -check-prefix=IR %s
2+
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-lowered-sil %s | %FileCheck -check-prefix=LOWERED %s
33

44
// READ THIS: This test validates that basic lowering of hop to main actor if
55
// needed works. For fuller tests that validate that things actually hop, see
@@ -26,40 +26,28 @@
2626

2727
// Check that we actually emit the thunk and call taskRunOnMainActor.
2828
//
29-
// IR-LABEL: define linkonce_odr hidden swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTH"(ptr %0, ptr %1)
30-
// IR-NEXT: entry:
31-
// IR-NEXT: call swiftcc void @"$ss19_taskRunOnMainActor9operationyyyScMYcc_tF"(ptr %0, ptr %1)
32-
// IR-NEXT: ret void
33-
// IR-NEXT: }
34-
35-
// Test Closure. We just hop onto the main actor.
36-
// IR-LABEL: define hidden swifttailcc void @"$s22hoptomainactorifneeded11testClosureyyYaF"(ptr swiftasync %0)
37-
// IR: musttail call swifttailcc void @swift_task_switch(ptr swiftasync {{%.*}}, ptr @"$s22hoptomainactorifneeded11testClosureyyYaFTY0_",
38-
39-
// After we hop onto the main actor, we store the partial apply forwarder to the
40-
// hop to main actor closure.
41-
//
42-
// IR: define internal swifttailcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTY0_"(ptr swiftasync [[ASYNC_CONTEXT:%.*]])
43-
// IR: %async.ctx.frameptr = getelementptr inbounds i8, ptr [[ASYNC_CONTEXT]], i32 16
44-
// IR: [[FUNC1:%.*]] = getelementptr inbounds %"$s22hoptomainactorifneeded11testClosureyyYaF.Frame", ptr %async.ctx.frameptr, i32 0, i32 0
45-
// IR: [[FUNC2:%.*]] = getelementptr inbounds { %objc_block, %swift.function }, ptr [[FUNC1]], i32 0, i32 1
46-
// IR: [[FUNC3:%.*]] = getelementptr inbounds %swift.function, ptr [[FUNC2]], i32 0, i32 0
47-
// IR: store ptr @"$s22hoptomainactorifneeded11testClosureyyYaFTTHTA", ptr [[FUNC3]]
48-
49-
// In the partial apply forwarder, we need to call the actual hop to main actor
50-
// thunk.
51-
//
52-
// IR: define internal swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTHTA"(ptr swiftself [[FRAME:%.*]])
53-
// IR-NEXT: entry:
54-
// IR-NEXT: [[FRAME_GEP:%.*]] = getelementptr inbounds <{ %swift.refcounted, %swift.function }>, ptr [[FRAME]], i32 0, i32 1
55-
// IR-NEXT: [[FUNC2:%.*]] = getelementptr inbounds %swift.function, ptr [[FRAME_GEP]], i32 0, i32 0
56-
// IR-NEXT: [[FUNC2_LOADED:%.*]] = load ptr, ptr [[FUNC2]]
57-
// IR-NEXT: [[DATA:%.*]] = getelementptr inbounds %swift.function, ptr [[FRAME_GEP]]
58-
// IR-NEXT: [[DATA_LOADED:%.*]] = load ptr, ptr [[DATA]]
59-
// IR-NEXT: tail call swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTH"(ptr [[FUNC2_LOADED]], ptr [[DATA_LOADED]])
60-
// IR-NEXT: ret void
61-
// IR-NEXT: }
62-
29+
// LOWERED-LABEL: sil shared [thunk] @$s22hoptomainactorifneeded11testClosureyyYaFTTH : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> () {
30+
// LOWERED: bb0([[ARG:%.*]] : $@callee_guaranteed () -> ()):
31+
// LOWERED: [[FUNC:%.*]] = function_ref @$ss19_taskRunOnMainActor9operationyyyScMYcc_tF : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
32+
// LOWERED: apply [[FUNC]]([[ARG]])
33+
// LOWERED: } // end sil function '$s22hoptomainactorifneeded11testClosureyyYaFTTH
34+
35+
// testClosure.
36+
// LOWERED-LABEL: sil hidden @$s22hoptomainactorifneeded11testClosureyyYaF : $@convention(thin) @async () -> () {
37+
// LOWERED: [[CLOSURE:%.*]] = function_ref @$s22hoptomainactorifneeded11testClosureyyYaFyyScMYccfU_ : $@convention(thin) () -> ()
38+
// LOWERED: [[THICK_CLOSURE:%.*]] = thin_to_thick_function [[CLOSURE]]
39+
// LOWERED: [[THUNK:%.*]] = function_ref @$s22hoptomainactorifneeded11testClosureyyYaFTTH : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
40+
// LOWERED: [[THUNKED_CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[THICK_CLOSURE]])
41+
// LOWERED: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage
42+
// LOWERED: [[PROJECT_BLOCK_STORAGE:%.*]] = project_block_storage [[BLOCK_STORAGE]]
43+
// LOWERED: store [[THUNKED_CLOSURE]] to [[PROJECT_BLOCK_STORAGE]]
44+
// LOWERED: [[THUNK_THUNK_CALLEE:%.*]] = function_ref @$sIeg_IeyB_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed () -> ()) -> ()
45+
// LOWERED: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] : $*@block_storage @callee_guaranteed () -> (), invoke [[THUNK_THUNK_CALLEE]]
46+
// LOWERED: [[FINISHED_BLOCK:%.*]] = copy_block [[BLOCK]]
47+
// LOWERED: [[OPT_BLOCK:%.*]] = enum $Optional<@convention(block) () -> ()>, #Optional.some!enumelt, [[FINISHED_BLOCK]]
48+
// LOWERED: [[USE_CLOSURE_CALLEE:%.*]] = function_ref @useClosure : $@convention(c) (Optional<@convention(block) () -> ()>) -> ()
49+
// LOWERED: apply [[USE_CLOSURE_CALLEE]]([[OPT_BLOCK]])
50+
// LOWERED: } // end sil function '$s22hoptomainactorifneeded11testClosureyyYaF'
6351
@MainActor
6452
func testClosure() async {
6553
useClosure {

test/Frontend/lowered_sil.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-frontend -o - -emit-lowered-sil %s | %FileCheck %s
2+
3+
// CHECK: sil_stage lowered
4+
5+
func test() {
6+
}

0 commit comments

Comments
 (0)