Skip to content

Commit 23d838a

Browse files
committed
[SIL/SILGen] [AST] NFC: Remove @runtimeMetadata related code
1 parent 0ab131c commit 23d838a

File tree

10 files changed

+1
-122
lines changed

10 files changed

+1
-122
lines changed

include/swift/SIL/SILDeclRef.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ struct SILDeclRef {
163163

164164
/// The asynchronous main entry-point function.
165165
AsyncEntryPoint,
166-
167-
/// This constant references the generator function used to instantiate
168-
/// attribute value associated with a particular declaration.
169-
RuntimeAttributeGenerator,
170166
};
171167

172168
/// Represents the variants of a back deployable function.
@@ -282,9 +278,6 @@ struct SILDeclRef {
282278
/// Produces a SILDeclRef for the entry-point of an async main FileUnit.
283279
static SILDeclRef getAsyncMainFileEntryPoint(FileUnit *file);
284280

285-
static SILDeclRef getRuntimeAttributeGenerator(CustomAttr *attr,
286-
ValueDecl *decl);
287-
288281
bool isNull() const { return loc.isNull(); }
289282
explicit operator bool() const { return !isNull(); }
290283

@@ -528,10 +521,6 @@ struct SILDeclRef {
528521
/// fallback for an original function which may be unavailable at runtime.
529522
bool isBackDeploymentFallback() const;
530523

531-
/// True if the decl ref references a function that could be looked up
532-
/// at runtime using special API.
533-
bool isRuntimeAccessibleFunction() const;
534-
535524
/// True if the decl ref references a method which introduces a new vtable
536525
/// entry.
537526
bool requiresNewVTableEntry() const;

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ bool SILDeclRef::hasUserWrittenCode() const {
370370
case Kind::PropertyWrapperInitFromProjectedValue:
371371
case Kind::EntryPoint:
372372
case Kind::AsyncEntryPoint:
373-
case Kind::RuntimeAttributeGenerator:
374373
// Implicit decls for these don't splice in user-written code.
375374
return false;
376375
}
@@ -512,9 +511,6 @@ static LinkageLimit getLinkageLimit(SILDeclRef constant) {
512511
// class from which they come, and never get seen externally.
513512
return Limit::NeverPublic;
514513

515-
case Kind::RuntimeAttributeGenerator:
516-
return Limit::NeverPublic;
517-
518514
case Kind::EntryPoint:
519515
case Kind::AsyncEntryPoint:
520516
llvm_unreachable("Already handled");
@@ -677,16 +673,6 @@ SILDeclRef SILDeclRef::getMainFileEntryPoint(FileUnit *file) {
677673
return result;
678674
}
679675

680-
SILDeclRef SILDeclRef::getRuntimeAttributeGenerator(CustomAttr *attr,
681-
ValueDecl *decl) {
682-
SILDeclRef result;
683-
result.loc = decl;
684-
result.kind = Kind::RuntimeAttributeGenerator;
685-
result.isRuntimeAccessible = true;
686-
result.pointer = attr;
687-
return result;
688-
}
689-
690676
bool SILDeclRef::hasClosureExpr() const {
691677
return loc.is<AbstractClosureExpr *>()
692678
&& isa<ClosureExpr>(getAbstractClosureExpr());
@@ -1046,11 +1032,6 @@ bool SILDeclRef::isBackDeploymentThunk() const {
10461032
kind == Kind::Allocator;
10471033
}
10481034

1049-
bool SILDeclRef::isRuntimeAccessibleFunction() const {
1050-
return isRuntimeAccessible &&
1051-
(kind == Kind::Func || kind == Kind::RuntimeAttributeGenerator);
1052-
}
1053-
10541035
/// Use the Clang importer to mangle a Clang declaration.
10551036
static void mangleClangDecl(raw_ostream &buffer,
10561037
const clang::NamedDecl *clangDecl,
@@ -1230,10 +1211,6 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
12301211
case SILDeclRef::Kind::EntryPoint: {
12311212
return getASTContext().getEntryPointFunctionName();
12321213
}
1233-
1234-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
1235-
return mangler.mangleRuntimeAttributeGeneratorEntity(
1236-
loc.get<ValueDecl *>(), pointer.get<CustomAttr *>(), SKind);
12371214
}
12381215

12391216
llvm_unreachable("bad entity kind!");
@@ -1603,7 +1580,7 @@ unsigned SILDeclRef::getParameterListCount() const {
16031580

16041581
// Always uncurried even if the underlying function is curried.
16051582
if (kind == Kind::DefaultArgGenerator || kind == Kind::EntryPoint ||
1606-
kind == Kind::AsyncEntryPoint || kind == Kind::RuntimeAttributeGenerator)
1583+
kind == Kind::AsyncEntryPoint)
16071584
return 1;
16081585

16091586
auto *vd = getDecl();

lib/SIL/IR/SILFunctionBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ SILFunction *SILFunctionBuilder::getOrCreateFunction(
311311
}
312312

313313
IsRuntimeAccessible_t isRuntimeAccessible = IsNotRuntimeAccessible;
314-
if (constant.isRuntimeAccessibleFunction())
315-
isRuntimeAccessible = IsRuntimeAccessible;
316314

317315
auto *F = SILFunction::create(
318316
mod, linkage, name, constantType, nullptr, llvm::None, IsNotBare, IsTrans,

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,9 +2748,6 @@ static CanSILFunctionType getNativeSILFunctionType(
27482748
case SILDeclRef::Kind::AsyncEntryPoint:
27492749
return getSILFunctionTypeForConventions(
27502750
DefaultConventions(NormalParameterConvention::Guaranteed));
2751-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
2752-
return getSILFunctionTypeForConventions(DefaultConventions(
2753-
NormalParameterConvention::Guaranteed, ResultConvention::Indirect));
27542751
case SILDeclRef::Kind::EntryPoint:
27552752
llvm_unreachable("Handled by getSILFunctionTypeForAbstractCFunction");
27562753
}
@@ -3786,7 +3783,6 @@ static ObjCSelectorFamily getObjCSelectorFamily(SILDeclRef c) {
37863783
case SILDeclRef::Kind::EnumElement:
37873784
case SILDeclRef::Kind::GlobalAccessor:
37883785
case SILDeclRef::Kind::DefaultArgGenerator:
3789-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
37903786
case SILDeclRef::Kind::StoredPropertyInitializer:
37913787
case SILDeclRef::Kind::PropertyWrapperBackingInitializer:
37923788
case SILDeclRef::Kind::PropertyWrapperInitFromProjectedValue:
@@ -4061,7 +4057,6 @@ TypeConverter::getDeclRefRepresentation(SILDeclRef c) {
40614057
switch (c.kind) {
40624058
case SILDeclRef::Kind::GlobalAccessor:
40634059
case SILDeclRef::Kind::DefaultArgGenerator:
4064-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
40654060
case SILDeclRef::Kind::StoredPropertyInitializer:
40664061
case SILDeclRef::Kind::PropertyWrapperBackingInitializer:
40674062
case SILDeclRef::Kind::PropertyWrapperInitFromProjectedValue:
@@ -4466,7 +4461,6 @@ static AbstractFunctionDecl *getBridgedFunction(SILDeclRef declRef) {
44664461
case SILDeclRef::Kind::Deallocator:
44674462
case SILDeclRef::Kind::GlobalAccessor:
44684463
case SILDeclRef::Kind::DefaultArgGenerator:
4469-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
44704464
case SILDeclRef::Kind::StoredPropertyInitializer:
44714465
case SILDeclRef::Kind::PropertyWrapperBackingInitializer:
44724466
case SILDeclRef::Kind::PropertyWrapperInitFromProjectedValue:

lib/SIL/IR/SILPrinter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,6 @@ void SILDeclRef::print(raw_ostream &OS) const {
391391
case SILDeclRef::Kind::PropertyWrapperInitFromProjectedValue:
392392
OS << "!projectedvalueinit";
393393
break;
394-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
395-
OS << "!attrgenerator";
396-
break;
397394
}
398395

399396
if (isForeign)

lib/SIL/IR/SILSymbolVisitor.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,6 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
368368
Visitor.addMethodDescriptor(method);
369369
}
370370

371-
void addRuntimeDiscoverableAttrGenerators(ValueDecl *D) {
372-
for (auto *attr : D->getRuntimeDiscoverableAttrs()) {
373-
addFunction(SILDeclRef::getRuntimeAttributeGenerator(attr, D),
374-
/*ignoreLinkage=*/true);
375-
}
376-
}
377-
378371
public:
379372
SILSymbolVisitorImpl(SILSymbolVisitor &Visitor,
380373
const SILSymbolVisitorContext &Ctx)
@@ -492,8 +485,6 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
492485
AFD->getGenericSignature()));
493486
}
494487

495-
addRuntimeDiscoverableAttrGenerators(AFD);
496-
497488
visitDefaultArguments(AFD, AFD->getParameters());
498489

499490
if (AFD->hasAsync()) {
@@ -580,8 +571,6 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
580571
}
581572

582573
visitAbstractStorageDecl(VD);
583-
584-
addRuntimeDiscoverableAttrGenerators(VD);
585574
}
586575

587576
void visitSubscriptDecl(SubscriptDecl *SD) {
@@ -619,8 +608,6 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
619608
// There are symbols associated with any protocols this type conforms to.
620609
addConformances(NTD);
621610

622-
addRuntimeDiscoverableAttrGenerators(NTD);
623-
624611
visitMembers(NTD);
625612
}
626613

lib/SIL/IR/TypeLowering.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,30 +3375,6 @@ static CanAnyFunctionType getStoredPropertyInitializerInterfaceType(
33753375
info);
33763376
}
33773377

3378-
/// Type of runtime discoverable attribute generator is () -> <#AttrType#>
3379-
static CanAnyFunctionType
3380-
getRuntimeAttributeGeneratorInterfaceType(TypeConverter &TC, SILDeclRef c) {
3381-
auto *attachedToDecl = c.getDecl();
3382-
auto *attr = c.pointer.get<CustomAttr *>();
3383-
auto *attrType = attachedToDecl->getRuntimeDiscoverableAttrTypeDecl(attr);
3384-
auto generator =
3385-
attachedToDecl->getRuntimeDiscoverableAttributeGenerator(attr);
3386-
3387-
auto resultTy = generator.second->getCanonicalType();
3388-
3389-
CanType canResultTy = resultTy->getReducedType(
3390-
attrType->getInnermostDeclContext()->getGenericSignatureOfContext());
3391-
3392-
// Remove @noescape from function return types. A @noescape
3393-
// function return type is a contradiction.
3394-
canResultTy = removeNoEscape(canResultTy);
3395-
3396-
// FIXME: Verify ExtInfo state is correct, not working by accident.
3397-
CanAnyFunctionType::ExtInfo info;
3398-
return CanAnyFunctionType::get(/*genericSignature=*/nullptr,
3399-
/*params=*/{}, canResultTy, info);
3400-
}
3401-
34023378
/// Get the type of a property wrapper backing initializer,
34033379
/// (property-type) -> backing-type.
34043380
static CanAnyFunctionType getPropertyWrapperBackingInitializerInterfaceType(
@@ -3659,8 +3635,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) {
36593635
return getAsyncEntryPoint(Context);
36603636
case SILDeclRef::Kind::EntryPoint:
36613637
return getEntryPointInterfaceType(Context);
3662-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
3663-
return getRuntimeAttributeGeneratorInterfaceType(*this, c);
36643638
}
36653639

36663640
llvm_unreachable("Unhandled SILDeclRefKind in switch.");
@@ -3714,7 +3688,6 @@ TypeConverter::getConstantGenericSignature(SILDeclRef c) {
37143688
return vd->getDeclContext()->getGenericSignatureOfContext();
37153689
case SILDeclRef::Kind::EntryPoint:
37163690
case SILDeclRef::Kind::AsyncEntryPoint:
3717-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
37183691
llvm_unreachable("Doesn't have generic signature");
37193692
}
37203693

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,9 +1707,6 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Result,
17071707
} else if (!ParseState && Id.str() == "defaultarg") {
17081708
Kind = SILDeclRef::Kind::IVarInitializer;
17091709
ParseState = 1;
1710-
} else if (!ParseState && Id.str() == "attrgenerator") {
1711-
Kind = SILDeclRef::Kind::RuntimeAttributeGenerator;
1712-
ParseState = 1;
17131710
} else if (!ParseState && Id.str() == "propertyinit") {
17141711
Kind = SILDeclRef::Kind::StoredPropertyInitializer;
17151712
ParseState = 1;

lib/SILGen/SILGen.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,22 +1133,6 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
11331133
postEmitFunction(constant, f);
11341134
return;
11351135
}
1136-
1137-
case SILDeclRef::Kind::RuntimeAttributeGenerator: {
1138-
auto *decl = constant.getDecl();
1139-
auto *attr = constant.pointer.get<CustomAttr *>();
1140-
auto *DC = decl->getDeclContext()->getParentSourceFile();
1141-
1142-
auto generator = decl->getRuntimeDiscoverableAttributeGenerator(attr);
1143-
auto loc = RegularLocation::getAutoGeneratedLocation();
1144-
preEmitFunction(constant, f, loc);
1145-
PrettyStackTraceSILFunction X("silgen emitRuntimeAttributeGenerator ", f);
1146-
SILGenFunction SGF(*this, *f, DC);
1147-
SGF.emitGeneratorFunction(constant, generator.second, generator.first,
1148-
AbstractionPattern::getOpaqueFunction());
1149-
postEmitFunction(constant, f);
1150-
break;
1151-
}
11521136
}
11531137
}
11541138

