Skip to content

[AST] Remove Builtin.copy. #73443

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 1 commit into from
May 6, 2024
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
8 changes: 0 additions & 8 deletions include/swift/AST/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,6 @@ BUILTIN_SIL_OPERATION(HopToActor, "hopToActor", None)
/// Returns the number of items in a pack.
BUILTIN_SIL_OPERATION(PackLength, "packLength", Special)

/// TODO: Remove. Only exists to avoid a reverse condfail.
/// rdar://127516085 (Complete removal of Builtin.copy)
///
/// copy: <T>(T) -> T
///
/// Creates a copy of the source at the destination.
BUILTIN_SIL_OPERATION(Copy, "copy", Special)

// BUILTIN_RUNTIME_CALL - A call into a runtime function.
// These functions accept a single argument of any type.
#ifndef BUILTIN_RUNTIME_CALL
Expand Down
1 change: 0 additions & 1 deletion include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroupWithExecutor, 0, "Task create in t
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroup, 0, "Task create in discarding task group builtin, accounting for the Void return type")
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskWithExecutor, 0, "Task create builtin with extra executor preference")
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroupWithExecutor, 0, "Task create in discarding task group with extra executor preference")
BASELINE_LANGUAGE_FEATURE(BuiltinCopy, 0, "Builtin.copy()")
BASELINE_LANGUAGE_FEATURE(BuiltinStackAlloc, 0, "Builtin.stackAlloc")
LANGUAGE_FEATURE(BuiltinUnprotectedStackAlloc, 0, "Builtin.unprotectedStackAlloc")
LANGUAGE_FEATURE(BuiltinAllocVector, 0, "Builtin.allocVector")
Expand Down
13 changes: 0 additions & 13 deletions lib/AST/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,6 @@ static ValueDecl *getDestroyArrayOperation(ASTContext &ctx, Identifier id) {
_void);
}

static ValueDecl *getCopyOperation(ASTContext &ctx, Identifier id) {
return getBuiltinFunction(ctx, id, _thin,
_generics(_unrestricted,
_conformsTo(_typeparam(0), _copyable),
_conformsTo(_typeparam(0), _escapable)),
_parameters(_typeparam(0)), _typeparam(0));
}

static ValueDecl *getAssumeAlignment(ASTContext &ctx, Identifier id) {
// This is always "(Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer"
return getBuiltinFunction(ctx, id, _thin, _parameters(_rawPointer, _word),
Expand Down Expand Up @@ -2786,11 +2778,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
if (!Types.empty()) return nullptr;
return getEndUnpairedAccessOperation(Context, Id);

case BuiltinValueKind::Copy:
if (!Types.empty())
return nullptr;
return getCopyOperation(Context, Id);

case BuiltinValueKind::AssumeAlignment:
if (!Types.empty())
return nullptr;
Expand Down
17 changes: 0 additions & 17 deletions lib/SILGen/SILGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2027,23 +2027,6 @@ static ManagedValue emitBuiltinAddressOfRawLayout(SILGenFunction &SGF,
return ManagedValue::forObjectRValueWithoutOwnership(bi);
}

/// TODO: Remove. Only exists to avoid a reverse condfail.
/// rdar://127516085 (Complete removal of Builtin.copy)
static ManagedValue emitBuiltinCopy(SILGenFunction &SGF, SILLocation loc,
SubstitutionMap subs,
ArrayRef<ManagedValue> args, SGFContext C) {
// Builtin.copy has no uses in current/future swiftinterfaces. It has a
// single use in old swiftinterfaces:
// func _copy<T>(_ t: T) -> T {
// Builtin.copy(t)
// }
// It is sufficient to have the builtin pass the value through. When the
// return is emitted, a copy will be made.
assert(args.size() == 1 && "not two arguments!?");
return ManagedValue::forOwnedAddressRValue(args[0].getValue(),
CleanupHandle::invalid());
}

std::optional<SpecializedEmitter>
SpecializedEmitter::forDecl(SILGenModule &SGM, SILDeclRef function) {
// Only consider standalone declarations in the Builtin module.
Expand Down
16 changes: 0 additions & 16 deletions test/stdlib/LifetimeManagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,3 @@ suite.test("move") {
}

runAllTests()

// TODO: Remove. Only exists to avoid a reverse condfail.
// rdar://127516085 (Complete removal of Builtin.copy)
func _oldCopy<T>(_ value: T) -> T {
#if $BuiltinCopy
Builtin.copy(value)
#else
value
#endif
}

suite.test("_oldCopy") {
let k = Klass()
expectTrue(k === _oldCopy(k))
}