Skip to content

Commit a9751ef

Browse files
authored
Merge pull request #9179 from apple/large_types_swift4_cherrypick
2 parents 37de124 + 49dafe4 commit a9751ef

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ static bool modifiableFunction(CanSILFunctionType funcType) {
9797
// C functions should use the old ABI
9898
return false;
9999
}
100-
if (funcType->getRepresentation() == SILFunctionTypeRepresentation::Method) {
101-
// C functions should use the old ABI
102-
return false;
103-
}
104100
return true;
105101
}
106102

@@ -396,10 +392,6 @@ static bool modifiableApply(ApplySite applySite, irgen::IRGenModule &Mod) {
396392
SILFunctionTypeRepresentation::CFunctionPointer) {
397393
return false;
398394
}
399-
if (applySite.getSubstCalleeType()->getRepresentation() ==
400-
SILFunctionTypeRepresentation::Method) {
401-
return false;
402-
}
403395
auto callee = applySite.getCallee();
404396
if (dyn_cast<ProjectBlockStorageInst>(callee)) {
405397
return false;
@@ -425,17 +417,18 @@ void LargeValueVisitor::visitApply(ApplySite applySite) {
425417
SILValue currOperand = operand.get();
426418
SILType silType = currOperand->getType();
427419
SILType newSilType = getNewSILType(genEnv, silType, pass.Mod);
428-
if (silType != newSilType) {
420+
if (silType != newSilType ||
421+
std::find(pass.largeLoadableArgs.begin(), pass.largeLoadableArgs.end(),
422+
currOperand) != pass.largeLoadableArgs.end() ||
423+
std::find(pass.funcSigArgs.begin(), pass.funcSigArgs.end(),
424+
currOperand) != pass.funcSigArgs.end()) {
429425
pass.applies.push_back(applySite.getInstruction());
430426
return;
431427
}
432428
}
433429
}
434430

435431
static bool isMethodInstUnmodifiable(MethodInst *instr) {
436-
if (dyn_cast<ClassMethodInst>(instr)) {
437-
return true;
438-
}
439432
for (auto *user : instr->getUses()) {
440433
if (ApplySite::isa(user->getUser())) {
441434
ApplySite applySite = ApplySite(user->getUser());
@@ -447,10 +440,6 @@ static bool isMethodInstUnmodifiable(MethodInst *instr) {
447440
SILFunctionTypeRepresentation::CFunctionPointer) {
448441
return true;
449442
}
450-
if (applySite.getSubstCalleeType()->getRepresentation() ==
451-
SILFunctionTypeRepresentation::Method) {
452-
return true;
453-
}
454443
}
455444
}
456445
return false;

lib/SIL/SILVerifier.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,9 +2244,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
22442244

22452245
void checkClassMethodInst(ClassMethodInst *CMI) {
22462246
auto overrideTy = TC.getConstantOverrideType(CMI->getMember());
2247-
requireSameType(CMI->getType(),
2248-
SILType::getPrimitiveObjectType(overrideTy),
2249-
"result type of class_method must match abstracted type of method");
2247+
if (CMI->getModule().getStage() != SILStage::Lowered) {
2248+
requireSameType(
2249+
CMI->getType(), SILType::getPrimitiveObjectType(overrideTy),
2250+
"result type of class_method must match abstracted type of method");
2251+
}
22502252
auto methodType = requireObjectType(SILFunctionType, CMI,
22512253
"result of class_method");
22522254
require(!methodType->getExtInfo().hasContext(),
@@ -2280,8 +2282,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
22802282

22812283
void checkSuperMethodInst(SuperMethodInst *CMI) {
22822284
auto overrideTy = TC.getConstantOverrideType(CMI->getMember());
2283-
requireSameType(CMI->getType(), SILType::getPrimitiveObjectType(overrideTy),
2284-
"result type of super_method must match abstracted type of method");
2285+
if (CMI->getModule().getStage() != SILStage::Lowered) {
2286+
requireSameType(
2287+
CMI->getType(), SILType::getPrimitiveObjectType(overrideTy),
2288+
"result type of super_method must match abstracted type of method");
2289+
}
22852290
auto methodType = requireObjectType(SILFunctionType, CMI,
22862291
"result of super_method");
22872292
require(!methodType->getExtInfo().hasContext(),
@@ -4226,12 +4231,14 @@ void SILVTable::verify(const SILModule &M) const {
42264231
llvm::raw_svector_ostream os(baseName);
42274232
entry.Method.print(os);
42284233
}
4229-
4230-
SILVerifier(*entry.Implementation)
4231-
.requireABICompatibleFunctionTypes(
4232-
baseInfo.getSILType().castTo<SILFunctionType>(),
4233-
entry.Implementation->getLoweredFunctionType(),
4234-
"vtable entry for " + baseName + " must be ABI-compatible");
4234+
4235+
if (M.getStage() != SILStage::Lowered) {
4236+
SILVerifier(*entry.Implementation)
4237+
.requireABICompatibleFunctionTypes(
4238+
baseInfo.getSILType().castTo<SILFunctionType>(),
4239+
entry.Implementation->getLoweredFunctionType(),
4240+
"vtable entry for " + baseName + " must be ABI-compatible");
4241+
}
42354242
}
42364243
#endif
42374244
}

test/IRGen/indirect_argument.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ struct HugeAlignment {
1414
// TODO: could be the context param
1515
// CHECK-LABEL-64: define{{( protected)?}} swiftcc void @huge_method(%T17indirect_argument4HugeV* noalias nocapture dereferenceable({{.*}}))
1616
// CHECK-LABEL-32: define{{( protected)?}} swiftcc void @huge_method(%T17indirect_argument4HugeV* noalias nocapture swiftself dereferenceable({{.*}}))
17-
// CHECK-64: call swiftcc void @huge_method(%T17indirect_argument4HugeV* noalias nocapture dereferenceable({{.*}})
18-
// CHECK-32: call swiftcc void @huge_method(%T17indirect_argument4HugeV* noalias nocapture swiftself dereferenceable({{.*}})
17+
// CHECK: call swiftcc void @huge_method(%T17indirect_argument4HugeV* noalias nocapture swiftself dereferenceable({{.*}})
1918
sil @huge_method : $@convention(method) Huge -> () {
2019
entry(%x : $Huge):
2120
%f = function_ref @huge_method : $@convention(method) Huge -> ()
@@ -61,7 +60,8 @@ entry(%o : $*Huge, %x : $Huge):
6160
}
6261

6362
// CHECK-LABEL: define{{( protected)?}} swiftcc void @huge_partial_application(%T17indirect_argument4HugeV* noalias nocapture dereferenceable({{.*}}), %T17indirect_argument4HugeV* noalias nocapture dereferenceable({{.*}}))
64-
// CHECK: [[CLOSURE:%.*]] = call noalias %swift.refcounted* @swift_rt_swift_allocObject
63+
// CHECK-32: [[CLOSURE:%.*]] = call noalias %swift.refcounted* @swift_rt_swift_allocObject
64+
// CHECK-64: [[CLOSURE:%.*]] = call noalias %swift.refcounted* @swift_rt_swift_allocObject
6565
// CHECK: bitcast %swift.refcounted* [[CLOSURE]] to <{ %swift.refcounted, %T17indirect_argument4HugeV }>*
6666
// CHECK: call void @llvm.memcpy
6767
// CHECK-64: call swiftcc void @_T024huge_partial_applicationTA(%T17indirect_argument4HugeV* noalias nocapture dereferenceable(40) %0, %swift.refcounted* swiftself [[CLOSURE]])

0 commit comments

Comments
 (0)