Skip to content

Commit 970c272

Browse files
Merge pull request #31470 from aschwaighofer/fix_rdar62560867
SIL: Thread type expansion context through to function convention apis
2 parents 20e973d + b455ac4 commit 970c272

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+984
-541
lines changed

include/swift/AST/Types.h

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,8 +3776,7 @@ class SILParameterInfo {
37763776
/// Return the type of a call argument matching this parameter.
37773777
///
37783778
/// \c t must refer back to the function type this is a parameter for.
3779-
CanType getArgumentType(SILModule &M,
3780-
const SILFunctionType *t) const;
3779+
CanType getArgumentType(SILModule &M, const SILFunctionType *t, TypeExpansionContext context) const;
37813780
ParameterConvention getConvention() const {
37823781
return TypeAndConvention.getInt();
37833782
}
@@ -3832,8 +3831,9 @@ class SILParameterInfo {
38323831
/// storage. Therefore they will be passed using an indirect formal
38333832
/// convention, and this method will return an address type. However, in
38343833
/// canonical SIL the opaque arguments might not have an address type.
3835-
SILType getSILStorageType(SILModule &M,
3836-
const SILFunctionType *t) const; // in SILFunctionConventions.h
3834+
SILType getSILStorageType(
3835+
SILModule &M, const SILFunctionType *t,
3836+
TypeExpansionContext context) const; // in SILFunctionConventions.h
38373837
SILType getSILStorageInterfaceType() const;
38383838

38393839
/// Return a version of this parameter info with the type replaced.
@@ -3865,9 +3865,9 @@ class SILParameterInfo {
38653865
/// type, apply any substitutions from the function type to it to
38663866
/// get a substituted version of it, as you would get from
38673867
/// SILFunctionType::getUnsubstitutedType.
3868-
SILParameterInfo getUnsubstituted(SILModule &M,
3869-
const SILFunctionType *fnType) const {
3870-
return getWithInterfaceType(getArgumentType(M, fnType));
3868+
SILParameterInfo getUnsubstituted(SILModule &M, const SILFunctionType *fnType,
3869+
TypeExpansionContext context) const {
3870+
return getWithInterfaceType(getArgumentType(M, fnType, context));
38713871
}
38723872

38733873
void profile(llvm::FoldingSetNodeID &id) {
@@ -3952,9 +3952,9 @@ class SILResultInfo {
39523952
/// The type of a return value corresponding to this result.
39533953
///
39543954
/// \c t must refer back to the function type this is a parameter for.
3955-
CanType getReturnValueType(SILModule &M,
3956-
const SILFunctionType *t) const;
3957-
3955+
CanType getReturnValueType(SILModule &M, const SILFunctionType *t,
3956+
TypeExpansionContext context) const;
3957+
39583958
ResultConvention getConvention() const {
39593959
return TypeAndConvention.getInt();
39603960
}
@@ -3964,8 +3964,9 @@ class SILResultInfo {
39643964
/// storage. Therefore they will be returned using an indirect formal
39653965
/// convention, and this method will return an address type. However, in
39663966
/// canonical SIL the opaque results might not have an address type.
3967-
SILType getSILStorageType(SILModule &M,
3968-
const SILFunctionType *t) const; // in SILFunctionConventions.h
3967+
SILType getSILStorageType(
3968+
SILModule &M, const SILFunctionType *t,
3969+
TypeExpansionContext context) const; // in SILFunctionConventions.h
39693970
SILType getSILStorageInterfaceType() const;
39703971
/// Return a version of this result info with the type replaced.
39713972
SILResultInfo getWithInterfaceType(CanType type) const {
@@ -4006,9 +4007,9 @@ class SILResultInfo {
40064007
/// type, apply any substitutions from the function type to it to
40074008
/// get a substituted version of it, as you would get from
40084009
/// SILFunctionType::getUnsubstitutedType.
4009-
SILResultInfo getUnsubstituted(SILModule &M,
4010-
const SILFunctionType *fnType) const {
4011-
return getWithInterfaceType(getReturnValueType(M, fnType));
4010+
SILResultInfo getUnsubstituted(SILModule &M, const SILFunctionType *fnType,
4011+
TypeExpansionContext context) const {
4012+
return getWithInterfaceType(getReturnValueType(M, fnType, context));
40124013
}
40134014

40144015
void profile(llvm::FoldingSetNodeID &id) {
@@ -4066,18 +4067,18 @@ class SILYieldInfo : public SILParameterInfo {
40664067
->getCanonicalType());
40674068
}
40684069

4069-
CanType getYieldValueType(SILModule &M,
4070-
const SILFunctionType *fnType) const {
4071-
return getArgumentType(M, fnType);
4070+
CanType getYieldValueType(SILModule &M, const SILFunctionType *fnType,
4071+
TypeExpansionContext context) const {
4072+
return getArgumentType(M, fnType, context);
40724073
}
40734074

40744075
/// Treating this yield info as a component of the given function
40754076
/// type, apply any substitutions from the function type to it to
40764077
/// get a substituted version of it, as you would get from
40774078
/// SILFunctionType::getUnsubstitutedType.
4078-
SILYieldInfo getUnsubstituted(SILModule &M,
4079-
const SILFunctionType *fnType) const {
4080-
return getWithInterfaceType(getYieldValueType(M, fnType));
4079+
SILYieldInfo getUnsubstituted(SILModule &M, const SILFunctionType *fnType,
4080+
TypeExpansionContext context) const {
4081+
return getWithInterfaceType(getYieldValueType(M, fnType, context));
40814082
}
40824083
};
40834084

@@ -4528,14 +4529,15 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
45284529
/// this function depends on the current SIL stage and is known by
45294530
/// SILFunctionConventions. It may be a wider tuple that includes formally
45304531
/// indirect results.
4531-
SILType getDirectFormalResultsType(SILModule &M);
4532+
SILType getDirectFormalResultsType(SILModule &M,
4533+
TypeExpansionContext expansion);
45324534

45334535
/// Get a single non-address SILType for all SIL results regardless of whether
45344536
/// they are formally indirect. The actual SIL result type of an apply
45354537
/// instruction that calls this function depends on the current SIL stage and
45364538
/// is known by SILFunctionConventions. It may be a narrower tuple that omits
45374539
/// formally indirect results.
4538-
SILType getAllResultsSubstType(SILModule &M);
4540+
SILType getAllResultsSubstType(SILModule &M, TypeExpansionContext expansion);
45394541
SILType getAllResultsInterfaceType();
45404542

45414543
/// Does this function have a blessed Swift-native error result?
@@ -4678,12 +4680,13 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
46784680
return getInvocationGenericSignature() && !getInvocationSubstitutions();
46794681
}
46804682

4681-
CanType getSelfInstanceType(SILModule &M) const;
4683+
CanType getSelfInstanceType(SILModule &M, TypeExpansionContext context) const;
46824684

46834685
/// If this is a @convention(witness_method) function with a class
46844686
/// constrained self parameter, return the class constraint for the
46854687
/// Self type.
4686-
ClassDecl *getWitnessMethodClass(SILModule &M) const;
4688+
ClassDecl *getWitnessMethodClass(SILModule &M,
4689+
TypeExpansionContext context) const;
46874690

46884691
/// If this is a @convention(witness_method) function, return the conformance
46894692
/// for which the method is a witness. If it isn't that convention, return
@@ -4875,8 +4878,9 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
48754878
return getExtInfo().getDifferentiabilityKind();
48764879
}
48774880

4878-
bool isNoReturnFunction(SILModule &M) const; // Defined in SILType.cpp
4879-
4881+
bool isNoReturnFunction(SILModule &M, TypeExpansionContext context)
4882+
const; // Defined in SILType.cpp
4883+
48804884
/// Create a SILFunctionType with the same structure as this one,
48814885
/// but with a different (or new) set of invocation substitutions.
48824886
/// The substitutions must have the same generic signature as this.
@@ -4956,7 +4960,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
49564960
TypeExpansionContext context);
49574961

49584962
SILType substInterfaceType(SILModule &M,
4959-
SILType interfaceType) const;
4963+
SILType interfaceType,
4964+
TypeExpansionContext context) const;
49604965

49614966
/// Return the unsubstituted function type equivalent to this type; that is, the type that has the same
49624967
/// argument and result types as `this` type after substitutions, if any.

include/swift/SIL/ApplySite.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "swift/SIL/SILBasicBlock.h"
2525
#include "swift/SIL/SILInstruction.h"
26+
#include "swift/SIL/SILFunction.h"
2627

2728
namespace swift {
2829

@@ -180,7 +181,10 @@ class ApplySite {
180181
}
181182

182183
/// Return the type.
183-
SILType getType() const { return getSubstCalleeConv().getSILResultType(); }
184+
SILType getType() const {
185+
return getSubstCalleeConv().getSILResultType(
186+
getFunction()->getTypeExpansionContext());
187+
}
184188

185189
/// Get the type of the callee without the applied substitutions.
186190
CanSILFunctionType getOrigCalleeType() const {

include/swift/SIL/SILFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class SILFunction
416416

417417
void setEntryCount(ProfileCounter Count) { EntryCount = Count; }
418418

419-
bool isNoReturnFunction() const;
419+
bool isNoReturnFunction(TypeExpansionContext context) const;
420420

421421
/// Unsafely rewrite the lowered type of this function.
422422
///

0 commit comments

Comments
 (0)