11. raw SIL
- raw SIL code is generated from SILGen
- raw SIL has not been optimized and diagnosed
- optimized and diagnosed on SILOptimizer phase
raw SIL
12. canonical SIL
- Optimized and diagnosed SIL code is canonical SIL
- on SILOptimizer phase
canonical
SIL
14. SILOptimizer
- SILOptimizer is one of phase in swiftc
- raw SIL is optimized and diagnosed on this phase
- It is consist of many module which called Pass
SILOptimizer
17. Pass in SILOptimizer
- Pass diagnoses and optimizes received ras SIL
- Some of Passes are called definitely
Pass
18. Pass Pipeline
- Pass Pipeline has info which Passes must be called
- Pipeline is created before starting optimizing
- Pass in Pipeline is decided by …
- swiftc Option (e.g.-O,-Onone) etc …
19. Pass in SILOptimizer
- Example of Optimizer Pass
- Memory Promotion
- Assuming Single Thread (Optional Optimizer)
Pass
20. Pass in SILOptimizer
- Example of Diagnostic Pass
- Overflow checking of Numeric Type
Pass
21. Pass in SILOptimizer
- Example of Diagnostic Pass
- Overflow checking of Numeric Type
Let's check it by Demo!
by using -Xllvm -sil-print-pass-name option
Pass
23. SIL
- SIL is generated from our Swift Code
- via type-checked AST
- raw SIL and canonical SIL
- canonical SIL is optimized and diagnosed SIL
24. SILOptimizer and Pass
- SILOptimizer is phase of optimizing and diagnosing
- SILOptimizer is consist of many Pass
- raw SIL is optimized and diagnosed by Pass
26. To add original Pass to swiftc
1. Create your C++ file (because Pass is C++ class)
@ lib/SILOptimizer/Transforms/*.cpp
27. To add original Pass to swiftc
2. Add location of C++ source for Pass Class
to lib/SILOptimizer/Transforms/CMakeLists.txt
3. Generate swiftc Xcode Project
※ You must do 2.before generating Xcode Project
28. 4. Register Pass info
@ include/swift/SILOptimizer/PassManager/Passes.def
5. Rebuild on Xcode
6. Add code which adding Pass to Pipeline
@ lib/SILOptimizer/PassManager/PassPipeline.cpp
To add original Pass to swiftc
29. 7. Write Pass Class and Creating Pass object func
@ on your C++ file which is added on 1.
To add original Pass to swiftc