[cfe-commits] r122643 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGStmt.cpp test/CodeGen/asm-variable.c

Benjamin Kramer benny.kra at googlemail.com
Thu Dec 30 16:08:15 PST 2010


On 30.12.2010, at 23:59, Rafael Espindola wrote:

> Author: rafael
> Date: Thu Dec 30 16:59:32 2010
> New Revision: 122643
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=122643&view=rev
> Log:
> Add support for declaring register contraints in variables. They are only used
> in asm statements:
> 
> register int foo asm("rdi");
> 
> asm("..." : ... "r" (foo) ...
> 
> We also only accept these variables if the constraint in the asm statement is "r".
> 
> This fixes most of PR3933.

I'm not very happy with this fix. Using such a pinned variable with inline asm looks like an edge case.

Most code (e.g. ruby 1.9) uses this as a (premature) optimization so it shouldn't hurt there but on the other hand
the linux kernel uses this extension to access the stack pointer like a variable.

register unsigned long current_stack_pointer asm("esp");
foo = current_stack_pointer;

We used to error out on this, now we treat it like normal stack variable and miscompile the code.



More information about the cfe-commits mailing list