This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/50772] New: Inline assembler "A" constrain works non-expectedly on 64-bits target


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]