Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2025 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 (7→8) taken 2 times.
✓ Branch 1 (7→9) taken 29 times.
✓ Branch 2 (10→11) taken 31 times.
✗ Branch 3 (10→16) not taken.
|
31 | si(cliOptions.useLTO ? resourceManager.ltoContext : sourceFile->context, false, resourceManager.cliOptions.testMode, |
24 |
5/10✓ Branch 0 (3→4) taken 31 times.
✗ Branch 1 (3→24) not taken.
✓ Branch 2 (4→5) taken 31 times.
✗ Branch 3 (4→22) not taken.
✓ Branch 4 (5→6) taken 31 times.
✗ Branch 5 (5→20) not taken.
✓ Branch 6 (6→7) taken 31 times.
✗ Branch 7 (6→18) not taken.
✓ Branch 8 (11→12) taken 31 times.
✗ Branch 9 (11→14) 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 |