@@ -677,7 +677,7 @@ class SILBuilder {
677
677
!hasOwnership () && " Unqualified inst in qualified function" );
678
678
assert ((Qualifier == LoadOwnershipQualifier::Unqualified) ||
679
679
hasOwnership () && " Qualified inst in unqualified function" );
680
- assert (LV->getType (). isLoadableOrOpaque ( getModule ()));
680
+ assert (isLoadableOrOpaque ( LV->getType ()));
681
681
return insert (new (getModule ())
682
682
LoadInst (getSILDebugLocation (Loc), LV, Qualifier));
683
683
}
@@ -696,13 +696,13 @@ class SILBuilder {
696
696
// / non-address values.
697
697
SILValue emitLoadValueOperation (SILLocation Loc, SILValue LV,
698
698
LoadOwnershipQualifier Qualifier) {
699
- assert (LV->getType (). isLoadableOrOpaque ( getModule ()));
699
+ assert (isLoadableOrOpaque ( LV->getType ()));
700
700
const auto &lowering = getTypeLowering (LV->getType ());
701
701
return lowering.emitLoad (*this , Loc, LV, Qualifier);
702
702
}
703
703
704
704
LoadBorrowInst *createLoadBorrow (SILLocation Loc, SILValue LV) {
705
- assert (LV->getType (). isLoadableOrOpaque ( getModule ()));
705
+ assert (isLoadableOrOpaque ( LV->getType ()));
706
706
return insert (new (getModule ())
707
707
LoadBorrowInst (getSILDebugLocation (Loc), LV));
708
708
}
@@ -1069,7 +1069,7 @@ class SILBuilder {
1069
1069
}
1070
1070
1071
1071
DestroyValueInst *createDestroyValue (SILLocation Loc, SILValue operand) {
1072
- assert (operand->getType (). isLoadableOrOpaque ( getModule ()));
1072
+ assert (isLoadableOrOpaque ( operand->getType ()));
1073
1073
return insert (new (getModule ())
1074
1074
DestroyValueInst (getSILDebugLocation (Loc), operand));
1075
1075
}
@@ -1100,7 +1100,7 @@ class SILBuilder {
1100
1100
RetainValueInst *createRetainValue (SILLocation Loc, SILValue operand,
1101
1101
Atomicity atomicity) {
1102
1102
assert (!hasOwnership ());
1103
- assert (operand->getType (). isLoadableOrOpaque ( getModule ()));
1103
+ assert (isLoadableOrOpaque ( operand->getType ()));
1104
1104
return insert (new (getModule ()) RetainValueInst (getSILDebugLocation (Loc),
1105
1105
operand, atomicity));
1106
1106
}
@@ -1115,7 +1115,7 @@ class SILBuilder {
1115
1115
ReleaseValueInst *createReleaseValue (SILLocation Loc, SILValue operand,
1116
1116
Atomicity atomicity) {
1117
1117
assert (!hasOwnership ());
1118
- assert (operand->getType (). isLoadableOrOpaque ( getModule ()));
1118
+ assert (isLoadableOrOpaque ( operand->getType ()));
1119
1119
return insert (new (getModule ()) ReleaseValueInst (getSILDebugLocation (Loc),
1120
1120
operand, atomicity));
1121
1121
}
@@ -1132,7 +1132,7 @@ class SILBuilder {
1132
1132
SILValue operand,
1133
1133
Atomicity atomicity) {
1134
1134
assert (hasOwnership ());
1135
- assert (operand->getType (). isLoadableOrOpaque ( getModule ()));
1135
+ assert (isLoadableOrOpaque ( operand->getType ()));
1136
1136
return insert (new (getModule ()) UnmanagedRetainValueInst (
1137
1137
getSILDebugLocation (Loc), operand, atomicity));
1138
1138
}
@@ -1141,7 +1141,7 @@ class SILBuilder {
1141
1141
SILValue operand,
1142
1142
Atomicity atomicity) {
1143
1143
assert (hasOwnership ());
1144
- assert (operand->getType (). isLoadableOrOpaque ( getModule ()));
1144
+ assert (isLoadableOrOpaque ( operand->getType ()));
1145
1145
return insert (new (getModule ()) UnmanagedReleaseValueInst (
1146
1146
getSILDebugLocation (Loc), operand, atomicity));
1147
1147
}
@@ -1177,14 +1177,14 @@ class SILBuilder {
1177
1177
1178
1178
StructInst *createStruct (SILLocation Loc, SILType Ty,
1179
1179
ArrayRef<SILValue> Elements) {
1180
- assert (Ty. isLoadableOrOpaque (getModule () ));
1180
+ assert (isLoadableOrOpaque (Ty ));
1181
1181
return insert (StructInst::create (getSILDebugLocation (Loc), Ty, Elements,
1182
1182
getModule (), hasOwnership ()));
1183
1183
}
1184
1184
1185
1185
TupleInst *createTuple (SILLocation Loc, SILType Ty,
1186
1186
ArrayRef<SILValue> Elements) {
1187
- assert (Ty. isLoadableOrOpaque (getModule () ));
1187
+ assert (isLoadableOrOpaque (Ty ));
1188
1188
return insert (TupleInst::create (getSILDebugLocation (Loc), Ty, Elements,
1189
1189
getModule (), hasOwnership ()));
1190
1190
}
@@ -1193,21 +1193,21 @@ class SILBuilder {
1193
1193
1194
1194
EnumInst *createEnum (SILLocation Loc, SILValue Operand,
1195
1195
EnumElementDecl *Element, SILType Ty) {
1196
- assert (Ty. isLoadableOrOpaque (getModule () ));
1196
+ assert (isLoadableOrOpaque (Ty ));
1197
1197
return insert (new (getModule ()) EnumInst (getSILDebugLocation (Loc),
1198
1198
Operand, Element, Ty));
1199
1199
}
1200
1200
1201
1201
// / Inject a loadable value into the corresponding optional type.
1202
1202
EnumInst *createOptionalSome (SILLocation Loc, SILValue operand, SILType ty) {
1203
- assert (ty. isLoadableOrOpaque (getModule () ));
1203
+ assert (isLoadableOrOpaque (ty ));
1204
1204
auto someDecl = getModule ().getASTContext ().getOptionalSomeDecl ();
1205
1205
return createEnum (Loc, operand, someDecl, ty);
1206
1206
}
1207
1207
1208
1208
// / Create the nil value of a loadable optional type.
1209
1209
EnumInst *createOptionalNone (SILLocation Loc, SILType ty) {
1210
- assert (ty. isLoadableOrOpaque (getModule () ));
1210
+ assert (isLoadableOrOpaque (ty ));
1211
1211
auto noneDecl = getModule ().getASTContext ().getOptionalNoneDecl ();
1212
1212
return createEnum (Loc, nullptr , noneDecl, ty);
1213
1213
}
@@ -1224,7 +1224,7 @@ class SILBuilder {
1224
1224
SILValue Operand,
1225
1225
EnumElementDecl *Element,
1226
1226
SILType Ty) {
1227
- assert (Ty. isLoadableOrOpaque (getModule () ));
1227
+ assert (isLoadableOrOpaque (Ty ));
1228
1228
return insert (new (getModule ()) UncheckedEnumDataInst (
1229
1229
getSILDebugLocation (Loc), Operand, Element, Ty));
1230
1230
}
@@ -1264,7 +1264,7 @@ class SILBuilder {
1264
1264
ArrayRef<std::pair<EnumElementDecl *, SILValue>> CaseValues,
1265
1265
Optional<ArrayRef<ProfileCounter>> CaseCounts = None,
1266
1266
ProfileCounter DefaultCount = ProfileCounter()) {
1267
- assert (Ty. isLoadableOrOpaque (getModule () ));
1267
+ assert (isLoadableOrOpaque (Ty ));
1268
1268
return insert (SelectEnumInst::create (
1269
1269
getSILDebugLocation (Loc), Operand, Ty, DefaultValue, CaseValues,
1270
1270
getModule (), CaseCounts, DefaultCount, hasOwnership ()));
@@ -2125,6 +2125,15 @@ class SILBuilder {
2125
2125
#endif
2126
2126
}
2127
2127
2128
+ bool isLoadableOrOpaque (SILType Ty) {
2129
+ if (!F) {
2130
+ // We are inserting into the static initializer of a SILGlobalVariable.
2131
+ // All types used there are loadable by definition.
2132
+ return true ;
2133
+ }
2134
+ return Ty.isLoadableOrOpaque (F);
2135
+ }
2136
+
2128
2137
void appendOperandTypeName (SILType OpdTy, llvm::SmallString<16 > &Name) {
2129
2138
if (auto BuiltinIntTy =
2130
2139
dyn_cast<BuiltinIntegerType>(OpdTy.getASTType ())) {
0 commit comments