[llvm-commits] [llvm-gcc-4.2] r76208 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp
Chris Lattner
clattner at apple.com
Fri Jul 17 14:40:21 PDT 2009
On Jul 17, 2009, at 2:32 PM, Eli Friedman wrote:
> On Fri, Jul 17, 2009 at 1:47 PM, Anton
> Korobeynikov<anton at korobeynikov.info> wrote:
>>> Okay, I guess... as long as it doesn't break tying a variable to an
>>> allocatable register. (I'm specifically worried about a variable
>>> being overwritten because it gets allocated over.)
>> It's up to programmer. :) Note that we only translate loads and
>> stores
>> to such variables (modelled as inline asm reading / writing to the
>> specified register), so I think this should be perfectly ok.
>
> The case I'm worried about is something like the following:
> int test() {
> register int x __asm__(("edi")) = 0;
> // Lots of code, where the register allocator
> // happens to reuse edi for something else
> return x; // Returns a random value instead of zero
> // because it's reading the register rather than
> // the value
> }
I don't think "local register variables" are useful for stuff like
that. They are really only useful for getting at things that are
fixed in a function, like "esp". Maybe "pc" on targets that allow
direct access to it like arm.
-Chris
More information about the llvm-commits
mailing list