Embedded Swift Atomic can cause metadata allocation or locks

Thanks to @kubamracek and his work done here, we can now import Synchronization module in Embedded Swift.

My problem now is the following. This code snippet:

import Synchronization

func test() {
    Atomic(3)
}

compiled with Embedded feature works fine.

But if I add @noLocks to test:

import Synchronization

@_noLocks
@_noAllocation
func test() {
    Atomic(3)
}

it fails with:

"Using type 'Atomic' can cause metadata allocation or locks"

I am compiling it with:

xcrun -toolchain "Swift Development Snapshot" swiftc atomic.swift -Xfrontend -disable-availability-checking -Xllvm -enable-deinit-devirtualizer -enable-experimental-feature Embedded -wmo

and I am using the latest Swift Toolchain (March 18 nightly build)

Note: This is in some way continuation of this topic, but since it doesn't work on Embedded it seems even more intriguing.

1 Like

cc: @Erik_Eckstein

I was convinced that I tried it, but even this basic example:

struct Test: ~Copyable {
}

@_noLocks
@_noAllocation
func test() {
    Test()
}

fails with:

"error: this code performs reference counting operations which can cause locking"

This was fixed here.