================ @@ -129,6 +129,26 @@ static void optimizeDiagnosticOpts(DiagnosticOptions &Opts, Opts.Remarks.clear(); } +static void optimizeCWD(FileSystemOptions &FSOpts, CodeGenOptions &CGOpts, + const std::string &CWD) { + FSOpts.WorkingDir.clear(); + if (CGOpts.DwarfVersion) { ---------------- jansvoboda11 wrote:
Even if we don't take this branch (and therefore don't need to modify `CodeGenOptions`), we already might've made an unnecessary copy in the caller by calling `getMutCodeGenOpts()`. Can we pass the entire `CowCompilerInvocation &` into this function and then implement the logic like this? ```c++ if (CI.getCodeGenOpts().DwarfVersion) { CI.getMutCodeGenOpts().DebugCompilationDir = ...; } ``` `CodeGenOptions` is large (1824B) and making a copy for each module unnecessarily seems excessive. Even if the optimization does kick in, it's still excessive to make a separate copy of `CodeGenOptions` for each module. We don't make any other module-specific changes to `CodeGenOptions` anywhere in the scanner, so they will all end up being identical copies. (At least for a single TU.) Maybe we could keep just two versions of `CodeGenOptions` for each TU: one with and one without `DebugCompilationDir`) and refer to either one or the other from all discovered modules' command lines. That's a bit more involved though and `CowCompilerInvocation` doesn't have a good API for this, so let's not sink time into it right now. Maybe leaving a FIXME here would be nice. https://github.com/llvm/llvm-project/pull/128446 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits