LLVM 24.0.0git
PassManager.cpp
Go to the documentation of this file.
1//===- PassManager.cpp - Runs a pipeline of Sandbox IR passes -------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
12
13namespace llvm::sandboxir {
14
15bool FunctionPassManager::runOnFunction(Function &F, const Analyses &A) {
16 bool Change = false;
17 for (auto &Pass : Passes) {
18#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)
19 auto HashBefore = F.hash();
20#endif
21 bool PassChange = Pass->runOnFunction(F, A);
22#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)
23 auto HashAfter = F.hash();
24 assert((PassChange || HashAfter == HashBefore) &&
25 "The pass returned false (i.e., no change) but the IR changed!");
26#endif
27 Change |= PassChange;
28 // TODO: run the verifier.
29 }
30 return Change;
31}
32
34 bool Change = false;
35 for (auto &Pass : Passes) {
36#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)
37 auto &F = R.getParentFunction();
38 auto HashBefore = F.hash();
39#endif
40 bool PassChange = Pass->runOnRegion(R, A);
41#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)
42 auto HashAfter = F.hash();
43 assert((PassChange || HashAfter == HashBefore) &&
44 "The pass returned false (i.e., no change) but the IR changed!");
45#endif
46 Change |= PassChange;
47 // TODO: run the verifier.
48 }
49 return Change;
51
52} // namespace llvm::sandboxir
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define F(x, y, z)
Definition MD5.cpp:54
SmallVector< std::unique_ptr< FunctionPass > > Passes
Definition PassManager.h:43
The base class of a Sandbox IR Pass.
Definition Pass.h:53
bool runOnRegion(Region &R, const Analyses &A) final
\Returns true if it modifies R.