[clang] [lld] [llvm] [DTLTO] Refactor the DTLTO code. (PR #192629)

Teresa Johnson via cfe-commits cfe-commits at lists.llvm.org
Fri May 29 12:47:37 PDT 2026


================
@@ -1299,10 +1299,7 @@ Error LTO::checkPartiallySplit() {
 }
 
 Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
-  llvm::scope_exit CleanUp([this]() { cleanup(); });
-
-  if (Error EC = serializeInputsForDistribution())
-    return EC;
+  llvm::scope_exit CleanUp([this]() { LTO::cleanup(); });
----------------
teresajohnson wrote:

Why do we need to call LTO::cleanup() rather than just cleanup() now? Oh I see, DTLTO::run() invokes performThinLink which invokes Base::run, and you want the DTLTO::cleanup to happen later, on exit from DTLTO::run presumably. Can you add a comment here that any derived LTO (specifically DLTO) is expected to invoke its own cleanup itself? And that we don't want to inadvertently do the derived class cleanup too early if it invokes LTO::run?

Thankfully, it looks like LTO::cleanup, which will end up getting called twice, can handle that. But perhaps DTLTO::cleanup should not invoke Base::cleanup? 

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


More information about the cfe-commits mailing list