[llvm] [PassManager][Loop] Merge loop pass manager when add it (PR #135150)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 04:54:08 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (paperchalice)

<details>
<summary>Changes</summary>

Which aligns the behavior with generic pass manager.

---
Full diff: https://github.com/llvm/llvm-project/pull/135150.diff


1 Files Affected:

- (modified) llvm/include/llvm/Transforms/Scalar/LoopPassManager.h (+14) 


``````````diff
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index f55022fbff07c..02eb87cbda3db 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -130,6 +130,20 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
         new LoopNestPassModelT(std::forward<PassT>(Pass))));
   }
 
+  LLVM_ATTRIBUTE_MINSIZE
+  void addPass(PassManager &&PM) {
+    std::size_t VecSize = PM.IsLoopNestPass.size();
+    IsLoopNestPass.reserve(IsLoopNestPass.size() + VecSize);
+    for (std::size_t I = 0; I != VecSize; ++I)
+      IsLoopNestPass.push_back(PM.IsLoopNestPass[I]);
+    LoopPasses.insert(LoopPasses.end(),
+                      std::make_move_iterator(PM.LoopPasses.begin()),
+                      std::make_move_iterator(PM.LoopPasses.end()));
+    LoopNestPasses.insert(LoopNestPasses.end(),
+                          std::make_move_iterator(PM.LoopNestPasses.begin()),
+                          std::make_move_iterator(PM.LoopNestPasses.end()));
+  }
+
   bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
 
   static bool isRequired() { return true; }

``````````

</details>


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


More information about the llvm-commits mailing list