llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang doesn't support pinning variables to registers with __asm__("eax")

Open llvmbot opened this issue 17 years ago • 18 comments

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 ^

llvmbot avatar Apr 03 '09 15:04 llvmbot

mentioned in issue llvm/llvm-bugzilla-archive#8874

llvmbot avatar Nov 27 '21 06:11 llvmbot

mentioned in issue llvm/llvm-project#1234

asl avatar Nov 27 '21 06:11 asl

mentioned in issue llvm/llvm-bugzilla-archive#6665

nlewycky avatar Nov 27 '21 05:11 nlewycky

mentioned in issue llvm/llvm-bugzilla-archive#5511

efriedma-quic avatar Nov 27 '21 05:11 efriedma-quic

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.

llvmbot avatar Dec 31 '10 01:12 llvmbot

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));

llvmbot avatar Dec 30 '10 22:12 llvmbot

*** Bug llvm/llvm-bugzilla-archive#8874 has been marked as a duplicate of this bug. ***

llvmbot avatar Dec 30 '10 21:12 llvmbot

This is now the last thing that keeps us from building all of chromium (binary and all tests) on linux.

nico avatar Dec 19 '10 08:12 nico

I'll take a look.

echristo avatar Nov 30 '10 00:11 echristo

Chromium apparently also needs this.

llvmbot avatar Oct 04 '10 21:10 llvmbot

tcmalloc (google-perftools) also needs this.

llvmbot avatar Jul 22 '10 16:07 llvmbot

*** Bug llvm/llvm-bugzilla-archive#6665 has been marked as a duplicate of this bug. ***

nlewycky avatar Apr 17 '10 07:04 nlewycky

This also seems to prevent the FreeBSD kernel from being built. Fails somewhere when building ACPI code if I remember correctly.

EdSchouten avatar Apr 06 '09 13:04 EdSchouten

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).

llvmbot avatar Apr 06 '09 11:04 llvmbot

Llvmgcc honors it in inline asm stmts that the value is live across, which is technically all that is required for local vars.

lattner avatar Apr 04 '09 06:04 lattner

previously, clang just ignored the register name

There is precedent here; llvm-gcc currently ignores the register name.

efriedma-quic avatar Apr 04 '09 05:04 efriedma-quic

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.

lattner avatar Apr 03 '09 17:04 lattner

assigned to @echristo

llvmbot avatar Apr 03 '09 15:04 llvmbot