[clang] [clang-repl] Take the opt level defaults from the driver and cc1 (PR #237999)

Aaron Jomy via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 13:53:37 PST 2026


================
@@ -133,6 +134,9 @@ class Interpreter {
   /// Compiler instance performing the incremental compilation.
   std::unique_ptr<CompilerInstance> CI;
 
+  /// CI's startup CodeGenOptions, to tell explicit options from -O defaults.
+  std::unique_ptr<const CodeGenOptions> InitialCodeGenOpts;
----------------
aaronj0 wrote:

Since setOptLevel modifies that copy, we lose the startup values after the first level change. e.g as seen in the added lit test: the interpreter is created with `-O2 -fno-inline-functions` switching to `O0` and back to `O2` should still keep the functions noinline. Without `InitialCodeGenOpts` that info is not available anymore. How would you suggest handling this without storing startup CodeGenOptions?

https://github.com/llvm/llvm-project/pull/237999


More information about the cfe-commits mailing list