Skip to content

Commit 631ba28

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents ab78849 + 35c96b8 commit 631ba28

File tree

5 files changed

+51
-16
lines changed

5 files changed

+51
-16
lines changed

include/swift/SIL/SILArgumentConvention.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ struct SILArgumentConvention {
8787
return Value <= SILArgumentConvention::Indirect_Out;
8888
}
8989

90+
bool isOwnedConvention() const {
91+
switch (Value) {
92+
case SILArgumentConvention::Indirect_In:
93+
case SILArgumentConvention::Direct_Owned:
94+
return true;
95+
case SILArgumentConvention::Indirect_In_Guaranteed:
96+
case SILArgumentConvention::Direct_Guaranteed:
97+
case SILArgumentConvention::Indirect_Inout:
98+
case SILArgumentConvention::Indirect_In_Constant:
99+
case SILArgumentConvention::Indirect_Out:
100+
case SILArgumentConvention::Indirect_InoutAliasable:
101+
case SILArgumentConvention::Direct_Unowned:
102+
case SILArgumentConvention::Direct_Deallocating:
103+
return false;
104+
}
105+
llvm_unreachable("covered switch isn't covered?!");
106+
}
107+
90108
bool isGuaranteedConvention() const {
91109
switch (Value) {
92110
case SILArgumentConvention::Indirect_In_Guaranteed:

lib/SIL/SILFunctionType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ static CanSILFunctionType getNativeSILFunctionType(
12501250
case SILFunctionType::Representation::WitnessMethod: {
12511251
switch (constant ? constant->kind : SILDeclRef::Kind::Func) {
12521252
case SILDeclRef::Kind::Initializer:
1253+
case SILDeclRef::Kind::EnumElement:
12531254
return getSILFunctionType(M, origType, substInterfaceType, extInfo,
12541255
DefaultInitializerConventions(), ForeignInfo(),
12551256
constant, witnessMethodConformance);
@@ -1272,7 +1273,6 @@ static CanSILFunctionType getNativeSILFunctionType(
12721273
case SILDeclRef::Kind::StoredPropertyInitializer:
12731274
case SILDeclRef::Kind::IVarInitializer:
12741275
case SILDeclRef::Kind::IVarDestroyer:
1275-
case SILDeclRef::Kind::EnumElement:
12761276
return getSILFunctionType(M, origType, substInterfaceType, extInfo,
12771277
getNormalArgumentConvention(M), ForeignInfo(),
12781278
constant, witnessMethodConformance);

lib/SILGen/SILGenBridging.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,10 +1094,8 @@ ManagedValue SILGenFunction::emitBridgedToNativeError(SILLocation loc,
10941094
};
10951095
auto conformances = getASTContext().AllocateCopy(conformanceArray);
10961096

1097-
SILValue nativeError =
1098-
B.createInitExistentialRef(loc, nativeErrorTy, bridgedErrorTy,
1099-
bridgedError.forward(*this), conformances);
1100-
return emitManagedRValueWithCleanup(nativeError);
1097+
return B.createInitExistentialRef(loc, nativeErrorTy, bridgedErrorTy,
1098+
bridgedError, conformances);
11011099
}
11021100

11031101
// Otherwise, we need to call a runtime function to potential substitute

lib/SILGen/SILGenConstructor.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,25 @@ static RValue emitImplicitValueConstructorArg(SILGenFunction &SGF,
5757
RValue tuple(type);
5858
for (auto fieldType : tupleTy.getElementTypes())
5959
tuple.addElement(emitImplicitValueConstructorArg(SGF, loc, fieldType, DC));
60-
6160
return tuple;
61+
}
62+
63+
auto &AC = SGF.getASTContext();
64+
auto VD = new (AC) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
65+
AC.getIdentifier("$implicit_value"),
66+
SourceLoc(),
67+
AC.getIdentifier("$implicit_value"), Type(),
68+
DC);
69+
VD->setInterfaceType(interfaceType);
70+
SILFunctionArgument *arg =
71+
SGF.F.begin()->createFunctionArgument(SGF.getLoweredType(type), VD);
72+
ManagedValue mvArg;
73+
if (arg->getArgumentConvention().isOwnedConvention()) {
74+
mvArg = SGF.emitManagedRValueWithCleanup(arg);
6275
} else {
63-
auto &AC = SGF.getASTContext();
64-
auto VD = new (AC) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
65-
AC.getIdentifier("$implicit_value"),
66-
SourceLoc(),
67-
AC.getIdentifier("$implicit_value"), Type(),
68-
DC);
69-
VD->setInterfaceType(interfaceType);
70-
SILValue arg =
71-
SGF.F.begin()->createFunctionArgument(SGF.getLoweredType(type), VD);
72-
return RValue(SGF, loc, type, SGF.emitManagedRValueWithCleanup(arg));
76+
mvArg = ManagedValue::forUnmanaged(arg);
7377
}
78+
return RValue(SGF, loc, type, mvArg);
7479
}
7580

7681
static void emitImplicitValueConstructor(SILGenFunction &SGF,

stdlib/public/runtime/ImageInspectionCOFF.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ void swift::initializeTypeMetadataRecordLookup() {
8282
}
8383
}
8484

85+
void swift::initializeTypeFieldLookup() {
86+
const swift::MetadataSections *sections = registered;
87+
while (true) {
88+
const swift::MetadataSections::Range &fields = sections->swift5_fieldmd;
89+
if (fields.length)
90+
addImageTypeFieldDescriptorBlockCallback(
91+
reinterpret_cast<void *>(fields.start), fields.length);
92+
93+
if (sections->next == registered)
94+
break;
95+
sections = sections->next;
96+
}
97+
}
98+
8599
SWIFT_RUNTIME_EXPORT
86100
void swift_addNewDSOImage(const void *addr) {
87101
const swift::MetadataSections *sections =

0 commit comments

Comments
 (0)