i've been trying to learn a bit more about the SIL optimization passes written in swift by adding a new one locally to test things out. however i've yet to be able to successfully run my new pass that does nothing but print() a string without crashing the compiler. what i've tried thus far:
- add a new file in the
SwiftCompilerSources/Sources/Optimizer/FunctionPassesdirectory - update the relevant
CMakeLists.txtwith the new file name - add a new global variable for the pass and stub out the implementation of the
FunctionPasstype with a print statement (trying to copy the scaffolding of the existing swift-based function passes). - update
Passes.defwith a newPASSmacro entry with the appropriate id & tag - update
registerSwiftPasses()to explicitly register the function pass - register the pass with a pipeline in
addMandatoryDiagnosticOptPipelineso it will always run when emitting SIL
after doing this, when i try to run my dev compiler, it crashes on this assertion. i haven't yet made sense of what that assertion is enforcing exactly, nor how to change my code to avoid hitting it. any advice would be appreciated!