Let me think... One difference between the inline function and a global register value is that the function contained an "asm volatile", so the compiler was not allowed to re-order execution. Is KLP using the value of "current_stack_pointer" in a context that might change %r15 by any chance? If that's the case, you may have to save the stack pointer into another variable like this: const unsigned long current_sp = current_stack_pointer The "const" qualifier may be needed to tell the compiler that the value is initialized once and never changed.