https://github.com/justinfargnoli updated 
https://github.com/llvm/llvm-project/pull/192155

>From 7c5d872151bb5ab46d83f7e523bee342b3c59354 Mon Sep 17 00:00:00 2001
From: Justin Fargnoli <[email protected]>
Date: Wed, 15 Apr 2026 00:13:15 +0000
Subject: [PATCH 1/2] [LTO] Enable PrepareForLTO for loop unrolling in pre-link
 pipelines

Set PrepareForLTO=true on the LoopFullUnrollPass in the O1 and O2
function simplification pipelines when running in a ThinLTO or
FullLTO pre-link phase. This defers unrolling of loops with calls
that may be inlined during the LTO link phase, allowing the post-link
unroller to make better decisions with fully resolved call targets.
---
 llvm/lib/Passes/PassBuilderPipelines.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index b8c5b1eab2f97..d77b8e1f4998d 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -567,7 +567,8 @@ 
PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
       PGOOpt->Action != PGOOptions::SampleUse)
     LPM2.addPass(LoopFullUnrollPass(static_cast<int>(Level),
                                     /* OnlyWhenForced= */ !PTO.LoopUnrolling,
-                                    PTO.ForgetAllSCEVInLoopUnroll));
+                                    PTO.ForgetAllSCEVInLoopUnroll,
+                                    /* PrepareForLTO= */ isLTOPreLink(Phase)));
 
   invokeLoopOptimizerEndEPCallbacks(LPM2, Level);
 
@@ -749,7 +750,8 @@ 
PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
       PGOOpt->Action != PGOOptions::SampleUse)
     LPM2.addPass(LoopFullUnrollPass(static_cast<int>(Level),
                                     /* OnlyWhenForced= */ !PTO.LoopUnrolling,
-                                    PTO.ForgetAllSCEVInLoopUnroll));
+                                    PTO.ForgetAllSCEVInLoopUnroll,
+                                    /* PrepareForLTO= */ isLTOPreLink(Phase)));
 
   invokeLoopOptimizerEndEPCallbacks(LPM2, Level);
 

>From cfde2c2665b27d3ad162ec31ecb4ea68c1de1f60 Mon Sep 17 00:00:00 2001
From: Justin Fargnoli <[email protected]>
Date: Thu, 27 Aug 2026 19:06:59 +0000
Subject: [PATCH 2/2] Update test

---
 clang/test/CodeGen/fat-lto-objects-cfi.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CodeGen/fat-lto-objects-cfi.cpp 
b/clang/test/CodeGen/fat-lto-objects-cfi.cpp
index a41412e0d5148..f68d8243be76d 100644
--- a/clang/test/CodeGen/fat-lto-objects-cfi.cpp
+++ b/clang/test/CodeGen/fat-lto-objects-cfi.cpp
@@ -17,7 +17,7 @@
 // TYPE_TEST-NEXT:    %cmp14.not = icmp eq i64 %len, 0
 // TYPE_TEST-NEXT:    br i1 %cmp14.not, label %for.end7, label 
%for.cond1.preheader.preheader
 // TYPE_TEST-LABEL: for.cond1.preheader.preheader:                    ; preds 
= %entry
-// TYPE_TEST-NEXT:    %arrayidx.1 = getelementptr inbounds nuw i8, ptr %ptr, 
i64 4
+// TYPE_TEST-NEXT:    %arrayidx.c = getelementptr inbounds nuw i8, ptr %ptr, 
i64 4
 // TYPE_TEST-NEXT:    br label %for.cond1.preheader
 
 // The code below is a reduced case from 
https://github.com/llvm/llvm-project/issues/112053

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to