lkml.org 
[lkml]   [2013]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Multiple local register variables w/ same register
On Wed, Nov 20, 2013 at 07:56:57AM +1000, Richard Henderson wrote:
> It appears not:
>
> int __attribute__((noinline)) f(void)
> {
> {
> register int x __asm__("eax");
> x = 1;
> }
> {
> register int y __asm__("eax");
> return ++y;
> }
> }
>
> extern void abort(void);
>
> int main(void)
> {
> if (f() != 2)
> abort();
> return 0;
> }
>
> Anyone see anything wrong with the testcase? Do we thing this sort of thing
> ought to work, perhaps with scopes lengthened?

I'd say this is undefined, when a local register var goes out of scope,
it's value can change arbitrarily. If you insert some call in between the
two scopes, it will surely have clobbered value, and even if there isn't
any call in between those, any insn could in theory clobber those.

Jakub


\
 
 \ /
  Last update: 2013-11-19 23:21    [W:0.055 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site