[Bug inline-asm/50772] New: Inline assembler "A" constrain works non-expectedly on 64-bits target
vagran.ast at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 18 08:07:00 GMT 2011
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).
More information about the Gcc-bugs
mailing list