This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/50772] New: Inline assembler "A" constrain works non-expectedly on 64-bits target
- From: "vagran.ast at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Oct 2011 08:07:00 +0000
- Subject: [Bug inline-asm/50772] New: Inline assembler "A" constrain works non-expectedly on 64-bits target
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50772
Bug #: 50772
Summary: Inline assembler "A" constrain works non-expectedly on
64-bits target
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: inline-asm
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vagran.ast@gmail.com
As per documentation "A" constrain of inline assembler should accept/return
64-bits value in eax:edx registers pair. However it doesn't work on 64-bits
target, the value of just %rdx register is used instead.
Use case example:
rdmsr and wrmsr x86 instruction use eax:edx pair in both 32 and 64 bits mode.
The following code will not work on 64-bits target:
static inline u64
rdmsr(u32 msr)
{
u64 rc;
ASM (
"rdmsr"
: "=A"(rc)
: "c"(msr)
);
return rc;
}
Value in %rdx will be used as the result, %rax value will be discarded. The
same situation when "A" constrain is used as input. It is not a major problem,
it can be easily worked around by additional instructions in inline assembler
block. But IMHO it should be fixed either in the compiler code (preferably) or
in documentation (mention that it is not supported on 64-bits target).