Move more logic from IRModuleWriter to IRSlalomFunction