diff options
author | Arthur Eubanks <aeubanks@google.com> | 2021-09-14 13:09:23 -0700 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2021-10-06 13:42:22 -0700 |
commit | 6522b7cc3240626952ebc271d8714043a805911d (patch) | |
tree | dc8fc7c9587a8a77002a204bf9ad3695d0301a88 /clang/lib/CodeGen/CodeGenAction.cpp | |
parent | 05392466f02bca49bf3381a64d109c5263354169 (diff) | |
download | llvm-6522b7cc3240626952ebc271d8714043a805911d.zip llvm-6522b7cc3240626952ebc271d8714043a805911d.tar.gz llvm-6522b7cc3240626952ebc271d8714043a805911d.tar.bz2 |
[clang] Add option to clear AST memory before running LLVM passes
This is to save memory for Clang compiles.
Measuring building PassBuilder.cpp under /usr/bin/time, max rss goes from 0.93GB to 0.7GB.
This does not turn it by default yet.
I've turned on the option locally and run it over a good amount of files without any issues.
For more background, see
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D111105
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 9fb5f29..4ca34db 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -351,6 +351,11 @@ namespace clang { } } + // FIXME: Fix cleanup issues with clearing the AST when we properly free + // things. + if (CodeGenOpts.DisableFree && CodeGenOpts.ClearASTBeforeBackend) + C.getAllocator().Reset(); + EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef()); EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, |