[silgen] Use Builtin.ImplicitActor instead of Optional<any Actor> to represent the implicit isolated parameter.

NOTE: We are not performing any bitmasking at all now. This is so that we can
transition the code base/tests to expect Builtin.ImplicitActor instead
of Optional<any Actor>.

NOTE: The actual test changes are in the next commit. I did this to make it
easier to review the changes.

This should not have any user visible changes.
This commit is contained in:
Michael Gottesman
2025-08-06 17:01:52 -07:00
parent fe9c21fd87
commit 788abd0b96
16 changed files with 360 additions and 102 deletions

View File

@@ -0,0 +1,38 @@
//===--- ConcurrencyUtils.h -----------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SIL_CONCURRENCYUTILS_H
#define SWIFT_SIL_CONCURRENCYUTILS_H
#include "swift/SIL/SILType.h"
namespace swift {
class SILValue;
class SILBuilder;
class SILLocation;
/// Clear the implicit isolated bits of value.
///
/// \p value must be Builtin.ImplicitActor
///
/// \p finalType if empty, we always return
/// Builtin.ImplicitActor. Otherwise we bitcast to finalType after
/// tieing the lifetime of the result to \p value.
SILValue clearImplicitActorBits(SILBuilder &b, SILLocation loc, SILValue value,
SILType finalType = {});
SILValue setImplicitActorBits(SILBuilder &b, SILLocation loc, SILValue value);
} // namespace swift
#endif

View File

@@ -1330,6 +1330,17 @@ public:
forwardingOwnershipKind));
}
/// Create an unchecked_value_cast when Ownership SSA is enabled and
/// unchecked_bitwise_cast otherwise.
///
/// Intended to be used in utility code that needs to support both Ownership
/// SSA and non-Ownership SSA code.
SILValue emitUncheckedValueCast(SILLocation loc, SILValue op, SILType ty) {
if (hasOwnership())
return createUncheckedValueCast(loc, op, ty);
return createUncheckedBitwiseCast(loc, op, ty);
}
RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref,
SILValue Bits) {
return createRefToBridgeObject(Loc, Ref, Bits, Ref->getOwnershipKind());