Skip to content

SIL: Remove the incorrect old getTypeLinkage() #70692

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
Jan 4, 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
1 change: 0 additions & 1 deletion include/swift/SIL/FormalLinkage.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ enum class FormalLinkage {

FormalLinkage getDeclLinkage(const ValueDecl *decl);
FormalLinkage getTypeLinkage(CanType formalType);
FormalLinkage getTypeLinkage_correct(CanType formalType);
FormalLinkage getGenericSignatureLinkage(CanGenericSignature signature);
SILLinkage getSILLinkage(FormalLinkage linkage,
ForDefinition_t forDefinition);
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6967,7 +6967,7 @@ llvm::GlobalValue *irgen::emitAsyncFunctionPointer(IRGenModule &IGM,

static FormalLinkage getExistentialShapeLinkage(CanGenericSignature genSig,
CanType shapeType) {
auto typeLinkage = getTypeLinkage_correct(shapeType);
auto typeLinkage = getTypeLinkage(shapeType);
if (typeLinkage == FormalLinkage::Private)
return FormalLinkage::Private;

Expand Down
2 changes: 0 additions & 2 deletions lib/IRGen/Outlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ static bool needsSpecialOwnershipHandling(SILType t) {
return ref->getOwnership() != ReferenceOwnership::Strong;
}

bool isTypeMetadataForLayoutAccessible(SILModule &M, SILType type);

static bool canUseValueWitnessForValueOp(IRGenModule &IGM, SILType T) {
if (!IGM.getSILModule().isTypeMetadataForLayoutAccessible(T))
return false;
Expand Down
18 changes: 2 additions & 16 deletions lib/SIL/IR/SIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ FormalLinkage swift::getGenericSignatureLinkage(CanGenericSignature sig) {
case RequirementKind::Conformance:
case RequirementKind::SameType:
case RequirementKind::Superclass:
switch (getTypeLinkage_correct(CanType(req.getSecondType()))) {
switch (getTypeLinkage(CanType(req.getSecondType()))) {
case FormalLinkage::PublicUnique:
case FormalLinkage::PublicNonUnique:
continue;
Expand All @@ -189,19 +189,6 @@ FormalLinkage swift::getGenericSignatureLinkage(CanGenericSignature sig) {
return linkage;
}

/// Return the formal linkage of the given formal type.
///
/// Note that this function is buggy and generally should not be
/// used in new code; we should migrate all callers to
/// getTypeLinkage_correct and then consolidate them.
FormalLinkage swift::getTypeLinkage(CanType t) {
assert(t->isLegalFormalType());
// Due to a bug, this always returns PublicUnique.
// It's a bit late in the 5.7 timeline to be changing that, but
// we can optimize it!
return FormalLinkage::PublicUnique;
}

/// Return the formal linkage of the given formal type.
/// This in the appropriate linkage for a lazily-emitted entity
/// derived from the type.
Expand All @@ -211,7 +198,7 @@ FormalLinkage swift::getTypeLinkage(CanType t) {
/// uniquely-emitted nominal type, the formal linkage of that
/// type may differ from the formal linkage of the underlying
/// type declaration.
FormalLinkage swift::getTypeLinkage_correct(CanType t) {
FormalLinkage swift::getTypeLinkage(CanType t) {
assert(t->isLegalFormalType());

class Walker : public TypeWalker {
Expand Down Expand Up @@ -265,7 +252,6 @@ static bool isTypeMetadataForLayoutAccessible(SILModule &M, SILType type) {

// Otherwise, check that we can fetch the type metadata.
return M.isTypeMetadataAccessible(type.getASTType());

}

/// Can we perform value operations on the given type? We have no way
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenThunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ getOrCreateReabstractionThunk(CanSILFunctionType thunkType,
auto serializable = IsSerialized;
if (fromGlobalActorBound) {
auto globalActorLinkage = getTypeLinkage(fromGlobalActorBound);
serializable = globalActorLinkage >= FormalLinkage::PublicNonUnique
serializable = globalActorLinkage <= FormalLinkage::PublicNonUnique
? IsSerialized : IsNotSerialized;
}

Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/hop_to_executor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func testGlobalActorClosure() {
let pga: @PrivateGlobalActor () -> () = { @PrivateGlobalActor in print(5) }
acceptAsyncClosure(pga)

// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] [ossa] @$sIeg_IegH_TR4test17PublicGlobalActorVTU
// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIeg_IegH_TR4test17PublicGlobalActorVTU
// CHECK: hop_to_executor {{%.*}} : $MyPublicActor
// CHECK: apply %0()
let pbga: @PublicGlobalActor () -> () = { @PublicGlobalActor in print(5) }
Expand Down