@@ -2000,14 +1984,6 @@ class SILGenModuleRAII {
20001984
SGM.visit(TD);
20011985
}
20021986

2003-
for (auto *D : sf->getDeclsWithRuntimeDiscoverableAttrs()) {
2004-
for (auto *attr : D->getRuntimeDiscoverableAttrs()) {
2005-
emitSILFunctionDefinition(
2006-
SILDeclRef::getRuntimeAttributeGenerator(attr, D)
2007-
.asRuntimeAccessible());
2008-
}
2009-
}
2010-
20111987
// If the source file contains an artificial main, emit the implicit
20121988
// top-level code.
20131989
if (auto *mainDecl = sf->getMainDecl()) {

lib/SILGen/SILGenFunction.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,6 @@ DeclName SILGenModule::getMagicFunctionName(SILDeclRef ref) {
201201
auto *file = ref.getDecl()->getDeclContext()->getParentSourceFile();
202202
return getMagicFunctionName(file);
203203
}
204-
case SILDeclRef::Kind::RuntimeAttributeGenerator: {
205-
if (auto *var = dyn_cast<VarDecl>(ref.getDecl()))
206-
return var->getName();
207-
208-
auto *DC = dyn_cast<DeclContext>(ref.getDecl());
209-
return getMagicFunctionName(DC ? DC : ref.getDecl()->getDeclContext());
210-
}
211204
}
212205

213206
llvm_unreachable("Unhandled SILDeclRefKind in switch.");
@@ -1507,8 +1500,6 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value,
15071500
}
15081501

15091502
params = ParameterList::create(ctx, SourceLoc(), {param}, SourceLoc());
1510-
} else if (function.kind == SILDeclRef::Kind::RuntimeAttributeGenerator) {
1511-
params = ParameterList::createEmpty(getASTContext());
15121503
}
15131504

15141505
auto captureInfo = SGM.M.Types.getLoweredLocalCaptures(function);

0 commit comments

Comments
 (0)