clang doesn't support pinning variables to registers with __asm__("eax")
| Bugzilla Link | 3933 |
| Resolution | FIXED |
| Resolved on | Dec 30, 2010 17:04 |
| Version | unspecified |
| OS | All |
| Blocks | llvm/llvm-project#1234 llvm/llvm-project#4068 llvm/llvm-bugzilla-archive#5511 |
| Attachments | vm_exec.c |
| Reporter | LLVM Bugzilla Contributor |
| CC | @echristo,@EdSchouten,@efriedma-quic,@zmodem,@ismail,@nlewycky,@nico,@pwo |
Extended Description
At around r68030, ruby was compiling mostly fine (see other ticket on tests failing), now it does not anymore (I'm now using r68372 on OSX).
ruby -Ks ../tool/insns2vm.rb --srcdir=".." vmtc.inc
ruby -Ks ../tool/insns2vm.rb --srcdir=".." vm.inc
clang -O -pipe -m64 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -I. -I.ext/include/i386-darwin9.6.0 -I../include -I.. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o vm.o -c ../vm.c
clang: warning: argument unused during compilation: '-Wno-parentheses'
...
<lots of "uninteresting" warnings skipped>
In file included from ../vm.c:23:
../vm_exec.c:58:5: error: cannot compile this asm yet
DECL_SC_REG(VALUE *, pc, "14");
^
:183:1: note: instantiated from:
reg_pc
^
../vm_exec.c:59:5: error: cannot compile this asm yet
DECL_SC_REG(rb_control_frame_t *, cfp, "15");
^
:184:1: note: instantiated from:
reg_cfp
^
mentioned in issue llvm/llvm-bugzilla-archive#8874
mentioned in issue llvm/llvm-project#1234
mentioned in issue llvm/llvm-bugzilla-archive#6665
mentioned in issue llvm/llvm-bugzilla-archive#5511
I think the most important part has been fixed in 122643. We are intentionally more restrictive than gcc, if too restrictive for a particular use, please open a new bug report.
The generated code also has more moves than the one produced by gcc, but that is an llvm problem, not clang's.
I intend to do a partial fix for this as described in llvm/llvm-bugzilla-archive#8874 . Just remember that a variable was declared with asm("reg") and use that register if the variable is an argument to a asm statement.
We should probably also reject or at least warn about things like
register uint64_t foo asm("rbx");
asm("..." : "=a" (foo));
*** Bug llvm/llvm-bugzilla-archive#8874 has been marked as a duplicate of this bug. ***
This is now the last thing that keeps us from building all of chromium (binary and all tests) on linux.
I'll take a look.
Chromium apparently also needs this.
tcmalloc (google-perftools) also needs this.
*** Bug llvm/llvm-bugzilla-archive#6665 has been marked as a duplicate of this bug. ***
This also seems to prevent the FreeBSD kernel from being built. Fails somewhere when building ACPI code if I remember correctly.
Llvmgcc honors it in inline asm stmts that the value is live across, which is technically all that is required for local vars.
FYI, I've opened bug #1357 on redmine.ruby-lang.org about this with a patch removing the assignment-to-specific-registers code (see http://redmine.ruby-lang.org/issues/show/1357).
Llvmgcc honors it in inline asm stmts that the value is live across, which is technically all that is required for local vars.
previously, clang just ignored the register name
There is precedent here; llvm-gcc currently ignores the register name.
previously, clang just ignored the register name, which could lead to miscompilations, telling the user that we don't support it yet is better. One work-around for this is to just remove the asm register declaration from the source, its use is dubious anyway.
assigned to @echristo