mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Cache the isTrivial property.
The check for isTrivial takes ~20% of the optimizer compile time (in debug mode) and using a cache accelerates the compile time. Swift SVN r14346
This commit is contained in:
@@ -127,6 +127,9 @@ private:
|
||||
/// This is a cache of builtin Function declarations to numeric ID mappings.
|
||||
llvm::DenseMap<Identifier, BuiltinInfo> BuiltinIDCache;
|
||||
|
||||
/// This is a cache of the isTrivial property for SILTypes.
|
||||
llvm::DenseMap<SILType, bool> TrivialTypeCache;
|
||||
|
||||
/// This is the set of undef values we've created, for uniquing purposes.
|
||||
llvm::DenseMap<SILType, SILUndef*> UndefValues;
|
||||
|
||||
@@ -163,6 +166,19 @@ public:
|
||||
FunctionTable.erase(F->getName());
|
||||
}
|
||||
|
||||
bool isTrivialType(SILType Ty) {
|
||||
auto It = TrivialTypeCache.find(Ty);
|
||||
|
||||
// Check if this type is already in the cache.
|
||||
if (It != TrivialTypeCache.end())
|
||||
return It->second;
|
||||
|
||||
// Check if the type is trivial and store the result in the cache.
|
||||
bool IsTriv = getTypeLowering(Ty).isTrivial();
|
||||
TrivialTypeCache[Ty] = IsTriv;
|
||||
return IsTriv;
|
||||
}
|
||||
|
||||
/// Construct a SIL module from an AST module.
|
||||
///
|
||||
/// The module will be constructed in the Raw stage. The provided AST module
|
||||
|
||||
Reference in New Issue
Block a user