Post-build IL optimizer and intermediate representation for .NET programs (experimental).
Cilica is a continuation of DistIL.
Try Cilica Lab in your browser to explore optimization passes, control-flow graphs, and generated code.
- SSA-based Intermediate Representation
- Linq Expansion
- Loop Strength Reduction
- Loop Vectorization
- List Pre-sizing
- Devirtualization
- Method Inlining
- Scalar Replacement
See Optimization Passes for a detailed list of optimizations passes available.
Cilica.Cli -i input/MyLibrary.dll -o output/MyLibrary.dllThe Cilica.OptimizerTask NuGet package contains an MSBuild task which automatically invokes the optimizer on the output project assembly when building in Release mode. It requires the .NET 10+. Install the preview package with:
dotnet add package Cilica.OptimizerTask --prereleaseBy default, only methods and classes annotated with [Cilica.Attributes.Optimize] will be transformed. This can be changed by setting the CilicaAllMethods project property to true:
<CilicaAllMethods>true</CilicaAllMethods>Set RunCilica to enable or disable optimization explicitly, and use CilicaExtraArgs to pass additional CLI options.
Use --skip-module-initializers to omit explicit module-initialization checks when the runtime initializes modules before use. Cilica.OptimizerTask enables this by default with PublishAot=true; set CilicaSkipModuleInitializers=false to override it.
Use --nativeaot-compat when invoking the CLI before NativeAOT compilation. Cilica.OptimizerTask enables this automatically with PublishAot=true.
The optimizer task processes your main assembly by default. To include managed dependencies and framework assemblies in a self-contained build or publish, enable CilicaAllAssemblies:
<SelfContained>true</SelfContained>
<CilicaAllAssemblies>true</CilicaAllAssemblies>Under this mode, assembly signatures and ReadyToRun code will be removed, and CilicaAllMethods will be set to true; set it to false to retain attribute filtering.
There's also a Cilica.Core package that exposes the optimizer and intermediate representation APIs for direct use.