[llvm] [LTO] Preserve use list order in save-temps (PR #165882)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 09:31:03 PDT 2025


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/165882

save-temps is debugging functionality, so it should preserve use-lists to keep the optimization/codegen behavior of the dumped bitcode as close to the in-memory IR as possible.

>From aaae64d0a03752e43273cc3285ec35674398969f Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 31 Oct 2025 17:28:58 +0100
Subject: [PATCH] [LTO] Preserve use list order in save-temps

save-temps is debugging functionality, so it should preserve
use-lists to keep the optimization/codegen behavior of the dumped
bitcode as close to the in-memory IR as possible.
---
 llvm/lib/LTO/LTOBackend.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 93118becedbac..8efde8efb3cb1 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -124,7 +124,7 @@ Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath,
       // directly and exit.
       if (EC)
         reportOpenError(Path, EC.message());
-      WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/false);
+      WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/true);
       return true;
     };
   };



More information about the llvm-commits mailing list