The IAR compiler allows a user to lock general registers from r15 and down by using compiler options and this keyword syntax:

__regvar __no_init volatile unsigned int filteredTimeSinceCommutation @14;

This line locks r14 for use only when explicitly referenced in your code thorugh the var name "filteredTimeSinceCommutation". This means that the compiler cannot dispose of it at its own will.

To do this in AVR GCC, do this:

register unsigned char counter asm("r3");

Typically, it should be possible to use r2 through r15 that way.