Reduce memory usage by freeing memory occupied by SILModules after IRGen.

There is no need to keep SILModules around after IRGen has generated LLVM IR from them.
This reduces the compiler memory usage during LLVM code-generation and optimization phases roughly by 15%-20%.
This commit is contained in:
Roman Levenstein
2016-11-29 22:11:59 -08:00
parent a3e56f8bcf
commit 409d146f17
5 changed files with 36 additions and 20 deletions

View File

@@ -1073,10 +1073,10 @@ static bool performCompile(CompilerInstance &Instance,
// something is persisting across calls to performIRGeneration.
auto &LLVMContext = getGlobalLLVMContext();
if (PrimarySourceFile) {
performIRGeneration(IRGenOpts, *PrimarySourceFile, SM.get(),
performIRGeneration(IRGenOpts, *PrimarySourceFile, std::move(SM),
opts.getSingleOutputFilename(), LLVMContext);
} else {
performIRGeneration(IRGenOpts, Instance.getMainModule(), SM.get(),
performIRGeneration(IRGenOpts, Instance.getMainModule(), std::move(SM),
opts.getSingleOutputFilename(), LLVMContext);
}