Blog post
Week 7: GSoC Project Progress
10 Jul 2026
Hours this week: 16
Total hours: 120
At the end of the sixth week, I had the following tasks to work upon:
- Implement the optimizations like elimination of string comparisions, malloc etc for improving the speed of execution of the mlir backend.
At the end of the sixth week, the Linux x86_64 ELF self-host path was working, but the main remaining task was to understand where the time was being spent and then continue removing backend issues one by one.
This week, I focused on three smaller tasks:
- time benchmarking for the
ELFbackend - working on the
fchmodhandling for the corec platform layer - continuing the local string-to-enum refactor for LLVM dialect handling
Time benchmarking
The first task was to benchmark the ELF self-host pipeline in more detail:
https://github.com/certik/mlir/issues/225
Earlier, the benchmark only gave the final end-to-end timing. This week, I split the flow into smaller steps so that it is clearer where the largest cost comes from. The timing issue shows that the tinyc_stage1_elf pipeline is roughly 3x slower than the clang -O0 bootstrap path overall. It is also roughlt 8x slower than optmized clang builds. So, this gives us a clear direction for optimization work: we need to focus on the stages that are dominating the total runtime.
The detailed split also shows that the largest cost is still in the llvm optimization passes, and the elf backend creation. Out of ~200 seconds on ELF, about 100 sec is consumed by llvm optimizations passes itself, followed by ~30 seconds each for elf backend emission and wasm backend emission. The LLVM optimization passes are still a major bottleneck, and we need to continue optimizing them. So, optimizing the LLVM dialect is the best place to begin with, giving us a significant gains in latency.
Working on fchmod
The second task was around fchmod support in corec:
https://github.com/certik/corec/pull/38
The issue here is that created files need to get the correct mode when O_CREAT is used. Earlier this logic was tied to the WASI adapter, but that is not the right long-term place because each platform handles file creation differently.
The PR moves this handling closer to the platform layer. On Linux, this can be handled through the syscall path. On macOS, the problem is related to calling variadic libc functions such as open, where the mode argument needs special backend handling. This is still being discussed and refined, but the direction is to keep platform-specific behavior in the platform layer rather than embedding it directly in the WASI adapter. It is still a work in progress, to find out the usage of fchmod & implementing platform-specific handling for it.
Local string-to-enum refactor
The third task is a work in progress locally. I have been refactoring the LLVM dialect path to remove string comparisons from hot backend logic and replace them with enum-based checks.
The goal is to keep strings only at parse and print boundaries. Once an MLIR operation is inside the native IR, lowering and backend dispatch should use typed enum values such as MLIR_OpType enums instead of repeatedly comparing operation names as strings.
This should make the code easier to maintain and should also reduce repeated string matching in hot paths like LLVM lowering, LLVM IR translation, and backend emission. The work is still local because it needs a careful reivew: partial conversion can leave mixed string and enum dispatch in the same loop, so the remaining cases need to be audited before it is pushed. I am working on this part, and it will be pushed soon after the review.
Outcome
By the end of this week:
- the
ELFbackend timing data is now split by pipeline stage - the
fchmodplacement is being moved toward platform-specific handling - the LLVM dialect string-comparison cleanup is continuing locally as a WIP
The main next step is to use the benchmark data to guide the next performance fixes, while finishing the enum-based refactor without destabilizing the working ELF self-host path.
Next Steps:
- Continue to work upon the optimizations to improve the performance of the mlir backend.
- Push and merge all the open PRs for the
certik/mlirandcertik/corecrepositories.
Acknowledgments
A huge thanks to my mentors, Ondřej Čertík, Pranav Goswami, Harshita Kalani & other contributors for helping me to work on this project.