1. A method comprising: receiving source code for a program; translating the source code into an intermediate representation (IR); analyzing the IR to identify at least two objects that could use a first allocated memory space in a thread stack memory; and modifying the IR by replacing references to a first object of the at least two objects with a reference to a second object of the at least two objects.