-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
IRGenLLVM IR generationLLVM IR generationasync & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaregenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsscript modeFlag: Specific to script mode compilationFlag: Specific to script mode compilationswift 6.0
Description
Description
No response
Reproduction
func foo<each S>(_ s: repeat each S) async {}
await foo(true)
Stack dump
Instruction missing on-stack pack metadata cleanups!
%14 = apply %12<Pack{Bool}>(%3) : $@convention(thin) @async <each τ_0_0> (@pack_guaranteed Pack{repeat each τ_0_0}) -> ()
In function:
// async_Main
sil private @async_Main : $@convention(thin) @async () -> () {
bb0:
%0 = builtin "buildMainActorExecutorRef"() : $Builtin.Executor // user: %1
%1 = enum $Optional<Builtin.Executor>, #Optional.some!enumelt, %0 : $Builtin.Executor // user: %15
%2 = alloc_pack_metadata $()
%3 = alloc_pack $Pack{Bool} // users: %14, %10
%4 = alloc_stack $Bool // users: %7, %10
%5 = integer_literal $Builtin.Int1, -1 // user: %6
%6 = struct $Bool (%5 : $Builtin.Int1) // user: %7
store %6 to %4 : $*Bool // id: %7
%8 = scalar_pack_index 0 of $Pack{Bool} // user: %10
%9 = alloc_pack_metadata $()
pack_element_set %4 : $*Bool into %8 of %3 : $*Pack{Bool} // id: %10
%11 = alloc_pack_metadata $()
// function_ref foo<each A>(_:)
%12 = function_ref @$s4test3fooyyxxQpYaRvzlF : $@convention(thin) @async <each τ_0_0> (@pack_guaranteed Pack{repeat each τ_0_0}) -> () // user: %14
%13 = alloc_pack_metadata $()
%14 = apply %12<Pack{Bool}>(%3) : $@convention(thin) @async <each τ_0_0> (@pack_guaranteed Pack{repeat each τ_0_0}) -> ()
hop_to_executor %1 : $Optional<Builtin.Executor> // id: %15
%16 = integer_literal $Builtin.Int32, 0 // user: %17
%17 = struct $Int32 (%16 : $Builtin.Int32) // user: %19
// function_ref exit
%18 = function_ref @exit : $@convention(c) (Int32) -> Never // user: %19
%19 = apply %18(%17) : $@convention(c) (Int32) -> Never
unreachable // id: %20
} // end sil function 'async_Main'
Allocated the following on-stack pack metadata:
- Metadata Pack: %4 = alloca [1 x ptr], align 8
define internal swifttailcc void @async_Main(ptr swiftasync %0) #0 {
entry:
%1 = alloca ptr, align 8
%2 = alloca [1 x ptr], align 8
%3 = alloca %TSb, align 1
%4 = alloca [1 x ptr], align 8
%"alloca point" = alloca i1, align 1
%5 = call token @llvm.coro.id.async(i32 16, i32 16, i32 0, ptr @async_MainTu)
%6 = call ptr @llvm.coro.begin(token %5, ptr null)
store ptr %0, ptr %1, align 8
%"earliest insert point" = alloca i1, align 1
%7 = call swiftcc %swift.executor @swift_task_getMainExecutor() #8
%8 = extractvalue %swift.executor %7, 0
%9 = extractvalue %swift.executor %7, 1
call void @llvm.lifetime.start.p0(i64 8, ptr %2)
call void @llvm.lifetime.start.p0(i64 1, ptr %3)
%._value = getelementptr inbounds %TSb, ptr %3, i32 0, i32 0
store i8 1, ptr %._value, align 1
%10 = getelementptr inbounds ptr, ptr %2, i64 0
store ptr %3, ptr %10, align 8
%11 = load i32, ptr getelementptr inbounds (%swift.async_func_pointer, ptr @"$s4test3fooyyxxQpYaRvzlFTu", i32 0, i32 1), align 8
%12 = zext i32 %11 to i64
%13 = call swiftcc ptr @swift_task_alloc(i64 %12) #3
call void @llvm.lifetime.start.p0(i64 -1, ptr %13)
call void @llvm.lifetime.start.p0(i64 8, ptr %4)
%14 = getelementptr inbounds [1 x ptr], ptr %4, i32 0, i32 0
store ptr @"$sSbN", ptr %14, align 8
%15 = load ptr, ptr %1, align 8
%16 = getelementptr inbounds <{ ptr, ptr }>, ptr %13, i32 0, i32 0
store ptr %15, ptr %16, align 8
%17 = call ptr @llvm.coro.async.resume()
%18 = getelementptr inbounds <{ ptr, ptr }>, ptr %13, i32 0, i32 1
store ptr %17, ptr %18, align 8
%19 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0s(i32 0, ptr %17, ptr @__swift_async_resume_project_context, ptr @async_Main.0, ptr @"$s4test3fooyyxxQpYaRvzlF", ptr %13, ptr %2, i64 1, ptr %4)
%20 = extractvalue { ptr } %19, 0
%21 = call ptr @__swift_async_resume_project_context(ptr %20)
store ptr %21, ptr %1, align 8
call swiftcc void @swift_task_dealloc(ptr %13) #3
call void @llvm.lifetime.end.p0(i64 -1, ptr %13)
}
<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: Instruction resulted in on-stack pack metadata emission but no cleanup instructions were added
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: bin/swift-frontend -debug-diagnostic-names -emit-irgen -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Users/mac/Desktop/test.swift
1. Swift version 6.0-dev (LLVM 48dc0c6fa01ce9e, Swift 19fbe5b33d423d1)
2. Compiling with effective version 5.10
3. While evaluating request IRGenRequest(IR Generation for module test)
4. While emitting IR SIL function "@async_Main".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x0000000112c5c658 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1 swift-frontend 0x0000000112c5aaa5 llvm::sys::RunSignalHandlers() + 85
2 swift-frontend 0x0000000112c5ccae SignalHandler(int) + 270
3 libsystem_platform.dylib 0x00007ff8058ea37d _sigtramp + 29
4 libsystem_platform.dylib 0x0000600000380900 _sigtramp + 18446708923607639456
5 libsystem_c.dylib 0x00007ff8057dba4d abort + 126
6 swift-frontend 0x000000010a0af43d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_42::operator()(char const*, bool) const + 957
7 swift-frontend 0x000000010a0af078 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_2::operator()(void*, char const*, bool) const + 56
8 swift-frontend 0x000000010a0af030 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_2::__invoke(void*, char const*, bool) + 48
9 swift-frontend 0x0000000112bbe880 llvm::report_fatal_error(llvm::Twine const&, bool) + 352
10 swift-frontend 0x0000000112bbe719 llvm::report_fatal_error(char const*, bool) + 41
11 swift-frontend 0x000000010abee169 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2201
12 swift-frontend 0x000000010abe2fae (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 2798
13 swift-frontend 0x000000010abe23e8 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 328
14 swift-frontend 0x000000010a873cc8 swift::irgen::IRGenerator::emitLazyDefinitions() + 3976
15 swift-frontend 0x000000010aad2b98 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 1592
16 swift-frontend 0x000000010abe1063 swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 163
17 swift-frontend 0x000000010abe0f28 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 40
18 swift-frontend 0x000000010aafe078 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 264
19 swift-frontend 0x000000010aafdf58 swift::IRGenRequest::OutputType swift::Evaluator::operator()<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'(), (void*)0>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 40
20 swift-frontend 0x000000010aad5244 swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest) + 36
21 swift-frontend 0x000000010aad42f9 swift::performIRGeneration(swift::ModuleDecl*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::GlobalVariable**) + 665
22 swift-frontend 0x000000010a09c1ff generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 559
23 swift-frontend 0x000000010a09623c performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2236
24 swift-frontend 0x000000010a0952ae swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 382
25 swift-frontend 0x000000010a0c6813 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29::operator()(swift::CompilerInstance&) const + 147
26 swift-frontend 0x000000010a0c676d bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29>(long, swift::CompilerInstance&) + 29
27 swift-frontend 0x000000010a0c5b31 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 33
28 swift-frontend 0x000000010a0c4a58 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 392
29 swift-frontend 0x000000010a0bd155 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1349
30 swift-frontend 0x000000010a0986f6 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 262
31 swift-frontend 0x000000010a0970da swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2794
32 swift-frontend 0x0000000109f45daa run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 2410
33 swift-frontend 0x0000000109f449e7 swift::mainEntry(int, char const**) + 1543
34 swift-frontend 0x0000000109f43f92 main + 34
35 dyld 0x00007ff8055343a6 start + 1942
Abort trap: 6
Expected behavior
Successful compilation
Environment
Swift version 6.0-dev (LLVM 48dc0c6fa01ce9e, Swift 19fbe5b)
Additional information
No response
Metadata
Metadata
Assignees
Labels
IRGenLLVM IR generationLLVM IR generationasync & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaregenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsscript modeFlag: Specific to script mode compilationFlag: Specific to script mode compilationswift 6.0