aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Interpreter/Interpreter.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2021-10-06 13:57:29 -0700
committerArthur Eubanks <aeubanks@google.com>2021-10-15 10:13:17 -0700
commit47eb99aa44ab1d20327d67a49d6c47163de76387 (patch)
tree225c8bd33f2c84d072e00017a6177adcf7c51c7a /clang/lib/Interpreter/Interpreter.cpp
parentccbfcfda1e21f95498ec9b00504b929fcc297a13 (diff)
downloadllvm-47eb99aa44ab1d20327d67a49d6c47163de76387.zip
llvm-47eb99aa44ab1d20327d67a49d6c47163de76387.tar.gz
llvm-47eb99aa44ab1d20327d67a49d6c47163de76387.tar.bz2
[clang] Pass -clear-ast-before-backend in Clang::ConstructJob()
This clears the memory used for the Clang AST before we run LLVM passes. https://llvm-compile-time-tracker.com/compare.php?from=d0a5f61c4f6fccec87fd5207e3fcd9502dd59854&to=b7437fee79e04464dd968e1a29185495f3590481&stat=max-rss shows significant memory savings with no slowdown (in fact -O0 slightly speeds up). For more background, see https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html. Turn this off for the interpreter since it does codegen multiple times. Differential Revision: https://reviews.llvm.org/D111270
Diffstat (limited to 'clang/lib/Interpreter/Interpreter.cpp')
-rw-r--r--clang/lib/Interpreter/Interpreter.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 02b3025..d14940d 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -113,6 +113,10 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
+ // Don't clear the AST before backend codegen since we do codegen multiple
+ // times, reusing the same AST.
+ Clang->getCodeGenOpts().ClearASTBeforeBackend = false;
+
return std::move(Clang);
}