Separate functions that require shared state into a class to avoid needing to pass them though multiple functions just to be available where needed.
The main motivation for this is that we would like to remove the limitation that accumulator values be dynamic constant, which would require additional shared state between call eliminations in the same function, compounding this issue.
Please make sure this class is in an anonymous namespace.