Skip to content

Commit 6d042ae

Browse files
authored
Embedded WASI: fix storeEnumTagSinglePayload type mismatch (#83480)
This is a follow up to #80862, where `storeEnumTagSinglePayload` in a special implementation of `ResultTypeInfo` for Embedded Swift had a mismatching number of arguments. The actual declaration of it in `ABI/ValueWitness.def` clearly includes one more argument. ``` /// void (*storeEnumTagSinglePayload)(T* enum, UINT_TYPE whichCase, /// UINT_TYPE emptyCases, M *self); /// Given uninitialized memory for an instance of a single payload enum with a /// payload of this witness table's type (e.g Optional<ThisType>), store the /// tag. FUNCTION_VALUE_WITNESS(storeEnumTagSinglePayload, StoreEnumTagSinglePayload, VOID_TYPE, (MUTABLE_VALUE_TYPE, UINT_TYPE, UINT_TYPE, TYPE_TYPE)) ``` This function type mismatch is illegal when targeting Wasm and traps at run time. Similarly to #80862, we're passing `nullptr` as the newly added argument, which is equivalent to the existing behavior on other platforms. rdar://157219474
1 parent 6987ecd commit 6d042ae

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

include/swift/ABI/Task.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct ResultTypeInfo {
243243
size_t alignMask = 0;
244244
OpaqueValue * (*initializeWithCopy)(OpaqueValue *result, OpaqueValue *src, void *type) = nullptr;
245245
void (*storeEnumTagSinglePayload)(OpaqueValue *v, unsigned whichCase,
246-
unsigned emptyCases) = nullptr;
246+
unsigned emptyCases, void *type) = nullptr;
247247
void (*destroy)(OpaqueValue *, void *) = nullptr;
248248

249249
bool isNull() {
@@ -260,7 +260,7 @@ struct ResultTypeInfo {
260260
}
261261
void vw_storeEnumTagSinglePayload(OpaqueValue *v, unsigned whichCase,
262262
unsigned emptyCases) {
263-
storeEnumTagSinglePayload(v, whichCase, emptyCases);
263+
storeEnumTagSinglePayload(v, whichCase, emptyCases, nullptr);
264264
}
265265
void vw_destroy(OpaqueValue *v) {
266266
destroy(v, nullptr);

include/swift/ABI/TaskOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class ResultTypeInfoTaskOptionRecord : public TaskOptionRecord {
221221

222222
void (*__ptrauth_swift_value_witness_function_pointer(
223223
SpecialPointerAuthDiscriminators::StoreEnumTagSinglePayload)
224-
storeEnumTagSinglePayload)(OpaqueValue *, unsigned, unsigned);
224+
storeEnumTagSinglePayload)(OpaqueValue *, unsigned, unsigned, void *);
225225

226226
void (*__ptrauth_swift_value_witness_function_pointer(
227227
SpecialPointerAuthDiscriminators::Destroy) destroy)(OpaqueValue *, void *);

test/embedded/concurrency-discardingtaskgroup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -target %target-cpu-apple-macos14 -parse-as-library %s -c -o %t/a.o
3-
// 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
2+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library %s -c -o %t/a.o
3+
// RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%module-target-triple %target-clang-resource-dir-opt -lc++abi -lswift_Concurrency %target-swift-default-executor-opt -dead_strip
44
// RUN: %target-run %t/a.out | %FileCheck %s
55

66
// REQUIRES: executable_test
77
// REQUIRES: swift_in_compiler
88
// REQUIRES: optimized_stdlib
9-
// REQUIRES: OS=macosx
9+
// REQUIRES: OS=macosx || OS=wasip1
1010
// REQUIRES: swift_feature_Embedded
1111

1212
import _Concurrency

test/embedded/concurrency-taskgroup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -target %target-cpu-apple-macos14 -parse-as-library %s -c -o %t/a.o
3-
// 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
2+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library %s -c -o %t/a.o
3+
// RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%module-target-triple %target-clang-resource-dir-opt -lc++abi -lswift_Concurrency %target-swift-default-executor-opt -dead_strip
44
// RUN: %target-run %t/a.out | %FileCheck %s
55

66
// REQUIRES: executable_test
77
// REQUIRES: swift_in_compiler
88
// REQUIRES: optimized_stdlib
9-
// REQUIRES: OS=macosx
9+
// REQUIRES: OS=macosx || OS=wasip1
1010
// REQUIRES: swift_feature_Embedded
1111

1212
import _Concurrency

0 commit comments

Comments
 (0)