Skip to content

Revert "[NoncopyableGenerics] Basic end-to-end testing (without stdlib)." #69649

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define SWIFT_BASIC_LANGOPTIONS_H

#include "swift/Basic/Feature.h"
#include "swift/Basic/FixedBitSet.h"
#include "swift/Basic/FunctionBodySkipping.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/Version.h"
Expand All @@ -29,6 +28,7 @@
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -429,7 +429,7 @@ namespace swift {
bool EnableNewOperatorLookup = false;

/// The set of features that have been enabled.
FixedBitSet<numFeatures(), Feature> Features;
llvm::SmallSet<Feature, 2> Features;

/// Temporary flag to support LLDB's transition to using \c Features.
bool EnableBareSlashRegexLiterals = false;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/SIL/SILType.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ class SILType {
return getSILBoxFieldType(fn).isMoveOnly();
}

bool isBoxedNonCopyableType(const SILFunction &fn) const {
return isBoxedNonCopyableType(&fn);
}

bool isBoxedMoveOnlyWrappedType(const SILFunction *fn) const {
if (!this->is<SILBoxType>())
return false;
Expand Down
11 changes: 3 additions & 8 deletions lib/IRGen/GenReflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ getTypeRefImpl(IRGenModule &IGM,
useFlatUnique = true;
break;

case MangledTypeRefRole::FieldMetadata: {
case MangledTypeRefRole::FieldMetadata:
// We want to keep fields of noncopyable type from being exposed to
// in-process runtime reflection libraries in older Swift runtimes, since
// they more than likely assume they can copy field values, and the language
Expand All @@ -405,16 +405,11 @@ getTypeRefImpl(IRGenModule &IGM,
// noncopyable, use a function to emit the type ref which will look for a
// signal from future runtimes whether they support noncopyable types before
// exposing their metadata to them.
Type contextualTy = type;
if (sig)
contextualTy = sig.getGenericEnvironment()->mapTypeIntoContext(type);

if (contextualTy->isNoncopyable()) {
if (type->isNoncopyable()) {
IGM.IRGen.noteUseOfTypeMetadata(type);
return getTypeRefByFunction(IGM, sig, type);
}
}
LLVM_FALLTHROUGH;
LLVM_FALLTHROUGH;

case MangledTypeRefRole::DefaultAssociatedTypeWitness:
case MangledTypeRefRole::Metadata:
Expand Down
5 changes: 2 additions & 3 deletions lib/SIL/IR/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,8 @@ AllocBoxInst::AllocBoxInst(SILDebugLocation Loc, CanSILBoxType BoxType,
sharedUInt8().AllocBoxInst.reflection = reflection;

// If we have a noncopyable type, always set uses mvoeable value debug info.
auto fieldTy = getSILBoxFieldType(F.getTypeExpansionContext(), BoxType,
F.getModule().Types, 0);
usesMoveableValueDebugInfo |= fieldTy.isMoveOnly();
usesMoveableValueDebugInfo |=
BoxType->getLayout()->getFields()[0].getObjectType().isMoveOnly();

sharedUInt8().AllocBoxInst.usesMoveableValueDebugInfo =
usesMoveableValueDebugInfo;
Expand Down
28 changes: 3 additions & 25 deletions lib/SIL/IR/SILType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,20 +1044,10 @@ SILType::getSingletonAggregateFieldType(SILModule &M,
}

bool SILType::isMoveOnly() const {
// Legacy check.
if (!getASTContext().LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
return getASTType()->isNoncopyable() || isMoveOnlyWrapped();
}

// Anything within the move-only wrapper is move-only.
if (isMoveOnlyWrapped())
// Nominal types are move-only if declared as such.
if (getASTType()->isNoncopyable())
return true;

auto ty = getASTType();

// All kinds of references are copyable.
if (isa<ReferenceStorageType>(ty))
return false;

// TODO: Nonescaping closures ought to be treated as move-only in SIL.
// They aren't marked move-only now, because the necessary move-only passes
Expand All @@ -1070,19 +1060,7 @@ bool SILType::isMoveOnly() const {
return fnTy->isTrivialNoEscape();
}
*/
if (isa<SILFunctionType>(ty))
return false;

// Treat all other SIL-specific types as Copyable.
if (isa<SILBlockStorageType,
SILBoxType,
SILPackType,
SILTokenType>(ty)) {
return false;
}

// Finally, for other ordinary types, ask the AST type.
return ty->isNoncopyable();
return isMoveOnlyWrapped();
}


Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Transforms/AllocBoxToStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ specializeApplySite(SILOptFunctionBuilder &FuncBuilder, ApplySite Apply,
// boxes, convert them from having escaping to having non-escaping
// semantics.
for (unsigned index : PromotedCalleeArgIndices) {
if (F->getArgument(index)->getType().isBoxedNonCopyableType(F)) {
if (F->getArgument(index)->getType().isBoxedNonCopyableType(*F)) {
auto boxType = F->getArgument(index)->getType().castTo<SILBoxType>();
bool isMutable = boxType->getLayout()->getFields()[0].isMutable();
auto checkKind = isMutable ? MarkUnresolvedNonCopyableValueInst::
Expand Down
4 changes: 1 addition & 3 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,7 @@ bool HasNoncopyableAnnotationRequest::evaluate(Evaluator &evaluator, TypeDecl *d

// Handle the legacy '@_moveOnly' attribute
if (decl->getAttrs().hasAttribute<MoveOnlyAttr>()) {
assert(isa<StructDecl>(decl) || isa<EnumDecl>(decl)
|| (ctx.LangOpts.hasFeature(Feature::MoveOnlyClasses)
&& isa<ClassDecl>(decl)));
assert(isa<StructDecl>(decl) || isa<EnumDecl>(decl));
return true;
}

Expand Down
117 changes: 0 additions & 117 deletions test/Interpreter/moveonly_generics.swift

This file was deleted.

Loading