[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.
This commit is contained in:
Roman Levenstein
2017-03-10 13:19:14 -08:00
parent 5c01a65a40
commit b3f558321a
2 changed files with 13 additions and 4 deletions

View File

@@ -50,6 +50,10 @@ class ReabstractionInfo {
/// to direct.
llvm::SmallBitVector Conversions;
/// If set, indirect to direct conversions should be performned by the generic
/// specializer.
bool ConvertIndirectToDirect;
/// The first NumResults bits in Conversions refer to formal indirect
/// out-parameters.
unsigned NumFormalIndirectResults;
@@ -130,7 +134,8 @@ public:
/// If specialization is not possible getSpecializedType() will return an
/// invalid type.
ReabstractionInfo(ApplySite Apply, SILFunction *Callee,
SubstitutionList ParamSubs);
SubstitutionList ParamSubs,
bool ConvertIndirectToDirect = true);
/// Constructs the ReabstractionInfo for generic function \p Orig with
/// additional requirements. Requirements may contain new layout,
@@ -140,14 +145,15 @@ public:
/// Returns true if the \p ParamIdx'th (non-result) formal parameter is
/// converted from indirect to direct.
bool isParamConverted(unsigned ParamIdx) const {
return Conversions.test(ParamIdx + NumFormalIndirectResults);
return ConvertIndirectToDirect &&
Conversions.test(ParamIdx + NumFormalIndirectResults);
}
/// Returns true if the \p ResultIdx'th formal result is converted from
/// indirect to direct.
bool isFormalResultConverted(unsigned ResultIdx) const {
assert(ResultIdx < NumFormalIndirectResults);
return Conversions.test(ResultIdx);
return ConvertIndirectToDirect && Conversions.test(ResultIdx);
}
/// Gets the total number of original function arguments.