Skip to content

Commit 9d30684

Browse files
committed
SIL: Cache SILFunction::getLoweredTypeInContext()
1 parent 6c60f03 commit 9d30684

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ class SILFunction
236236
/// The lowered type of the function.
237237
CanSILFunctionType LoweredType;
238238

239+
CanSILFunctionType LoweredTypeInContext;
240+
239241
/// The context archetypes of the function.
240242
GenericEnvironment *GenericEnv = nullptr;
241243

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5292,7 +5292,12 @@ TypeExpansionContext::TypeExpansionContext(const SILFunction &f)
52925292
isContextWholeModule(f.getModule().isWholeModule()) {}
52935293

52945294
CanSILFunctionType SILFunction::getLoweredFunctionTypeInContext() const {
5295-
return getLoweredFunctionTypeInContext(getTypeExpansionContext());
5295+
if (!LoweredTypeInContext) {
5296+
const_cast<SILFunction *>(this)->LoweredTypeInContext
5297+
= getLoweredFunctionTypeInContext(
5298+
getTypeExpansionContext());
5299+
}
5300+
return LoweredTypeInContext;
52965301
}
52975302

52985303
CanSILFunctionType SILFunction::getLoweredFunctionTypeInContext(

0 commit comments

Comments
 (0)