Skip to content

Commit 65091d6

Browse files
committed
[sil-generic-specializer] Provide a possibility to disable the indirect-to-direct conversions of parameters and results
This is required by the capture propagation pass. Indirect-to-direct conversions are still performed by default.
1 parent f3bfc77 commit 65091d6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

include/swift/SILOptimizer/Utils/Generics.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class ReabstractionInfo {
5050
/// to direct.
5151
llvm::SmallBitVector Conversions;
5252

53+
/// If set, indirect to direct conversions should be performned by the generic
54+
/// specializer.
55+
bool ConvertIndirectToDirect;
56+
5357
/// The first NumResults bits in Conversions refer to formal indirect
5458
/// out-parameters.
5559
unsigned NumFormalIndirectResults;
@@ -130,7 +134,8 @@ class ReabstractionInfo {
130134
/// If specialization is not possible getSpecializedType() will return an
131135
/// invalid type.
132136
ReabstractionInfo(ApplySite Apply, SILFunction *Callee,
133-
SubstitutionList ParamSubs);
137+
SubstitutionList ParamSubs,
138+
bool ConvertIndirectToDirect = true);
134139

135140
/// Constructs the ReabstractionInfo for generic function \p Orig with
136141
/// additional requirements. Requirements may contain new layout,
@@ -140,14 +145,15 @@ class ReabstractionInfo {
140145
/// Returns true if the \p ParamIdx'th (non-result) formal parameter is
141146
/// converted from indirect to direct.
142147
bool isParamConverted(unsigned ParamIdx) const {
143-
return Conversions.test(ParamIdx + NumFormalIndirectResults);
148+
return ConvertIndirectToDirect &&
149+
Conversions.test(ParamIdx + NumFormalIndirectResults);
144150
}
145151

146152
/// Returns true if the \p ResultIdx'th formal result is converted from
147153
/// indirect to direct.
148154
bool isFormalResultConverted(unsigned ResultIdx) const {
149155
assert(ResultIdx < NumFormalIndirectResults);
150-
return Conversions.test(ResultIdx);
156+
return ConvertIndirectToDirect && Conversions.test(ResultIdx);
151157
}
152158

153159
/// Gets the total number of original function arguments.

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,13 @@ bool ReabstractionInfo::canBeSpecialized(ApplySite Apply, SILFunction *Callee,
290290
}
291291

292292
ReabstractionInfo::ReabstractionInfo(ApplySite Apply, SILFunction *Callee,
293-
ArrayRef<Substitution> ParamSubs) {
293+
ArrayRef<Substitution> ParamSubs,
294+
bool ConvertIndirectToDirect) {
294295
if (!prepareAndCheck(Apply, Callee, ParamSubs))
295296
return;
296297

298+
this->ConvertIndirectToDirect = ConvertIndirectToDirect;
299+
297300
if (SpecializeGenericSubstitutions) {
298301
specializeConcreteAndGenericSubstitutions(Apply, Callee, ParamSubs);
299302
} else {

0 commit comments

Comments
 (0)