[cfe-dev] Specifying registers for local variables
Simon Atanasyan
simon at atanasyan.com
Thu Dec 18 07:12:56 PST 2014
Hi,
Does LLVM/Clang support specifying registers for local variables?
The following code is accepted by the Clang. It parses the `asm`
attribute in the `Parser::ParseAsmAttributesAfterDeclarator()` routine
and checks the declaration in the `Sema::ActOnVariableDeclarator()`.
But it looks like the asm label expression is not used anywhere
further. Is this language extension is unsupported by the Clang?
% cat check.c
int foo() {
register int v asm ("edx") = 3;
v = v + 1;
return v;
}
The assembler output demonstrates the problem:
% gcc -S check.c && cat check.s
...
movl $3, %edx ; use register
movl %edx, %eax
addl $1, %eax
movl %eax, %edx
movl %edx, %eax
...
% clang -S check.c && cat check.s
...
movl $3, -4(%rbp) ; use stack
movl -4(%rbp), %eax
addl $1, %eax
movl %eax, -4(%rbp)
movl -4(%rbp), %eax
...
--
Simon
More information about the cfe-dev
mailing list