The purpose of local register variables is to tell gcc which register to use in an inline asm, when multiple registers could be used. Other uses are not supported and usually don't work the way you expect, especially when optimizing.
If all you want is a function which returns the value in a specific register, you could try using an asm like this with a local register variable: __asm__ __volatile__ ("# no actual opcode" : "=r" (r)); That tells gcc that something has put a value in 'r' (although nothing did, so the old value is used). However, usually such registers have global-specific values, so a global register variable is a better choice. If the register may be used by gcc for other purposes, you have no way of predicting what might be in it when that asm happens.