Skip to content

[embedded][Concurrency] Fix missing swift_deletedAsyncMethodError #79706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,15 @@ FUNCTION(DeletedMethodError, Swift, swift_deletedMethodError, C_CC, AlwaysAvaila
EFFECT(NoEffect),
UNKNOWN_MEMEFFECTS)

// void swift_deletedAsyncMethodError();
FUNCTION(DeletedAsyncMethodError, _Concurrency, swift_deletedAsyncMethodError, SwiftAsyncCC,
ConcurrencyAvailability,
RETURNS(VoidTy),
ARGS(),
ATTRS(NoUnwind),
EFFECT(Concurrency),
UNKNOWN_MEMEFFECTS)

FUNCTION(AllocError, Swift, swift_allocError, SwiftCC, AlwaysAvailable,
RETURNS(ErrorPtrTy, OpaquePtrTy),
ARGS(TypeMetadataPtrTy, WitnessTablePtrTy, OpaquePtrTy, Int1Ty),
Expand Down
8 changes: 6 additions & 2 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3863,8 +3863,11 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity,
LinkInfo link = LinkInfo::get(*this, entity, forDefinition);

// Clang may have defined the variable already.
if (auto existing = Module.getNamedGlobal(link.getName()))
return getElementBitCast(existing, defaultType);
if (auto existing = Module.getNamedGlobal(link.getName())) {
auto var = getElementBitCast(existing, defaultType);
GlobalVars[entity] = var;
return var;
}

const LazyConstantInitializer *lazyInitializer = nullptr;
std::optional<ConstantInitBuilder> lazyBuilder;
Expand Down Expand Up @@ -4003,6 +4006,7 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity) {
getAddrOfLLVMVariable(entity, ConstantInit(), DebugTypeInfo());

auto entry = GlobalVars[entity];
assert(entry);

/// Returns a direct reference.
auto direct = [&]() -> ConstantReference {
Expand Down
50 changes: 50 additions & 0 deletions test/embedded/concurrency-deleted-method.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name main %s -emit-ir | %FileCheck --check-prefix=CHECK-IR %s
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name main %s -c -o %t/a.o
// RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos -lswift_Concurrency -lswift_ConcurrencyDefaultExecutor -dead_strip
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx
// REQUIRES: swift_feature_Embedded

import _Concurrency

actor MyActor {
var value: Int = 42
func foo() async {
print("value: \(value)")
}

func thisIsUnused() async {
print("unused")
}
}

@main struct Main {
static func main() async {
let n = MyActor()
await n.foo()
}
}

// CHECK-IR: @swift_deletedAsyncMethodErrorTu =
// CHECK-IR: @"$e4main7MyActorCN" = global <{ ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }> <{
// CHECK-IR-SAME: ptr null,
// CHECK-IR-SAME: ptr @"$e4main7MyActorCfD",
// CHECK-IR-SAME: ptr null,
// CHECK-IR-SAME: ptr @swift_deletedMethodError,
// CHECK-IR-SAME: ptr @swift_deletedMethodError,
// CHECK-IR-SAME: ptr @swift_deletedMethodError,
// CHECK-IR-SAME: ptr @"$e4main7MyActorC3fooyyYaFTu",
// CHECK-IR-SAME: ptr @got.swift_deletedAsyncMethodErrorTu,
// CHECK-IR-SAME: ptr @"$e4main7MyActorCACycfC"
// CHECK-IR-SAME: }>, align 8

// CHECK-IR-NOT: $e4main7MyActorC12thisIsUnusedyyYaF

// CHECK-IR: define swifttailcc void @swift_deletedAsyncMethodError(ptr swiftasync %0)

// CHECK: value: 42