Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2024 ChilliBits. All rights reserved. | ||
2 | |||
3 | #pragma once | ||
4 | |||
5 | #include <CompilerPass.h> | ||
6 | #include <SourceFile.h> | ||
7 | #include <global/GlobalResourceManager.h> | ||
8 | |||
9 | #include <llvm/Analysis/AliasAnalysis.h> | ||
10 | #include <llvm/Analysis/CGSCCPassManager.h> | ||
11 | #include <llvm/Analysis/LoopAnalysisManager.h> | ||
12 | #include <llvm/Passes/OptimizationLevel.h> | ||
13 | #include <llvm/Passes/PassBuilder.h> | ||
14 | #include <llvm/Passes/StandardInstrumentations.h> | ||
15 | |||
16 | namespace spice::compiler { | ||
17 | |||
18 | class IROptimizer : CompilerPass { | ||
19 | public: | ||
20 | // Constructors | ||
21 | 31 | IROptimizer(GlobalResourceManager &resourceManager, SourceFile *sourceFile) | |
22 | 31 | : CompilerPass(resourceManager, sourceFile), | |
23 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 29 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
|
31 | si(cliOptions.useLTO ? resourceManager.ltoContext : sourceFile->context, false, resourceManager.cliOptions.testMode, |
24 |
5/10✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 31 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 31 times.
✗ Branch 15 not taken.
|
62 | llvm::PrintPassOptions(false, true, false)) {} |
25 | |||
26 | // Public methods | ||
27 | void prepare(); | ||
28 | void optimizeDefault(); | ||
29 | void optimizePreLink(); | ||
30 | void optimizePostLink(); | ||
31 | |||
32 | private: | ||
33 | // Private members | ||
34 | llvm::LoopAnalysisManager loopAnalysisMgr; | ||
35 | llvm::FunctionAnalysisManager functionAnalysisMgr; | ||
36 | llvm::CGSCCAnalysisManager cgsccAnalysisMgr; | ||
37 | llvm::ModuleAnalysisManager moduleAnalysisMgr; | ||
38 | llvm::StandardInstrumentations si; | ||
39 | llvm::PassInstrumentationCallbacks pic; | ||
40 | std::unique_ptr<llvm::PassBuilder> passBuilder; | ||
41 | |||
42 | // Private methods | ||
43 | [[nodiscard]] llvm::OptimizationLevel getLLVMOptLevelFromSpiceOptLevel() const; | ||
44 | }; | ||
45 | |||
46 | } // namespace spice::compiler | ||
47 |