| 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 final : CompilerPass { | ||
| 19 | public: | ||
| 20 | // Constructors | ||
| 21 | 894 | IROptimizer(GlobalResourceManager &resourceManager, SourceFile *sourceFile) | |
| 22 | 894 | : CompilerPass(resourceManager, sourceFile), | |
| 23 |
3/4✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 9 taken 891 times.
✓ Branch 10 → 11 taken 894 times.
✗ Branch 10 → 16 not taken.
|
894 | si(cliOptions.useLTO ? resourceManager.ltoContext : sourceFile->context, false, resourceManager.cliOptions.testMode, |
| 24 |
5/10✓ Branch 3 → 4 taken 894 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 894 times.
✗ Branch 4 → 22 not taken.
✓ Branch 5 → 6 taken 894 times.
✗ Branch 5 → 20 not taken.
✓ Branch 6 → 7 taken 894 times.
✗ Branch 6 → 18 not taken.
✓ Branch 11 → 12 taken 894 times.
✗ Branch 11 → 14 not taken.
|
1788 | 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 | void addInstrumentationPassToPipeline(llvm::ModulePassManager& modulePassMgr) const; | ||
| 44 | [[nodiscard]] llvm::OptimizationLevel getLLVMOptLevelFromSpiceOptLevel() const; | ||
| 45 | }; | ||
| 46 | |||
| 47 | } // namespace spice::compiler | ||
| 48 |