Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
llvmbot opened this issue Apr 3, 2009 · 18 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:codegen

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 3, 2009

Bugzilla Link 3933
Resolution FIXED
Resolved on Dec 30, 2010 17:04
Version unspecified
OS All
Blocks #1234 #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
Copy link
Collaborator Author

llvmbot commented Apr 3, 2009

assigned to @echristo

@lattner
Copy link
Collaborator

lattner commented Apr 3, 2009

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.

@efriedma-quic
Copy link
Collaborator

previously, clang just ignored the register name

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

@lattner
Copy link
Collaborator

lattner commented Apr 4, 2009

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 6, 2009

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

@EdSchouten
Copy link
Contributor

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

@nlewycky
Copy link
Contributor

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 22, 2010

tcmalloc (google-perftools) also needs this.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 4, 2010

Chromium apparently also needs this.

@echristo
Copy link
Contributor

I'll take a look.

@nico
Copy link
Contributor

nico commented Dec 19, 2010

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 30, 2010

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 30, 2010

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
Copy link
Collaborator Author

llvmbot commented Dec 31, 2010

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.

@efriedma-quic
Copy link
Collaborator

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

@nlewycky
Copy link
Contributor

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

@asl
Copy link
Collaborator

asl commented Nov 27, 2021

mentioned in issue #1234

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 27, 2021

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen
Projects
None yet
Development

No branches or pull requests

8 participants