The evolution of the stellar mass function in star clusters