[llvm] [IR][NFC] Make PassConcept immovable (PR #208167)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 01:47:17 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
PassConcept is only ever created as a unique_ptr when added to the pass
list of a pass manager. The instances are never copied or moved. Due to
inheritance, this also wouldn't work anyway. Explicitly forbid
copying/moving and remove the dead functions.
Preliminary work for removing the vtable from PassConcept/PassModel.
---
Full diff: https://github.com/llvm/llvm-project/pull/208167.diff
1 Files Affected:
- (modified) llvm/include/llvm/IR/PassManagerInternal.h (+7-15)
``````````diff
diff --git a/llvm/include/llvm/IR/PassManagerInternal.h b/llvm/include/llvm/IR/PassManagerInternal.h
index f96fb02b1d3c5..f894f91cf1783 100644
--- a/llvm/include/llvm/IR/PassManagerInternal.h
+++ b/llvm/include/llvm/IR/PassManagerInternal.h
@@ -38,9 +38,15 @@ namespace detail {
/// polymorphically over pass objects.
template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
struct PassConcept {
+ PassConcept() = default;
+
// Boiler plate necessary for the container of derived classes.
virtual ~PassConcept() = default;
+ // Passes are immovable.
+ PassConcept(const PassConcept &) = delete;
+ PassConcept &operator=(const PassConcept &) = delete;
+
/// The polymorphic API which runs the pass over a given IR entity.
///
/// Note that actual pass object can omit the analysis manager argument if
@@ -71,22 +77,8 @@ struct PassConcept {
/// be a copyable object.
template <typename IRUnitT, typename PassT, typename AnalysisManagerT,
typename... ExtraArgTs>
-struct PassModel : PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...> {
+struct PassModel final : PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...> {
explicit PassModel(PassT Pass) : Pass(std::move(Pass)) {}
- // We have to explicitly define all the special member functions because MSVC
- // refuses to generate them.
- PassModel(const PassModel &Arg) : Pass(Arg.Pass) {}
- PassModel(PassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
-
- friend void swap(PassModel &LHS, PassModel &RHS) {
- using std::swap;
- swap(LHS.Pass, RHS.Pass);
- }
-
- PassModel &operator=(PassModel RHS) {
- swap(*this, RHS);
- return *this;
- }
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM,
ExtraArgTs... ExtraArgs) override {
``````````
</details>
https://github.com/llvm/llvm-project/pull/208167
More information about the llvm-commits
mailing list