1 //===- lld/Core/PassManager.h - Manage linker passes ----------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_CORE_PASS_MANAGER_H
10 #define LLD_CORE_PASS_MANAGER_H
12 #include "lld/Common/LLVM.h"
13 #include "lld/Core/Pass.h"
14 #include "llvm/Support/Error.h"
22 /// Owns and runs a collection of passes.
24 /// This class is currently just a container for passes and a way to run them.
26 /// In the future this should handle timing pass runs, running parallel passes,
27 /// and validate/satisfy pass dependencies.
30 void add(std::unique_ptr<Pass> pass) {
31 _passes.push_back(std::move(pass));
34 llvm::Error runOnFile(SimpleFile &file) {
35 for (std::unique_ptr<Pass> &pass : _passes)
36 if (llvm::Error EC = pass->perform(file))
38 return llvm::Error::success();
42 /// Passes in the order they should run.
43 std::vector<std::unique_ptr<Pass>> _passes;
45 } // end namespace lld