Hi, I am wondering if the following piece of code is supposed to be valid.
void* reg_v13() { register void* r __asm__ ("r13"); return r; } I did test with gcc on powerpc64, and confirmed that the function really returns r13 (thread pointer) value. However, LLVM issues a warning complaining that variable r is not initialized. The argument is that per http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Explicit-Reg-Vars.html#Explicit-Reg-Vars: "Local register variables in specific registers do not reserve the registers, except at the point where they are used as input or output operands in an asm statement and the asm statement itself is not deleted." It seems to mean that register variable does not have connection with the register if the variable is not used in asm statement. If the understanding correct? I could not find an example on official gcc document to support that the example code is valid, although gcc indeed treats r as alias of r13. Thanks, Jing